private CacheDataPage nestRootDataPage(CacheDataPage rootDataPage) throws IOException {
  DataPageMain rootMain=rootDataPage._main;
  DataPageExtra rootExtra=rootDataPage._extra;
  if (!rootMain.isRoot()) {
    throw new IllegalArgumentException(withErrorContext("should be called with root, duh"));
  }
  CacheDataPage newDataPage=allocateNewCacheDataPage(rootMain._pageNumber,rootMain._leaf);
  DataPageMain newMain=newDataPage._main;
  DataPageExtra newExtra=newDataPage._extra;
  newMain._childTailPageNumber=rootMain._childTailPageNumber;
  newExtra._entries=rootExtra._entries;
  newExtra._entryPrefix=rootExtra._entryPrefix;
  newExtra._totalEntrySize=rootExtra._totalEntrySize;
  newExtra.setEntryView(newMain);
  if (!newMain._leaf) {
    reparentChildren(newDataPage);
  }
  rootMain._leaf=false;
  rootMain._childTailPageNumber=INVALID_INDEX_PAGE_NUMBER;
  rootExtra._entries=new ArrayList<Entry>();
  rootExtra._entryPrefix=EMPTY_PREFIX;
  rootExtra._totalEntrySize=0;
  rootExtra.setEntryView(rootMain);
  addParentEntry(rootDataPage,newDataPage);
  return newDataPage;
}

private CacheDataPage nestRootDataPage ( CacheDataPage rootDataPage ) throws IOException { DataPageMain rootMain = rootDataPage . _main ; DataPageExtra rootExtra = rootDataPage . _extra ; if ( ! rootMain . isRoot ( ) ) { throw new IllegalArgumentException ( withErrorContext ( "should be called with root, duh" ) ) ; } CacheDataPage newDataPage = allocateNewCacheDataPage ( rootMain . _pageNumber , rootMain . _leaf ) ; DataPageMain newMain = newDataPage . _main ; DataPageExtra newExtra = newDataPage . _extra ; newMain . _childTailPageNumber = rootMain . _childTailPageNumber ; newExtra . _entries = rootExtra . _entries ; newExtra . _entryPrefix = rootExtra . _entryPrefix ; newExtra . _totalEntrySize = rootExtra . _totalEntrySize ; newExtra . setEntryView ( newMain ) ; if ( ! newMain . _leaf ) { reparentChildren ( newDataPage ) ; } rootMain . _leaf = false ; rootMain . _childTailPageNumber = INVALID_INDEX_PAGE_NUMBER ; rootExtra . _entries = new ArrayList < Entry > ( ) ; rootExtra . _entryPrefix = EMPTY_PREFIX ; rootExtra . _totalEntrySize = 0 ; rootExtra . setEntryView ( rootMain ) ; addParentEntry ( rootDataPage , newDataPage ) ; return newDataPage ; }
copies the current root page info into a new page and nests this page under the root page . this must be done when the root page needs to be split .
