Class BTree
java.lang.Object
org.aspectj.org.eclipse.jdt.internal.core.nd.db.BTree
Implements B-Tree search structure.
-
Field Summary
Modifier and TypeFieldDescriptionprotected IBTreeComparator
protected Database
protected int
protected int
protected int
protected int
protected int
protected int
static int
protected long
-
Constructor Summary
ConstructorDescriptionBTree(Nd nd, long rootPointer, int degree, IBTreeComparator cmp)
Constructor.BTree(Nd nd, long rootPointer, IBTreeComparator cmp)
-
Method Summary
Modifier and TypeMethodDescriptionboolean
accept(IBTreeVisitor visitor)
Visit all nodes beginning when the visitor comparator returns >= 0 until the visitor visit returns falls.void
delete(long record)
Deletes the specified record from the B-tree.void
destruct()
protected long
getChild(org.aspectj.org.eclipse.jdt.internal.core.nd.db.Chunk chunk, long node, int index)
static ITypeFactory<BTree>
getFactory(int degree, IBTreeComparator cmp)
static ITypeFactory<BTree>
getFactory(IBTreeComparator cmp)
Debugging method for checking B-tree invariantsprotected long
getRecord(org.aspectj.org.eclipse.jdt.internal.core.nd.db.Chunk chunk, long node, int index)
protected long
getRoot()
long
insert(long record)
Inserts the record into the b-tree.void
mergeNodes(org.aspectj.org.eclipse.jdt.internal.core.nd.db.BTree.BTNode src, org.aspectj.org.eclipse.jdt.internal.core.nd.db.BTree.BTNode keyProvider, int kIndex, org.aspectj.org.eclipse.jdt.internal.core.nd.db.BTree.BTNode dst)
Merge node 'src' onto the right side of node 'dst' using node 'keyProvider' as the source of the median key.protected void
putChild(org.aspectj.org.eclipse.jdt.internal.core.nd.db.Chunk chunk, long node, int index, long child)
protected void
putRecord(org.aspectj.org.eclipse.jdt.internal.core.nd.db.Chunk chunk, long node, int index, long record)
-
Field Details
-
RECORD_SIZE
public static final int RECORD_SIZE- See Also:
- Constant Field Values
-
db
-
rootPointer
protected final long rootPointer -
degree
protected final int degree -
maxRecords
protected final int maxRecords -
maxChildren
protected final int maxChildren -
minRecords
protected final int minRecords -
offsetChildren
protected final int offsetChildren -
medianRecord
protected final int medianRecord -
cmp
-
-
Constructor Details
-
BTree
-
BTree
Constructor.- Parameters:
nd
- the database containing the btreerootPointer
- offset into database of the pointer to the root node
-
-
Method Details
-
getFactory
-
getFactory
-
getRoot
- Throws:
IndexException
-
putRecord
protected final void putRecord(org.aspectj.org.eclipse.jdt.internal.core.nd.db.Chunk chunk, long node, int index, long record) -
getRecord
protected final long getRecord(org.aspectj.org.eclipse.jdt.internal.core.nd.db.Chunk chunk, long node, int index) -
putChild
protected final void putChild(org.aspectj.org.eclipse.jdt.internal.core.nd.db.Chunk chunk, long node, int index, long child) -
getChild
protected final long getChild(org.aspectj.org.eclipse.jdt.internal.core.nd.db.Chunk chunk, long node, int index) -
destruct
public void destruct() -
insert
Inserts the record into the b-tree. We don't insert if the key was already there, in which case we return the record that matched. In other cases, we just return the record back.- Parameters:
record
- offset of the record- Throws:
IndexException
-
delete
Deletes the specified record from the B-tree.If the specified record is not present then this routine has no effect.
Specifying a record r for which there is another record q existing in the B-tree where cmp.compare(r,q)==0 && r!=q will also have no effect
N.B. The record is not deleted itself - its storage is not deallocated. The reference to the record in the btree is deleted.
- Parameters:
record
- the record to delete- Throws:
IndexException
-
mergeNodes
public void mergeNodes(org.aspectj.org.eclipse.jdt.internal.core.nd.db.BTree.BTNode src, org.aspectj.org.eclipse.jdt.internal.core.nd.db.BTree.BTNode keyProvider, int kIndex, org.aspectj.org.eclipse.jdt.internal.core.nd.db.BTree.BTNode dst) throws IndexExceptionMerge node 'src' onto the right side of node 'dst' using node 'keyProvider' as the source of the median key. Bounds checking is not performed.- Parameters:
src
- the key to merge into dstkeyProvider
- the node that provides the median key for the new nodekIndex
- the index of the key in the node mid which is to become the new node's median keydst
- the node which is the basis and result of the merge- Throws:
IndexException
-
accept
Visit all nodes beginning when the visitor comparator returns >= 0 until the visitor visit returns falls.- Parameters:
visitor
-- Throws:
IndexException
-
getInvariantsErrorReport
Debugging method for checking B-tree invariants- Returns:
- the empty String if B-tree invariants hold, otherwise a human readable report
- Throws:
IndexException
-