Class Page.NonLeaf<K,V>

java.lang.Object
org.h2.mvstore.Page<K,V>
org.h2.mvstore.Page.NonLeaf<K,V>
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
Page.IncompleteNonLeaf
Enclosing class:
Page<K,V>

private static class Page.NonLeaf<K,V> extends Page<K,V>
  • Field Details

    • children

      private Page.PageReference<K,V>[] children
      The child page references.
    • totalCount

      private long totalCount
      The total entry count of this page and all children.
  • Constructor Details

  • Method Details

    • getNodeType

      public int getNodeType()
      Specified by:
      getNodeType in class Page<K,V>
    • copy

      public Page<K,V> copy(MVMap<K,V> map, boolean eraseChildrenRefs)
      Description copied from class: Page
      Create a copy of this page with potentially different owning map. This is used exclusively during bulk map copying. Child page references for nodes are cleared (re-pointed to an empty page) to be filled-in later to copying procedure. This way it can be saved mid-process without tree integrity violation
      Specified by:
      copy in class Page<K,V>
      Parameters:
      map - new map to own resulting page
      eraseChildrenRefs - whether cloned Page should have no child references or keep originals
      Returns:
      the page
    • getChildPage

      public Page<K,V> getChildPage(int index)
      Description copied from class: Page
      Get the child page at the given index.
      Specified by:
      getChildPage in class Page<K,V>
      Parameters:
      index - the index
      Returns:
      the child page
    • getChildPagePos

      public long getChildPagePos(int index)
      Description copied from class: Page
      Get the position of the child.
      Specified by:
      getChildPagePos in class Page<K,V>
      Parameters:
      index - the index
      Returns:
      the position
    • getValue

      public V getValue(int index)
      Description copied from class: Page
      Get the value at the given index.
      Specified by:
      getValue in class Page<K,V>
      Parameters:
      index - the index
      Returns:
      the value
    • split

      public Page<K,V> split(int at)
      Description copied from class: Page
      Split the page. This modifies the current page.
      Specified by:
      split in class Page<K,V>
      Parameters:
      at - the split index
      Returns:
      the page with the entries after the split index
    • expand

      public void expand(int keyCount, Object[] extraKeys, Object[] extraValues)
      Description copied from class: Page
      Append additional key/value mappings to this Page. New mappings suppose to be in correct key order.
      Specified by:
      expand in class Page<K,V>
      Parameters:
      keyCount - number of mappings to be added
      extraKeys - to be added
      extraValues - to be added
    • getTotalCount

      public long getTotalCount()
      Description copied from class: Page
      Get the total number of key-value pairs, including child pages.
      Specified by:
      getTotalCount in class Page<K,V>
      Returns:
      the number of key-value pairs
    • calculateTotalCount

      private long calculateTotalCount()
    • recalculateTotalCount

      void recalculateTotalCount()
    • getCounts

      long getCounts(int index)
      Description copied from class: Page
      Get the number of key-value pairs for a given child.
      Specified by:
      getCounts in class Page<K,V>
      Parameters:
      index - the child index
      Returns:
      the descendant count
    • setChild

      public void setChild(int index, Page<K,V> c)
      Description copied from class: Page
      Replace the child page.
      Specified by:
      setChild in class Page<K,V>
      Parameters:
      index - the index
      c - the new child page
    • setValue

      public V setValue(int index, V value)
      Description copied from class: Page
      Replace the value at an index in this page.
      Specified by:
      setValue in class Page<K,V>
      Parameters:
      index - the index
      value - the new value
      Returns:
      the old value
    • insertLeaf

      public void insertLeaf(int index, K key, V value)
      Description copied from class: Page
      Insert a key-value pair into this leaf.
      Specified by:
      insertLeaf in class Page<K,V>
      Parameters:
      index - the index
      key - the key
      value - the value
    • insertNode

      public void insertNode(int index, K key, Page<K,V> childPage)
      Description copied from class: Page
      Insert a child page into this node.
      Specified by:
      insertNode in class Page<K,V>
      Parameters:
      index - the index
      key - the key
      childPage - the child page
    • remove

      public void remove(int index)
      Description copied from class: Page
      Remove the key and value (or child) at the given index.
      Overrides:
      remove in class Page<K,V>
      Parameters:
      index - the index
    • removeAllRecursive

      public int removeAllRecursive(long version)
      Description copied from class: Page
      Remove all page data recursively.
      Specified by:
      removeAllRecursive in class Page<K,V>
      Parameters:
      version - at which page got removed
      Returns:
      adjustment for "unsaved memory" amount
    • getPrependCursorPos

      public CursorPos<K,V> getPrependCursorPos(CursorPos<K,V> cursorPos)
      Description copied from class: Page
      Extend path from a given CursorPos chain to "prepend point" in a B-tree, rooted at this Page.
      Specified by:
      getPrependCursorPos in class Page<K,V>
      Parameters:
      cursorPos - presumably pointing to this Page (null if real root), to build upon
      Returns:
      new head of the CursorPos chain
    • getAppendCursorPos

      public CursorPos<K,V> getAppendCursorPos(CursorPos<K,V> cursorPos)
      Description copied from class: Page
      Extend path from a given CursorPos chain to "append point" in a B-tree, rooted at this Page.
      Specified by:
      getAppendCursorPos in class Page<K,V>
      Parameters:
      cursorPos - presumably pointing to this Page (null if real root), to build upon
      Returns:
      new head of the CursorPos chain
    • readPayLoad

      protected void readPayLoad(ByteBuffer buff)
      Description copied from class: Page
      Read the page payload from the buffer.
      Specified by:
      readPayLoad in class Page<K,V>
      Parameters:
      buff - the buffer
    • writeValues

      protected void writeValues(WriteBuffer buff)
      Description copied from class: Page
      Write values that the buffer contains to the buff.
      Specified by:
      writeValues in class Page<K,V>
      Parameters:
      buff - the target buffer
    • writeChildren

      protected void writeChildren(WriteBuffer buff, boolean withCounts)
      Description copied from class: Page
      Write page children to the buff.
      Specified by:
      writeChildren in class Page<K,V>
      Parameters:
      buff - the target buffer
      withCounts - true if the descendant counts should be written
    • writeUnsavedRecursive

      void writeUnsavedRecursive(Chunk chunk, WriteBuffer buff, List<Long> toc)
      Description copied from class: Page
      Store this page and all children that are changed, in reverse order, and update the position and the children.
      Specified by:
      writeUnsavedRecursive in class Page<K,V>
      Parameters:
      chunk - the chunk
      buff - the target buffer
      toc - prospective table of content
    • writeChildrenRecursive

      void writeChildrenRecursive(Chunk chunk, WriteBuffer buff, List<Long> toc)
    • releaseSavedPages

      void releaseSavedPages()
      Description copied from class: Page
      Unlink the children recursively after all data is written.
      Specified by:
      releaseSavedPages in class Page<K,V>
    • getRawChildPageCount

      public int getRawChildPageCount()
      Specified by:
      getRawChildPageCount in class Page<K,V>
    • calculateMemory

      protected int calculateMemory()
      Description copied from class: Page
      Calculate estimated memory used in persistent case.
      Overrides:
      calculateMemory in class Page<K,V>
      Returns:
      memory in bytes
    • dump

      public void dump(StringBuilder buff)
      Description copied from class: Page
      Dump debug data for this page.
      Overrides:
      dump in class Page<K,V>
      Parameters:
      buff - append buffer