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[]
values
The 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 int
calculateMemory()
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.void
dump(java.lang.StringBuilder buff)
Dump debug data for this page.void
expand(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.long
getChildPagePos(int index)
Get the position of the child.(package private) long
getCounts(int index)
Get the number of key-value pairs for a given child.int
getNodeType()
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.int
getRawChildPageCount()
long
getTotalCount()
Get the total number of key-value pairs, including child pages.V
getValue(int index)
Get the value at the given index.void
insertLeaf(int index, K key, V value)
Insert a key-value pair into this leaf.void
insertNode(int index, K key, Page<K,V> childPage)
Insert a child page into this node.protected void
readPayLoad(java.nio.ByteBuffer buff)
Read the page payload from the buffer.(package private) void
releaseSavedPages()
Unlink the children recursively after all data is written.void
remove(int index)
Remove the key and value (or child) at the given index.int
removeAllRecursive(long version)
Remove all page data recursively.void
setChild(int index, Page<K,V> c)
Replace the child page.V
setValue(int index, V value)
Replace the value at an index in this page.private V
setValueInternal(int index, V value)
Page<K,V>
split(int at)
Split the page.protected void
writeChildren(WriteBuffer buff, boolean withCounts)
Write page children to the buff.(package private) void
writeUnsavedRecursive(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 void
writeValues(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:
getNodeType
in classPage<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
-
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 classPage<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 classPage<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.
-
split
public Page<K,V> split(int at)
Description copied from class:Page
Split the page. This modifies the current page.
-
expand
public void expand(int extraKeyCount, K[] extraKeys, V[] extraValues)
Description copied from class:Page
Append additional key/value mappings to this Page. New mappings suppose to be in correct key order.
-
getTotalCount
public long getTotalCount()
Description copied from class:Page
Get the total number of key-value pairs, including child pages.- Specified by:
getTotalCount
in classPage<K,V>
- Returns:
- the number of key-value pairs
-
getCounts
long getCounts(int index)
Description copied from class:Page
Get the number of key-value pairs for a given child.
-
setChild
public void setChild(int index, Page<K,V> c)
Description copied from class:Page
Replace the child page.
-
setValue
public V setValue(int index, V value)
Description copied from class:Page
Replace the value at an index in this page.
-
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 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:Page
Insert a child page into this node.- Specified by:
insertNode
in classPage<K,V>
- Parameters:
index
- the indexkey
- the keychildPage
- 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.
-
removeAllRecursive
public int removeAllRecursive(long version)
Description copied from class:Page
Remove all page data recursively.- Specified by:
removeAllRecursive
in 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:Page
Extend path from a given CursorPos chain to "prepend point" in a B-tree, rooted at this Page.- Specified by:
getPrependCursorPos
in 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:Page
Extend path from a given CursorPos chain to "append point" in a B-tree, rooted at this Page.- Specified by:
getAppendCursorPos
in 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:Page
Read the page payload from the buffer.- Specified by:
readPayLoad
in classPage<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 classPage<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 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:Page
Store this page and all children that are changed, in reverse order, and update the position and the children.- Specified by:
writeUnsavedRecursive
in classPage<K,V>
- Parameters:
chunk
- the chunkbuff
- the target buffertoc
- prospective table of content
-
releaseSavedPages
void releaseSavedPages()
Description copied from class:Page
Unlink the children recursively after all data is written.- Specified by:
releaseSavedPages
in classPage<K,V>
-
getRawChildPageCount
public int getRawChildPageCount()
- Specified by:
getRawChildPageCount
in classPage<K,V>
-
calculateMemory
protected int calculateMemory()
Description copied from class:Page
Calculate estimated memory used in persistent case.- Overrides:
calculateMemory
in classPage<K,V>
- Returns:
- memory in bytes
-
-