java.lang.Object
org.apache.jena.tdb1.index.bplustree.BPlusTree
- All Implemented Interfaces:
Iterable<Record>,org.apache.jena.atlas.lib.Closeable,org.apache.jena.atlas.lib.Sync,Index,RangeIndex
B-Tree converted to B+Tree
B-Tree taken from:
Introduction to Algorithms, Second Edition
Chapter 18: B-Trees
by Thomas H. Cormen, Charles E. Leiserson,
Ronald L. Rivest and Clifford Stein
Includes implementation of removal.
Notes:
Stores "records", which are a key and value (the value may be null).
In this B+Tree implementation, the (key,value) pairs are held in
RecordBuffer, which wrap a ByteBuffer that only has records in it.
BPTreeRecords provides the B+Tree view of a RecordBuffer. All records
are in RecordBuffer - the "tree" part is an index for finding the right
page. The tree only holds keys, copies from the (key, value) pairs in
the RecordBuffers.
Notes:
The version above splits nodes on the way down when full,
not when needed where a split can bubble up from below.
It means it only ever walks down the tree on insert.
Similarly, the delete code ensures a node is suitable
before descending.
Variations:
In this impl, splitRoot leaves the root node in place.
The root is always the same block.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanAdd a record - return true if an insertion was actually neededaddAndReturnOld(Record record) Add a record into the B+Treestatic BPlusTreeaddTracking(BPlusTree bpTree) Debuggingstatic BPlusTreeattach(BPlusTreeParams params, BlockMgr blkMgrNodes, BlockMgr blkMgrRecords) Create the in-memory structures to correspond to the supplied block managers for the persistent storage.voidcheck()Perform checks on this indexvoidclear()Clear the indexvoidclose()Close the index - can not be used again through this objectbooleanReturn whether the index contains the record or not.static BPlusTreecreate(BPlusTreeParams params, BlockMgr blkMgrNodes, BlockMgr blkMgrLeaves) Create the in-memory structures to correspond to the supplied block managers for the persistent storage.booleanDelete a record.deleteAndReturnOld(Record record) voiddump()voiddump(org.apache.jena.atlas.io.IndentedWriter out) Find one record - and return the record actually in the index (may have a value part)Only use for careful manipulation of structuresGet the parameters describing this B+TreeGet the Record factory associated with this indexOnly use for careful manipulation of structuresbooleanisEmpty()Answer whether the index is empty or not.iterator()Iterate over the whole indexReturn records between min (inclusive) and max (exclusive), based on the record keysstatic BPlusTreemakeMem(int order, int minRecords, int keyLength, int valueLength) (Testing mainly) Make an in-memory B+Tree, with copy-in, copy-out block managersstatic BPlusTree(Testing mainly) Make an in-memory B+Tree, with copy-in, copy-out block managersmaxKey()Return the record containing the greatest key - may or may not have the associated valueminKey()Return the record containing the least key - may or may not have the associated valuelongsize()Return size if known else return -1 : does not count the persistent storagevoidsync()Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
create
Create the in-memory structures to correspond to the supplied block managers for the persistent storage. Initialize the persistent storage to the empty B+Tree if it does not exist. This is the normal way to create a B+Tree. -
attach
public static BPlusTree attach(BPlusTreeParams params, BlockMgr blkMgrNodes, BlockMgr blkMgrRecords) Create the in-memory structures to correspond to the supplied block managers for the persistent storage. Does not initialize the B+Tree - it assumes the block managers correspond to an existing B+Tree. -
makeMem
(Testing mainly) Make an in-memory B+Tree, with copy-in, copy-out block managers -
makeMem
public static BPlusTree makeMem(String name, int order, int minRecords, int keyLength, int valueLength) (Testing mainly) Make an in-memory B+Tree, with copy-in, copy-out block managers -
addTracking
Debugging -
getParams
Get the parameters describing this B+Tree -
getNodeManager
Only use for careful manipulation of structures -
getRecordsMgr
Only use for careful manipulation of structures -
getRecordFactory
Description copied from interface:IndexGet the Record factory associated with this index- Specified by:
getRecordFactoryin interfaceIndex
-
find
Description copied from interface:IndexFind one record - and return the record actually in the index (may have a value part) -
contains
Description copied from interface:IndexReturn whether the index contains the record or not. -
minKey
Description copied from interface:RangeIndexReturn the record containing the least key - may or may not have the associated value- Specified by:
minKeyin interfaceRangeIndex
-
maxKey
Description copied from interface:RangeIndexReturn the record containing the greatest key - may or may not have the associated value- Specified by:
maxKeyin interfaceRangeIndex
-
add
Description copied from interface:IndexAdd a record - return true if an insertion was actually needed -
addAndReturnOld
Add a record into the B+Tree -
delete
Description copied from interface:IndexDelete a record. Return true if a record was actually removed -
deleteAndReturnOld
-
iterator
Description copied from interface:IndexIterate over the whole index -
iterator
Description copied from interface:RangeIndexReturn records between min (inclusive) and max (exclusive), based on the record keys- Specified by:
iteratorin interfaceRangeIndex
-
isEmpty
public boolean isEmpty()Description copied from interface:IndexAnswer whether the index is empty or not. May return false for unknown or meaningless -
clear
public void clear()Description copied from interface:IndexClear the index -
sync
public void sync()- Specified by:
syncin interfaceorg.apache.jena.atlas.lib.Sync
-
close
public void close()Description copied from interface:IndexClose the index - can not be used again through this object -
size
public long size()Description copied from interface:IndexReturn size if known else return -1 : does not count the persistent storage -
check
public void check()Description copied from interface:IndexPerform checks on this index -
dump
public void dump() -
dump
public void dump(org.apache.jena.atlas.io.IndentedWriter out)
-