Package org.h2.mvstore
Class Page.Leaf<K,V>
- java.lang.Object
-
- org.h2.mvstore.Page<K,V>
-
- org.h2.mvstore.Page.Leaf<K,V>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.h2.mvstore.Page
Page.PageReference<K,V>
-
-
Field Summary
Fields Modifier and Type Field Description private V[]valuesThe storage for values.-
Fields inherited from class org.h2.mvstore.Page
map, PAGE_LEAF_MEMORY, PAGE_MEMORY_CHILD, PAGE_NODE_MEMORY, pageNo
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected intcalculateMemory()Calculate estimated memory used in persistent case.Page<K,V>copy(MVMap<K,V> map, boolean eraseChildrenRefs)Create a copy of this page with potentially different owning map.voiddump(java.lang.StringBuilder buff)Dump debug data for this page.voidexpand(int extraKeyCount, K[] extraKeys, V[] extraValues)Append additional key/value mappings to this Page.CursorPos<K,V>getAppendCursorPos(CursorPos<K,V> cursorPos)Extend path from a given CursorPos chain to "append point" in a B-tree, rooted at this Page.Page<K,V>getChildPage(int index)Get the child page at the given index.longgetChildPagePos(int index)Get the position of the child.(package private) longgetCounts(int index)Get the number of key-value pairs for a given child.intgetNodeType()CursorPos<K,V>getPrependCursorPos(CursorPos<K,V> cursorPos)Extend path from a given CursorPos chain to "prepend point" in a B-tree, rooted at this Page.intgetRawChildPageCount()longgetTotalCount()Get the total number of key-value pairs, including child pages.VgetValue(int index)Get the value at the given index.voidinsertLeaf(int index, K key, V value)Insert a key-value pair into this leaf.voidinsertNode(int index, K key, Page<K,V> childPage)Insert a child page into this node.protected voidreadPayLoad(java.nio.ByteBuffer buff)Read the page payload from the buffer.(package private) voidreleaseSavedPages()Unlink the children recursively after all data is written.voidremove(int index)Remove the key and value (or child) at the given index.intremoveAllRecursive(long version)Remove all page data recursively.voidsetChild(int index, Page<K,V> c)Replace the child page.VsetValue(int index, V value)Replace the value at an index in this page.private VsetValueInternal(int index, V value)Page<K,V>split(int at)Split the page.protected voidwriteChildren(WriteBuffer buff, boolean withCounts)Write page children to the buff.(package private) voidwriteUnsavedRecursive(Chunk chunk, WriteBuffer buff, java.util.List<java.lang.Long> toc)Store this page and all children that are changed, in reverse order, and update the position and the children.protected voidwriteValues(WriteBuffer buff)Write values that the buffer contains to the buff.-
Methods inherited from class org.h2.mvstore.Page
addMemory, binarySearch, clone, copy, createEmptyLeaf, createEmptyNode, createKeyStorage, createLeaf, createNode, createRefStorage, createValueStorage, expandKeys, get, getDiskSpaceUsed, getKey, getKeyCount, getMapId, getMemory, getPos, insertKey, isComplete, isLeaf, isPersistent, isRemoved, isSaved, read, recalculateMemory, removePage, setComplete, setKey, splitKeys, toString, write
-
-
-
-
Field Detail
-
values
private V[] values
The storage for values.
-
-
Method Detail
-
getNodeType
public int getNodeType()
- Specified by:
getNodeTypein classPage<K,V>
-
copy
public Page<K,V> copy(MVMap<K,V> map, boolean eraseChildrenRefs)
Description copied from class:PageCreate 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
-
getChildPage
public Page<K,V> getChildPage(int index)
Description copied from class:PageGet the child page at the given index.- Specified by:
getChildPagein classPage<K,V>- Parameters:
index- the index- Returns:
- the child page
-
getChildPagePos
public long getChildPagePos(int index)
Description copied from class:PageGet the position of the child.- Specified by:
getChildPagePosin classPage<K,V>- Parameters:
index- the index- Returns:
- the position
-
getValue
public V getValue(int index)
Description copied from class:PageGet the value at the given index.
-
split
public Page<K,V> split(int at)
Description copied from class:PageSplit the page. This modifies the current page.
-
expand
public void expand(int extraKeyCount, K[] extraKeys, V[] extraValues)Description copied from class:PageAppend additional key/value mappings to this Page. New mappings suppose to be in correct key order.
-
getTotalCount
public long getTotalCount()
Description copied from class:PageGet the total number of key-value pairs, including child pages.- Specified by:
getTotalCountin classPage<K,V>- Returns:
- the number of key-value pairs
-
getCounts
long getCounts(int index)
Description copied from class:PageGet the number of key-value pairs for a given child.
-
setChild
public void setChild(int index, Page<K,V> c)Description copied from class:PageReplace the child page.
-
setValue
public V setValue(int index, V value)
Description copied from class:PageReplace the value at an index in this page.
-
insertLeaf
public void insertLeaf(int index, K key, V value)Description copied from class:PageInsert a key-value pair into this leaf.- Specified by:
insertLeafin classPage<K,V>- Parameters:
index- the indexkey- the keyvalue- the value
-
insertNode
public void insertNode(int index, K key, Page<K,V> childPage)Description copied from class:PageInsert a child page into this node.- Specified by:
insertNodein classPage<K,V>- Parameters:
index- the indexkey- the keychildPage- the child page
-
remove
public void remove(int index)
Description copied from class:PageRemove the key and value (or child) at the given index.
-
removeAllRecursive
public int removeAllRecursive(long version)
Description copied from class:PageRemove all page data recursively.- Specified by:
removeAllRecursivein classPage<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:PageExtend path from a given CursorPos chain to "prepend point" in a B-tree, rooted at this Page.- Specified by:
getPrependCursorPosin classPage<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:PageExtend path from a given CursorPos chain to "append point" in a B-tree, rooted at this Page.- Specified by:
getAppendCursorPosin classPage<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(java.nio.ByteBuffer buff)
Description copied from class:PageRead the page payload from the buffer.- Specified by:
readPayLoadin classPage<K,V>- Parameters:
buff- the buffer
-
writeValues
protected void writeValues(WriteBuffer buff)
Description copied from class:PageWrite values that the buffer contains to the buff.- Specified by:
writeValuesin classPage<K,V>- Parameters:
buff- the target buffer
-
writeChildren
protected void writeChildren(WriteBuffer buff, boolean withCounts)
Description copied from class:PageWrite page children to the buff.- Specified by:
writeChildrenin classPage<K,V>- Parameters:
buff- the target bufferwithCounts- true if the descendant counts should be written
-
writeUnsavedRecursive
void writeUnsavedRecursive(Chunk chunk, WriteBuffer buff, java.util.List<java.lang.Long> toc)
Description copied from class:PageStore this page and all children that are changed, in reverse order, and update the position and the children.- Specified by:
writeUnsavedRecursivein classPage<K,V>- Parameters:
chunk- the chunkbuff- the target buffertoc- prospective table of content
-
releaseSavedPages
void releaseSavedPages()
Description copied from class:PageUnlink the children recursively after all data is written.- Specified by:
releaseSavedPagesin classPage<K,V>
-
getRawChildPageCount
public int getRawChildPageCount()
- Specified by:
getRawChildPageCountin classPage<K,V>
-
calculateMemory
protected int calculateMemory()
Description copied from class:PageCalculate estimated memory used in persistent case.- Overrides:
calculateMemoryin classPage<K,V>- Returns:
- memory in bytes
-
-