Class BTreeIndex<Key,Value>
java.lang.Object
org.apache.activemq.store.kahadb.disk.index.BTreeIndex<Key,Value>
- All Implemented Interfaces:
Index<Key,Value>
BTreeIndex represents a Variable Magnitude B+Tree in a Page File.
A BTree is a bit flexible in that it can be used for set or
map-based indexing. Leaf nodes are linked together for faster
iteration of the values.
The Variable Magnitude attribute means that the BTree attempts to store as many values and pointers on one page as is possible.
The implementation can optionally a be Simple-Prefix B+Tree.
For those who don't know how a Simple-Prefix B+Tree works, the primary distinction is that instead of promoting actual keys to branch pages, when leaves are split, a shortest-possible separator is generated at the pivot. That separator is what is promoted to the parent branch (and continuing up the list). As a result, actual keys and pointers can only be found at the leaf level. This also affords the index the ability to ignore costly merging and redistribution of pages when deletions occur. Deletions only affect leaf pages in this implementation, and so it is entirely possible for a leaf page to be completely empty after all of its keys have been removed. , $Date$
The Variable Magnitude attribute means that the BTree attempts to store as many values and pointers on one page as is possible.
The implementation can optionally a be Simple-Prefix B+Tree.
For those who don't know how a Simple-Prefix B+Tree works, the primary distinction is that instead of promoting actual keys to branch pages, when leaves are split, a shortest-possible separator is generated at the pivot. That separator is what is promoted to the parent branch (and continuing up the list). As a result, actual keys and pointers can only be found at the leaf level. This also affords the index the ability to ignore costly merging and redistribution of pages when deletions occur. Deletions only affect leaf pages in this implementation, and so it is entirely possible for a leaf page to be completely empty after all of its keys have been removed. , $Date$
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInterface used to determine the simple prefix of two keys. , $Date$static classStringPrefixer is a Prefixer implementation that works on strings. -
Constructor Summary
ConstructorsConstructorDescriptionBTreeIndex(long rootPageId) BTreeIndex(Page page) BTreeIndex(PageFile pageFile, long rootPageId) BTreeIndex(PageFile pageFile, Page page) -
Method Summary
Modifier and TypeMethodDescriptionvoidclear(Transaction tx) clear the indexbooleancontainsKey(Transaction tx, Key key) get(Transaction tx, Key key) getFirst(Transaction tx) getLast(Transaction tx) intintlongbooleanisEmpty(Transaction tx) booleaniterator(Transaction tx) iterator(Transaction tx, Key initialKey) iterator(Transaction tx, Key initialKey, Key maxKey) voidload(Transaction tx) load indexesvoidprintStructure(Transaction tx, OutputStream out) voidprintStructure(Transaction tx, PrintWriter out) put(Transaction tx, Key key, Value value) store the key, itemremove(Transaction tx, Key key) remove the index keyvoidsetKeyMarshaller(Marshaller<Key> keyMarshaller) Set the marshaller for key objectsvoidsetPageFile(PageFile pageFile) voidsetPageId(long pageId) voidsetPrefixer(BTreeIndex.Prefixer<Key> prefixer) voidsetValueMarshaller(Marshaller<Value> valueMarshaller) Set the marshaller for key objectsvoidunload(Transaction tx) unload indexesvoidvisit(Transaction tx, BTreeVisitor<Key, Value> visitor)
-
Constructor Details
-
BTreeIndex
public BTreeIndex() -
BTreeIndex
public BTreeIndex(long rootPageId) -
BTreeIndex
-
BTreeIndex
-
BTreeIndex
-
-
Method Details
-
load
Description copied from interface:Indexload indexes- Specified by:
loadin interfaceIndex<Key,Value> - Throws:
IOException
-
unload
Description copied from interface:Indexunload indexes -
containsKey
- Specified by:
containsKeyin interfaceIndex<Key,Value> - Returns:
- true if it contains the key
- Throws:
IOException
-
get
- Specified by:
getin interfaceIndex<Key,Value> - Returns:
- the entry
- Throws:
IOException
-
put
Description copied from interface:Indexstore the key, item- Specified by:
putin interfaceIndex<Key,Value> - Throws:
IOException
-
remove
Description copied from interface:Indexremove the index key- Specified by:
removein interfaceIndex<Key,Value> - Returns:
- StoreEntry removed
- Throws:
IOException
-
isTransient
public boolean isTransient()- Specified by:
isTransientin interfaceIndex<Key,Value> - Returns:
- true if the index is transient
-
clear
Description copied from interface:Indexclear the index- Specified by:
clearin interfaceIndex<Key,Value> - Throws:
IOException
-
getMinLeafDepth
- Throws:
IOException
-
getMaxLeafDepth
- Throws:
IOException
-
printStructure
- Throws:
IOException
-
printStructure
- Throws:
IOException
-
isEmpty
- Throws:
IOException
-
iterator
- Specified by:
iteratorin interfaceIndex<Key,Value> - Returns:
- Throws:
IOException
-
iterator
- Throws:
IOException
-
iterator
public Iterator<Map.Entry<Key,Value>> iterator(Transaction tx, Key initialKey, Key maxKey) throws IOException - Throws:
IOException
-
visit
- Throws:
IOException
-
getFirst
- Throws:
IOException
-
getLast
- Throws:
IOException
-
getPageFile
-
getPageId
public long getPageId() -
getKeyMarshaller
-
setKeyMarshaller
Description copied from interface:IndexSet the marshaller for key objects- Specified by:
setKeyMarshallerin interfaceIndex<Key,Value>
-
getValueMarshaller
-
setValueMarshaller
Description copied from interface:IndexSet the marshaller for key objects- Specified by:
setValueMarshallerin interfaceIndex<Key,Value>
-
getPrefixer
-
setPrefixer
-
setPageFile
-
setPageId
public void setPageId(long pageId)
-