|
MXQuery 0.6.0 API Documentation - Copyright 2006-2009 ETH Zurich | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectch.ethz.mxquery.sms.btree.BTree
public class BTree
A simple btree implementation. (key equal or less than pivot -> go right) Has to be taylored to different key and value types manually as Generics would use Complex type (inefficent) instead of native types. We have pointers among leaves and also only store key/value mappings on the leaves. Therefore, this is a B+-tree implementation. The implementation allows us to store duplicate keys in the leaf level of the tree. However, a strict tree interval invariant is kept. To handle duplicate keys, this means that overflows due to duplication are handled by adding special overflow leaves that are not pointed to by any parent node. These leaves are created via splitting, however no pivot is promoted on such a split. The delete strategy implemented in this tree is to free at empty. Thus, there is no logic to merge at nodes at half occupation and nodes may become underutilized. This may be monitored by calculating the utilization at the leaf level.
Field Summary | |
---|---|
static int |
INVALID_KEY_INDEX
invalid value for atPos index returned from getFirstKeyAfter |
Constructor Summary | |
---|---|
BTree(int k,
int k_star)
Instantiates a new BTree. |
Method Summary | |
---|---|
void |
add(DeweyIdentifier key,
LinguisticToken value,
LeafCarrier leafCarrier)
Adds a mapping from key to value in the b-tree. |
BTreeNode |
bulkLoad(PhraseIterator input,
int F)
Bulkloads an empty BTree fill leaves from left to right until certain percentage. |
void |
close()
Close this b-tree. |
LinguisticToken |
get(DeweyIdentifier key,
BTreeNode currentRoot)
Gets the value currently mapped to the given key. |
DeweyIdentifier |
getFirstKey()
This method returns the first(smallest) currently in the tree. |
void |
getFirstKeyAfter(DeweyIdentifier key,
Leaf[] inLeaf,
int[] atPos)
This method takes two arrays as out parameters and inserts in them pointers to the leaf and position of the smallest key currently in tree which is either equal to key (if key is
present in btree) or smallest key larger than key (if
key is not present in btree): |
Leaf |
getFirstLeaf()
gets the first leaf of the btree |
DeweyIdentifier |
getKey(Leaf l,
int pos)
Gets the key value in the given leaf at the given position |
DeweyIdentifier |
getLastKey()
This method returns the last(largest) key present in the tree |
void |
getLastKeyBefore(DeweyIdentifier key,
Leaf[] inLeaf,
int[] atPos)
This method takes two arrays as out parameters and inserts in them pointers to the leaf and position of the largest key currently in tree which is either equal to key (if key is
present in btree) or largest key smaller than key (if
key is not present in btree): |
void |
getLastKeyBeforeLeafTraversal(DeweyIdentifier toKey,
Leaf startLeaf,
int startPos,
Leaf[] inLeaf,
int[] atPos)
This method takes two arrays as out parameters and inserts in them pointers to the leaf and position of the largest key currently in tree which is either equal to key (if key is
present in btree) or largest key smaller than key (if
key is not present in btree). |
Leaf |
getLastLeaf()
|
LinguisticToken |
getNext(DeweyIdentifier key,
BTreeNode currentRoot)
|
BTreeNode |
getRoot()
Gets the root of the btree |
java.util.Vector |
getSiblings(DeweyIdentifier from,
DeweyIdentifier parent,
BTreeNode currentRoot,
DeweyIdentifier[] ignoreId)
|
void |
printStats()
prints statistical infos about the tree |
void |
queryRange(DeweyIdentifier lowKey,
DeweyIdentifier highKey,
BtreePushOperator results)
Returns all the values mapped in the given key range through the provided push operator. |
void |
remove(DeweyIdentifier key)
Removes all mappings corresponding to the given key from the b-tree. |
void |
remove(DeweyIdentifier key,
LinguisticToken value)
Removes one instance of the given key-value mapping from the b-tree. |
int |
size()
|
java.lang.String |
toString()
Prints the root of the tree as a string. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int INVALID_KEY_INDEX
Constructor Detail |
---|
public BTree(int k, int k_star)
TODO remove this constructor.
k
- k_star
- Method Detail |
---|
public BTreeNode bulkLoad(PhraseIterator input, int F) throws MXQueryException
input
- as Pulloperator of F
- denoting the leaf usage
MXQueryException
public void add(DeweyIdentifier key, LinguisticToken value, LeafCarrier leafCarrier)
key
- value
- leafCarrier
- public LinguisticToken get(DeweyIdentifier key, BTreeNode currentRoot)
key
- currentRoot
- public LinguisticToken getNext(DeweyIdentifier key, BTreeNode currentRoot)
public java.util.Vector getSiblings(DeweyIdentifier from, DeweyIdentifier parent, BTreeNode currentRoot, DeweyIdentifier[] ignoreId)
public DeweyIdentifier getKey(Leaf l, int pos)
l
- leaf in which key is looked uppos
- position inside leaf where key is at
public void getFirstKeyAfter(DeweyIdentifier key, Leaf[] inLeaf, int[] atPos)
key
(if key
is
present in btree) or smallest key larger than key
(if
key
is not present in btree):
key
- inLeaf
- points to the leaf where to get the keyatPos
- points to the position of the key inside the leafpublic void getLastKeyBefore(DeweyIdentifier key, Leaf[] inLeaf, int[] atPos)
key
(if key
is
present in btree) or largest key smaller than key
(if
key
is not present in btree):
key
- the search keyinLeaf
- points to the leaf where to get the keyatPos
- points to the position of the key inside the leafpublic void getLastKeyBeforeLeafTraversal(DeweyIdentifier toKey, Leaf startLeaf, int startPos, Leaf[] inLeaf, int[] atPos)
key
(if key
is
present in btree) or largest key smaller than key
(if
key
is not present in btree). This method implements the
same functionality as getLastKeyBefore but uses leaf traversal to find
the position of the key.
toKey
- the search keystartLeaf
- startPos
- inLeaf
- points to the leaf where to get the keyatPos
- points to the position of the key inside the leafpublic void remove(DeweyIdentifier key)
key
- public void remove(DeweyIdentifier key, LinguisticToken value)
key
- value
- public void queryRange(DeweyIdentifier lowKey, DeweyIdentifier highKey, BtreePushOperator results)
lowKey
- highKey
- results
- PushOperator to be filled.public java.lang.String toString()
toString
in class java.lang.Object
public void close()
public void printStats()
public int size()
public BTreeNode getRoot()
public Leaf getFirstLeaf()
public Leaf getLastLeaf()
public DeweyIdentifier getLastKey()
public DeweyIdentifier getFirstKey()
|
MXQuery 0.6.0 API Documentation - Copyright 2006-2009 ETH Zurich | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |