diff --git a/src/include/storage/index/index_iterator.h b/src/include/storage/index/index_iterator.h index 72c0519ed..d54fea58d 100644 --- a/src/include/storage/index/index_iterator.h +++ b/src/include/storage/index/index_iterator.h @@ -35,9 +35,9 @@ class IndexIterator { auto operator++() -> IndexIterator &; - auto operator==(const IndexIterator &itr) const -> bool { throw std::runtime_error("unimplemented"); } + auto operator==(const IndexIterator &itr) const -> bool { UNIMPLEMENTED("TODO(P2): Add implementation."); } - auto operator!=(const IndexIterator &itr) const -> bool { throw std::runtime_error("unimplemented"); } + auto operator!=(const IndexIterator &itr) const -> bool { UNIMPLEMENTED("TODO(P2): Add implementation."); } private: // add your own private member variables here diff --git a/src/include/storage/page/b_plus_tree_internal_page.h b/src/include/storage/page/b_plus_tree_internal_page.h index 7530c1b67..54e8748c3 100644 --- a/src/include/storage/page/b_plus_tree_internal_page.h +++ b/src/include/storage/page/b_plus_tree_internal_page.h @@ -94,7 +94,7 @@ class BPlusTreeInternalPage : public BPlusTreePage { // Array members for page data. KeyType key_array_[INTERNAL_PAGE_SLOT_CNT]; ValueType page_id_array_[INTERNAL_PAGE_SLOT_CNT]; - // (Fall 2024) Feel free to add more fields and helper functions below if needed + // (Spring 2025) Feel free to add more fields and helper functions below if needed }; } // namespace bustub diff --git a/src/include/storage/page/b_plus_tree_leaf_page.h b/src/include/storage/page/b_plus_tree_leaf_page.h index ed7ba9c7b..6915aa809 100644 --- a/src/include/storage/page/b_plus_tree_leaf_page.h +++ b/src/include/storage/page/b_plus_tree_leaf_page.h @@ -92,7 +92,7 @@ class BPlusTreeLeafPage : public BPlusTreePage { // Array members for page data. KeyType key_array_[LEAF_PAGE_SLOT_CNT]; ValueType rid_array_[LEAF_PAGE_SLOT_CNT]; - // (Fall 2024) Feel free to add more fields and helper functions below if needed + // (Spring 2025) Feel free to add more fields and helper functions below if needed }; } // namespace bustub diff --git a/src/include/storage/page/b_plus_tree_page.h b/src/include/storage/page/b_plus_tree_page.h index ea716b01f..66bd9a315 100644 --- a/src/include/storage/page/b_plus_tree_page.h +++ b/src/include/storage/page/b_plus_tree_page.h @@ -58,6 +58,9 @@ class BPlusTreePage { void SetMaxSize(int max_size); auto GetMinSize() const -> int; + /* + * TODO(P2): Remove __attribute__((__unused__)) if you intend to use the fields. + */ private: // Member variables, attributes that both internal and leaf page share IndexPageType page_type_ __attribute__((__unused__)); diff --git a/src/storage/index/b_plus_tree.cpp b/src/storage/index/b_plus_tree.cpp index d915a7309..37997f902 100644 --- a/src/storage/index/b_plus_tree.cpp +++ b/src/storage/index/b_plus_tree.cpp @@ -34,7 +34,7 @@ BPLUSTREE_TYPE::BPlusTree(std::string name, page_id_t header_page_id, BufferPool * @return Returns true if this B+ tree has no keys and values. */ INDEX_TEMPLATE_ARGUMENTS -auto BPLUSTREE_TYPE::IsEmpty() const -> bool { return true; } +auto BPLUSTREE_TYPE::IsEmpty() const -> bool { UNIMPLEMENTED("TODO(P2): Add implementation."); } /***************************************************************************** * SEARCH @@ -50,10 +50,9 @@ auto BPLUSTREE_TYPE::IsEmpty() const -> bool { return true; } */ INDEX_TEMPLATE_ARGUMENTS auto BPLUSTREE_TYPE::GetValue(const KeyType &key, std::vector *result) -> bool { - // Declaration of context instance. + UNIMPLEMENTED("TODO(P2): Add implementation."); + // Declaration of context instance. Using the Context is not necessary but advised. Context ctx; - (void)ctx; - return false; } /***************************************************************************** @@ -72,10 +71,9 @@ auto BPLUSTREE_TYPE::GetValue(const KeyType &key, std::vector *result */ INDEX_TEMPLATE_ARGUMENTS auto BPLUSTREE_TYPE::Insert(const KeyType &key, const ValueType &value) -> bool { - // Declaration of context instance. + UNIMPLEMENTED("TODO(P2): Add implementation."); + // Declaration of context instance. Using the Context is not necessary but advised. Context ctx; - (void)ctx; - return false; } /***************************************************************************** @@ -94,7 +92,7 @@ INDEX_TEMPLATE_ARGUMENTS void BPLUSTREE_TYPE::Remove(const KeyType &key) { // Declaration of context instance. Context ctx; - (void)ctx; + UNIMPLEMENTED("TODO(P2): Add implementation."); } /***************************************************************************** @@ -103,10 +101,13 @@ void BPLUSTREE_TYPE::Remove(const KeyType &key) { /** * @brief Input parameter is void, find the leftmost leaf page first, then construct * index iterator + * + * You may want to implement this while implementing Task #3. + * * @return : index iterator */ INDEX_TEMPLATE_ARGUMENTS -auto BPLUSTREE_TYPE::Begin() -> INDEXITERATOR_TYPE { return INDEXITERATOR_TYPE(); } +auto BPLUSTREE_TYPE::Begin() -> INDEXITERATOR_TYPE { UNIMPLEMENTED("TODO(P2): Add implementation."); } /** * @brief Input parameter is low key, find the leaf page that contains the input key @@ -114,7 +115,7 @@ auto BPLUSTREE_TYPE::Begin() -> INDEXITERATOR_TYPE { return INDEXITERATOR_TYPE() * @return : index iterator */ INDEX_TEMPLATE_ARGUMENTS -auto BPLUSTREE_TYPE::Begin(const KeyType &key) -> INDEXITERATOR_TYPE { return INDEXITERATOR_TYPE(); } +auto BPLUSTREE_TYPE::Begin(const KeyType &key) -> INDEXITERATOR_TYPE { UNIMPLEMENTED("TODO(P2): Add implementation."); } /** * @brief Input parameter is void, construct an index iterator representing the end @@ -122,13 +123,15 @@ auto BPLUSTREE_TYPE::Begin(const KeyType &key) -> INDEXITERATOR_TYPE { return IN * @return : index iterator */ INDEX_TEMPLATE_ARGUMENTS -auto BPLUSTREE_TYPE::End() -> INDEXITERATOR_TYPE { return INDEXITERATOR_TYPE(); } +auto BPLUSTREE_TYPE::End() -> INDEXITERATOR_TYPE { UNIMPLEMENTED("TODO(P2): Add implementation."); } /** * @return Page id of the root of this tree + * + * You may want to implement this while implementing Task #3. */ INDEX_TEMPLATE_ARGUMENTS -auto BPLUSTREE_TYPE::GetRootPageId() -> page_id_t { return 0; } +auto BPLUSTREE_TYPE::GetRootPageId() -> page_id_t { UNIMPLEMENTED("TODO(P2): Add implementation."); } template class BPlusTree, RID, GenericComparator<4>>; diff --git a/src/storage/index/index_iterator.cpp b/src/storage/index/index_iterator.cpp index 15d05f19f..73b897479 100644 --- a/src/storage/index/index_iterator.cpp +++ b/src/storage/index/index_iterator.cpp @@ -30,15 +30,15 @@ INDEX_TEMPLATE_ARGUMENTS INDEXITERATOR_TYPE::~IndexIterator() = default; // NOLINT INDEX_TEMPLATE_ARGUMENTS -auto INDEXITERATOR_TYPE::IsEnd() -> bool { throw std::runtime_error("unimplemented"); } +auto INDEXITERATOR_TYPE::IsEnd() -> bool { UNIMPLEMENTED("TODO(P2): Add implementation."); } INDEX_TEMPLATE_ARGUMENTS auto INDEXITERATOR_TYPE::operator*() -> std::pair { - throw std::runtime_error("unimplemented"); + UNIMPLEMENTED("TODO(P2): Add implementation."); } INDEX_TEMPLATE_ARGUMENTS -auto INDEXITERATOR_TYPE::operator++() -> INDEXITERATOR_TYPE & { throw std::runtime_error("unimplemented"); } +auto INDEXITERATOR_TYPE::operator++() -> INDEXITERATOR_TYPE & { UNIMPLEMENTED("TODO(P2): Add implementation."); } template class IndexIterator, RID, GenericComparator<4>>; diff --git a/src/storage/page/b_plus_tree_internal_page.cpp b/src/storage/page/b_plus_tree_internal_page.cpp index f60441407..0e72857ec 100644 --- a/src/storage/page/b_plus_tree_internal_page.cpp +++ b/src/storage/page/b_plus_tree_internal_page.cpp @@ -31,7 +31,7 @@ namespace bustub { * @param max_size Maximal size of the page */ INDEX_TEMPLATE_ARGUMENTS -void B_PLUS_TREE_INTERNAL_PAGE_TYPE::Init(int max_size) {} +void B_PLUS_TREE_INTERNAL_PAGE_TYPE::Init(int max_size) { UNIMPLEMENTED("TODO(P2): Add implementation."); } /** * @brief Helper method to get/set the key associated with input "index"(a.k.a @@ -41,7 +41,9 @@ void B_PLUS_TREE_INTERNAL_PAGE_TYPE::Init(int max_size) {} * @return Key at index */ INDEX_TEMPLATE_ARGUMENTS -auto B_PLUS_TREE_INTERNAL_PAGE_TYPE::KeyAt(int index) const -> KeyType { return {}; } +auto B_PLUS_TREE_INTERNAL_PAGE_TYPE::KeyAt(int index) const -> KeyType { + UNIMPLEMENTED("TODO(P2): Add implementation."); +} /** * @brief Set key at the specified index. @@ -50,7 +52,9 @@ auto B_PLUS_TREE_INTERNAL_PAGE_TYPE::KeyAt(int index) const -> KeyType { return * @param key The new value for key */ INDEX_TEMPLATE_ARGUMENTS -void B_PLUS_TREE_INTERNAL_PAGE_TYPE::SetKeyAt(int index, const KeyType &key) {} +void B_PLUS_TREE_INTERNAL_PAGE_TYPE::SetKeyAt(int index, const KeyType &key) { + UNIMPLEMENTED("TODO(P2): Add implementation."); +} /** * @brief Helper method to get the value associated with input "index"(a.k.a array @@ -60,7 +64,9 @@ void B_PLUS_TREE_INTERNAL_PAGE_TYPE::SetKeyAt(int index, const KeyType &key) {} * @return Value at index */ INDEX_TEMPLATE_ARGUMENTS -auto B_PLUS_TREE_INTERNAL_PAGE_TYPE::ValueAt(int index) const -> ValueType { return 0; } +auto B_PLUS_TREE_INTERNAL_PAGE_TYPE::ValueAt(int index) const -> ValueType { + UNIMPLEMENTED("TODO(P2): Add implementation."); +} // valuetype for internalNode should be page id_t template class BPlusTreeInternalPage, page_id_t, GenericComparator<4>>; diff --git a/src/storage/page/b_plus_tree_leaf_page.cpp b/src/storage/page/b_plus_tree_leaf_page.cpp index 79d40d282..3199994ef 100644 --- a/src/storage/page/b_plus_tree_leaf_page.cpp +++ b/src/storage/page/b_plus_tree_leaf_page.cpp @@ -32,23 +32,25 @@ namespace bustub { * @param max_size Max size of the leaf node */ INDEX_TEMPLATE_ARGUMENTS -void B_PLUS_TREE_LEAF_PAGE_TYPE::Init(int max_size) {} +void B_PLUS_TREE_LEAF_PAGE_TYPE::Init(int max_size) { UNIMPLEMENTED("TODO(P2): Add implementation."); } /** * Helper methods to set/get next page id */ INDEX_TEMPLATE_ARGUMENTS -auto B_PLUS_TREE_LEAF_PAGE_TYPE::GetNextPageId() const -> page_id_t { return INVALID_PAGE_ID; } +auto B_PLUS_TREE_LEAF_PAGE_TYPE::GetNextPageId() const -> page_id_t { UNIMPLEMENTED("TODO(P2): Add implementation."); } INDEX_TEMPLATE_ARGUMENTS -void B_PLUS_TREE_LEAF_PAGE_TYPE::SetNextPageId(page_id_t next_page_id) {} +void B_PLUS_TREE_LEAF_PAGE_TYPE::SetNextPageId(page_id_t next_page_id) { + UNIMPLEMENTED("TODO(P2): Add implementation."); +} /* * Helper method to find and return the key associated with input "index" (a.k.a * array offset) */ INDEX_TEMPLATE_ARGUMENTS -auto B_PLUS_TREE_LEAF_PAGE_TYPE::KeyAt(int index) const -> KeyType { return {}; } +auto B_PLUS_TREE_LEAF_PAGE_TYPE::KeyAt(int index) const -> KeyType { UNIMPLEMENTED("TODO(P2): Add implementation."); } template class BPlusTreeLeafPage, RID, GenericComparator<4>>; template class BPlusTreeLeafPage, RID, GenericComparator<8>>; diff --git a/src/storage/page/b_plus_tree_page.cpp b/src/storage/page/b_plus_tree_page.cpp index ac6999e63..182e663bf 100644 --- a/src/storage/page/b_plus_tree_page.cpp +++ b/src/storage/page/b_plus_tree_page.cpp @@ -18,28 +18,28 @@ namespace bustub { * Helper methods to get/set page type * Page type enum class is defined in b_plus_tree_page.h */ -auto BPlusTreePage::IsLeafPage() const -> bool { return false; } -void BPlusTreePage::SetPageType(IndexPageType page_type) {} +auto BPlusTreePage::IsLeafPage() const -> bool { UNIMPLEMENTED("TODO(P2): Add implementation."); } +void BPlusTreePage::SetPageType(IndexPageType page_type) { UNIMPLEMENTED("TODO(P2): Add implementation."); } /* * Helper methods to get/set size (number of key/value pairs stored in that * page) */ -auto BPlusTreePage::GetSize() const -> int { return 0; } -void BPlusTreePage::SetSize(int size) {} -void BPlusTreePage::ChangeSizeBy(int amount) {} +auto BPlusTreePage::GetSize() const -> int { UNIMPLEMENTED("TODO(P2): Add implementation."); } +void BPlusTreePage::SetSize(int size) { UNIMPLEMENTED("TODO(P2): Add implementation."); } +void BPlusTreePage::ChangeSizeBy(int amount) { UNIMPLEMENTED("TODO(P2): Add implementation."); } /* * Helper methods to get/set max size (capacity) of the page */ -auto BPlusTreePage::GetMaxSize() const -> int { return 0; } -void BPlusTreePage::SetMaxSize(int size) {} +auto BPlusTreePage::GetMaxSize() const -> int { UNIMPLEMENTED("TODO(P2): Add implementation."); } +void BPlusTreePage::SetMaxSize(int size) { UNIMPLEMENTED("TODO(P2): Add implementation."); } /* * Helper method to get min page size * Generally, min page size == max page size / 2 * But whether you will take ceil() or floor() depends on your implementation */ -auto BPlusTreePage::GetMinSize() const -> int { return 0; } +auto BPlusTreePage::GetMinSize() const -> int { UNIMPLEMENTED("TODO(P2): Add implementation."); } } // namespace bustub