K - The type for the KeyV - The type for the stored valueclass PersistedNode<K,V> extends AbstractPage<K,V>
btree, children, keys, lastOffset, nbElems, offset, revision| Constructor and Description |
|---|
PersistedNode(BTree<K,V> btree,
long revision,
int nbElems)
Creates a new Node which will contain only one key, with references to
a left and right page.
|
PersistedNode(BTree<K,V> btree,
long revision,
K key,
Page<K,V> leftPage,
Page<K,V> rightPage)
Creates a new Node which will contain only one key, with references to
a left and right page.
|
PersistedNode(BTree<K,V> btree,
long revision,
K key,
PageHolder<K,V> leftPage,
PageHolder<K,V> rightPage)
Creates a new Node which will contain only one key, with references to
a left and right page.
|
| Modifier and Type | Method and Description |
|---|---|
private InsertResult<K,V> |
addAndSplit(java.util.List<Page<K,V>> copiedPages,
long revision,
K pivot,
Page<K,V> leftPage,
Page<K,V> rightPage,
int pos)
Splits a full page into two new pages, a left, a right and a pivot element.
|
private DeleteResult<K,V> |
borrowFromLeft(long revision,
MergedWithSiblingResult<K,V> mergedResult,
PersistedNode<K,V> sibling,
int pos)
Borrows an element from the left sibling, creating a new sibling with one
less element and creating a new page where the element to remove has been
deleted and the borrowed element added on the left.
|
private DeleteResult<K,V> |
borrowFromRight(long revision,
MergedWithSiblingResult<K,V> mergedResult,
PersistedNode<K,V> sibling,
int pos)
Borrows an element from the right sibling, creating a new sibling with one
less element and creating a new page where the element to remove has been
deleted and the borrowed element added on the right.
|
protected PersistedNode<K,V> |
copy(long revision)
Copies the current page and all its keys, with a new revision.
|
private PageHolder<K,V> |
createHolder(Page<K,V> page)
Creates a new holder containing a reference to a Page
|
(package private) DeleteResult<K,V> |
delete(K key,
V value,
long revision,
Page<K,V> parent,
int parentPos)
The real delete implementation.
|
(package private) KeyHolder<K> |
getKeyHolder(int pos) |
K |
getLeftMostKey()
Finds the leftmost key in this page.
|
K |
getRightMostKey()
Finds the rightmost key in this page.
|
private RemoveResult<K,V> |
handleBorrowedResult(BorrowedFromSiblingResult<K,V> borrowedResult,
int pos)
The deletion in a children has moved an element from one of its sibling.
|
private RemoveResult<K,V> |
handleRemoveResult(RemoveResult<K,V> removeResult,
int index,
int pos,
boolean found)
Modifies the current node after a remove has been done in one of its children.
|
private RemoveResult<K,V> |
handleRootRemove(MergedWithSiblingResult<K,V> mergedResult,
int pos,
boolean found)
Handles the removal of an element from the root page, when two of its children
have been merged.
|
InsertResult<K,V> |
insert(K key,
V value,
long revision) |
private InsertResult<K,V> |
insertChild(java.util.List<Page<K,V>> copiedPages,
long revision,
K key,
Page<K,V> leftPage,
Page<K,V> rightPage,
int pos)
Adds a new key into a copy of the current page at a given position.
|
boolean |
isLeaf() |
boolean |
isNode() |
private DeleteResult<K,V> |
mergeWithSibling(long revision,
MergedWithSiblingResult<K,V> mergedResult,
PersistedNode<K,V> sibling,
boolean isLeft,
int pos)
We have to merge the node with its sibling, both have N/2 elements before the element
removal.
|
private RemoveResult<K,V> |
removeKey(MergedWithSiblingResult<K,V> mergedResult,
long revision,
int pos)
Remove the key at a given position.
|
private InsertResult<K,V> |
replaceChild(long revision,
ModifyResult<K,V> result,
int pos)
This method is used when we have to replace a child in a page when we have
found the key in the tree (the value will be changed, so we have made
copies of the existing pages).
|
(package private) void |
setValue(int pos,
PersistedPageHolder<K,V> value)
Set the value at a give position
|
java.lang.String |
toString() |
browse, browse, browseKeys, compare, contains, delete, dumpPage, findLeftMost, findPos, findRightMost, get, getBtree, getKey, getKeys, getLastOffset, getNbElems, getOffset, getPage, getReference, getRevision, getValue, getValues, hasKey, selectSibling, setKey, setKeys, setLastOffset, setNbElems, setOffset, setPageHolder, setRevision, setValuePersistedNode(BTree<K,V> btree, long revision, int nbElems)
btree - the parent BTreerevision - the Node revisionnbElems - The number of elements in this NodePersistedNode(BTree<K,V> btree, long revision, K key, Page<K,V> leftPage, Page<K,V> rightPage)
btree - the parent BTreerevision - the Node revisionkey - The new keyleftPage - The left pagerightPage - The right pagePersistedNode(BTree<K,V> btree, long revision, K key, PageHolder<K,V> leftPage, PageHolder<K,V> rightPage)
btree - the parent BTreerevision - the Node revisionkey - The new keyleftPage - The left pagerightPage - The right pagepublic InsertResult<K,V> insert(K key, V value, long revision) throws java.io.IOException
java.io.IOExceptionprivate RemoveResult<K,V> handleRemoveResult(RemoveResult<K,V> removeResult, int index, int pos, boolean found) throws java.io.IOException
removeResult - The result of a remove operationindex - the position of the key, not transformedpos - The position of the key, as a positive valuefound - If the key has been found in the pagejava.io.IOException - If we have an error while trying to access the pageprivate RemoveResult<K,V> handleRootRemove(MergedWithSiblingResult<K,V> mergedResult, int pos, boolean found) throws java.io.IOException
mergedResult - The merge resultpos - The position in the current rootfound - Tells if the removed key is present in the root pagejava.io.IOException - If we have an error while trying to access the pageprivate DeleteResult<K,V> borrowFromRight(long revision, MergedWithSiblingResult<K,V> mergedResult, PersistedNode<K,V> sibling, int pos) throws java.io.IOException
revision - The new revision for all the pagessibling - The right siblingpos - The position of the element to removejava.io.IOException - If we have an error while trying to access the pageprivate DeleteResult<K,V> borrowFromLeft(long revision, MergedWithSiblingResult<K,V> mergedResult, PersistedNode<K,V> sibling, int pos) throws java.io.IOException
revision - The new revision for all the pagessibling - The left siblingpos - The position of the element to removejava.io.IOException - If we have an error while trying to access the pageprivate DeleteResult<K,V> mergeWithSibling(long revision, MergedWithSiblingResult<K,V> mergedResult, PersistedNode<K,V> sibling, boolean isLeft, int pos) throws java.io.IOException
revision - The revisionmergedResult - The result of the mergesibling - The Page we will merge the current page withisLeft - Tells if the sibling is on the leftpos - The position of the key that has been removedjava.io.IOException - If we have an error while trying to access the pageDeleteResult<K,V> delete(K key, V value, long revision, Page<K,V> parent, int parentPos) throws java.io.IOException
delete in class AbstractPage<K,V>key - The key to deletevalue - The value to deleterevision - The revision for which we want to delete a tupleparent - The parent pageparentPos - The position of this page in the parent pagejava.io.IOException - If we had an issue while processing the deletionprivate RemoveResult<K,V> handleBorrowedResult(BorrowedFromSiblingResult<K,V> borrowedResult, int pos) throws java.io.IOException
borrowedResult - The result of the deletion from the childrenpos - The position the key was found in the current nodejava.io.IOException - If we have an error while trying to access the pageprivate RemoveResult<K,V> removeKey(MergedWithSiblingResult<K,V> mergedResult, long revision, int pos) throws java.io.IOException
mergedResult - The page we will remove a key fromrevision - The revision of the modified pagepos - The position into the page of the element to removejava.io.IOException - If we have an error while trying to access the pagevoid setValue(int pos,
PersistedPageHolder<K,V> value)
pos - The position in the values arrayvalue - the value to injectprivate InsertResult<K,V> replaceChild(long revision, ModifyResult<K,V> result, int pos) throws java.io.IOException
revision - The current revisionresult - The modified pagepos - The position of the found keyjava.io.IOException - If we have an error while trying to access the pageprivate PageHolder<K,V> createHolder(Page<K,V> page) throws java.io.IOException
page - The page we will refer tojava.io.IOException - If we have an error while trying to access the pageprivate InsertResult<K,V> insertChild(java.util.List<Page<K,V>> copiedPages, long revision, K key, Page<K,V> leftPage, Page<K,V> rightPage, int pos) throws java.io.IOException
copiedPages - the list of copied pagesrevision - The revision of the modified pagekey - The key to insertleftPage - The left childrightPage - The right childpos - The position into the pagejava.io.IOException - If we have an error while trying to access the pageprivate InsertResult<K,V> addAndSplit(java.util.List<Page<K,V>> copiedPages, long revision, K pivot, Page<K,V> leftPage, Page<K,V> rightPage, int pos) throws java.io.IOException
copiedPages - the list of copied pagesrevision - The new revision for all the created pagespivot - The key that will be move up after the splitleftPage - The left childrightPage - The right childpos - The position of the insertion of the new elementjava.io.IOException - If we have an error while trying to access the pageprotected PersistedNode<K,V> copy(long revision)
revision - The new revisionpublic K getLeftMostKey()
getLeftMostKey in interface Page<K,V>getLeftMostKey in class AbstractPage<K,V>public K getRightMostKey()
getRightMostKey in interface Page<K,V>getRightMostKey in class AbstractPage<K,V>public boolean isLeaf()
public boolean isNode()
public java.lang.String toString()
toString in class AbstractPage<K,V>Object.toString()