text: //===----------------------------------------------------------------------===//
  //
  //                         CMU-DB Project (15-445/645)
  //                         ***DO NO SHARE PUBLICLY***
  //
  // Identification: src/page/b_plus_tree_internal_page.cpp
  //
  // Copyright (c) 2018, Carnegie Mellon University Database Group
  //
  //===----------------------------------------------------------------------===//
  
  #include <iostream>
  #include <sstream>
  
  #include "common/exception.h"
  #include "storage/page/b_plus_tree_internal_page.h"
  
  namespace bustub {
  /*****************************************************************************
   * HELPER METHODS AND UTILITIES
   *****************************************************************************/
  /*
   * Init method after creating a new internal page
   * Including set page type, set current size, set page id, set parent id and set
   * max page size
   */
  INDEX_TEMPLATE_ARGUMENTS
  void B_PLUS_TREE_INTERNAL_PAGE_TYPE::Init(page_id_t page_id, page_id_t parent_id, int max_size) {}
  /*
   * Helper method to get/set the key associated with input "index"(a.k.a
   * array offset)
   */
  INDEX_TEMPLATE_ARGUMENTS
  KeyType B_PLUS_TREE_INTERNAL_PAGE_TYPE::KeyAt(int index) const {
    // replace with your own code
    KeyType key{};
    return key;
  }
  
  INDEX_TEMPLATE_ARGUMENTS
  void B_PLUS_TREE_INTERNAL_PAGE_TYPE::SetKeyAt(int index, const KeyType &key) {}
  
  /*
   * Helper method to find and return array index(or offset), so that its value
   * equals to input "value"
   */
  INDEX_TEMPLATE_ARGUMENTS
  int B_PLUS_TREE_INTERNAL_PAGE_TYPE::ValueIndex(const ValueType &value) const { return 0; }
  
  /*
   * Helper method to get the value associated with input "index"(a.k.a array
   * offset)
   */
  INDEX_TEMPLATE_ARGUMENTS
  ValueType B_PLUS_TREE_INTERNAL_PAGE_TYPE::ValueAt(int index) const { return 0; }
  
  /*****************************************************************************
   * LOOKUP
   *****************************************************************************/
  /*
   * Find and return the child pointer(page_id) which points to the child page
   * that contains input "key"
   * Start the search from the second key(the first key should always be invalid)
   */
  INDEX_TEMPLATE_ARGUMENTS
  ValueType B_PLUS_TREE_INTERNAL_PAGE_TYPE::Lookup(const KeyType &key, const KeyComparator &comparator) const {
    return INVALID_PAGE_ID;
  }
  
  /*****************************************************************************
   * INSERTION
   *****************************************************************************/
  /*
   * Populate new root page with old_value + new_key & new_value
   * When the insertion cause overflow from leaf page all the way upto the root
   * page, you should create a new root page and populate its elements.
   * NOTE: This method is only called within InsertIntoParent()(b_plus_tree.cpp)
   */
  INDEX_TEMPLATE_ARGUMENTS
  void B_PLUS_TREE_INTERNAL_PAGE_TYPE::PopulateNewRoot(const ValueType &old_value, const KeyType &new_key,
                                                       const ValueType &new_value) {}
  /*
   * Insert new_key & new_value pair right after the pair with its value ==
   * old_value
   * @return:  new size after insertion
   */
  INDEX_TEMPLATE_ARGUMENTS
  int B_PLUS_TREE_INTERNAL_PAGE_TYPE::InsertNodeAfter(const ValueType &old_value, const KeyType &new_key,
                                                      const ValueType &new_value) {
    return 0;
  }
  
  /*****************************************************************************
   * SPLIT
   *****************************************************************************/
  /*
   * Remove half of key & value pairs from this page to "recipient" page
   */
  INDEX_TEMPLATE_ARGUMENTS
  void B_PLUS_TREE_INTERNAL_PAGE_TYPE::MoveHalfTo(BPlusTreeInternalPage *recipient,
                                                  BufferPoolManager *buffer_pool_manager) {}
  
  INDEX_TEMPLATE_ARGUMENTS
  void B_PLUS_TREE_INTERNAL_PAGE_TYPE::CopyHalfFrom(MappingType *items, int size,
                                                    BufferPoolManager *buffer_pool_manager) {}
  
  /*****************************************************************************
   * REMOVE
   *****************************************************************************/
  /*
   * Remove the key & value pair in internal page according to input index(a.k.a
   * array offset)
   * NOTE: store key&value pair continuously after deletion
   */
  INDEX_TEMPLATE_ARGUMENTS
  void B_PLUS_TREE_INTERNAL_PAGE_TYPE::Remove(int index) {}
  
  /*
   * Remove the only key & value pair in internal page and return the value
   * NOTE: only call this method within AdjustRoot()(in b_plus_tree.cpp)
   */
  INDEX_TEMPLATE_ARGUMENTS
  ValueType B_PLUS_TREE_INTERNAL_PAGE_TYPE::RemoveAndReturnOnlyChild() { return INVALID_PAGE_ID; }
  /*****************************************************************************
   * MERGE
   *****************************************************************************/
  /*
   * Remove all of key & value pairs from this page to "recipient" page, then
   * update relavent key & value pair in its parent page.
   */
  INDEX_TEMPLATE_ARGUMENTS
  void B_PLUS_TREE_INTERNAL_PAGE_TYPE::MoveAllTo(BPlusTreeInternalPage *recipient, int index_in_parent,
                                                 BufferPoolManager *buffer_pool_manager) {}
  
  INDEX_TEMPLATE_ARGUMENTS
  void B_PLUS_TREE_INTERNAL_PAGE_TYPE::CopyAllFrom(MappingType *items, int size, BufferPoolManager *buffer_pool_manager) {
  }
  
  /*****************************************************************************
   * REDISTRIBUTE
   *****************************************************************************/
  /*
   * Remove the first key & value pair from this page to tail of "recipient"
   * page, then update relavent key & value pair in its parent page.
   */
  INDEX_TEMPLATE_ARGUMENTS
  void B_PLUS_TREE_INTERNAL_PAGE_TYPE::MoveFirstToEndOf(BPlusTreeInternalPage *recipient,
                                                        BufferPoolManager *buffer_pool_manager) {}
  
  INDEX_TEMPLATE_ARGUMENTS
  void B_PLUS_TREE_INTERNAL_PAGE_TYPE::CopyLastFrom(const MappingType &pair, BufferPoolManager *buffer_pool_manager) {}
  
  /*
   * Remove the last key & value pair from this page to head of "recipient"
   * page, then update relavent key & value pair in its parent page.
   */
  INDEX_TEMPLATE_ARGUMENTS
  void B_PLUS_TREE_INTERNAL_PAGE_TYPE::MoveLastToFrontOf(BPlusTreeInternalPage *recipient, int parent_index,
                                                         BufferPoolManager *buffer_pool_manager) {}
  
  INDEX_TEMPLATE_ARGUMENTS
  void B_PLUS_TREE_INTERNAL_PAGE_TYPE::CopyFirstFrom(const MappingType &pair, int parent_index,
                                                     BufferPoolManager *buffer_pool_manager) {}
  
  // valuetype for internalNode should be page id_t
  template class BPlusTreeInternalPage<GenericKey<4>, page_id_t, GenericComparator<4>>;
  template class BPlusTreeInternalPage<GenericKey<8>, page_id_t, GenericComparator<8>>;
  template class BPlusTreeInternalPage<GenericKey<16>, page_id_t, GenericComparator<16>>;
  template class BPlusTreeInternalPage<GenericKey<32>, page_id_t, GenericComparator<32>>;
  template class BPlusTreeInternalPage<GenericKey<64>, page_id_t, GenericComparator<64>>;
  }  // namespace bustub
  