public class BTree
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected IBTreeComparator |
cmp |
protected Database |
db |
protected int |
degree |
protected int |
maxChildren |
protected int |
maxRecords |
protected int |
medianRecord |
protected int |
minRecords |
protected int |
offsetChildren |
static int |
RECORD_SIZE |
protected long |
rootPointer |
| Constructor and Description |
|---|
BTree(Nd nd,
long rootPointer,
IBTreeComparator cmp) |
BTree(Nd nd,
long rootPointer,
int degree,
IBTreeComparator cmp)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
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(IBTreeComparator cmp) |
static ITypeFactory<BTree> |
getFactory(int degree,
IBTreeComparator cmp) |
java.lang.String |
getInvariantsErrorReport()
Debugging method for checking B-tree invariants
|
protected 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) |
public static final int RECORD_SIZE
protected final Database db
protected final long rootPointer
protected final int degree
protected final int maxRecords
protected final int maxChildren
protected final int minRecords
protected final int offsetChildren
protected final int medianRecord
protected final IBTreeComparator cmp
public BTree(Nd nd, long rootPointer, IBTreeComparator cmp)
public BTree(Nd nd, long rootPointer, int degree, IBTreeComparator cmp)
nd - the database containing the btreerootPointer - offset into database of the pointer to the root nodepublic static ITypeFactory<BTree> getFactory(IBTreeComparator cmp)
public static ITypeFactory<BTree> getFactory(int degree, IBTreeComparator cmp)
protected long getRoot()
throws IndexException
IndexExceptionprotected final void putRecord(org.aspectj.org.eclipse.jdt.internal.core.nd.db.Chunk chunk,
long node,
int index,
long record)
protected final long getRecord(org.aspectj.org.eclipse.jdt.internal.core.nd.db.Chunk chunk,
long node,
int index)
protected final void putChild(org.aspectj.org.eclipse.jdt.internal.core.nd.db.Chunk chunk,
long node,
int index,
long child)
protected final long getChild(org.aspectj.org.eclipse.jdt.internal.core.nd.db.Chunk chunk,
long node,
int index)
public void destruct()
public long insert(long record)
throws IndexException
record - offset of the recordIndexExceptionpublic void delete(long record)
throws IndexException
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.
record - the record to deleteIndexExceptionpublic 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 IndexException
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 mergeIndexExceptionpublic boolean accept(IBTreeVisitor visitor) throws IndexException
visitor - IndexExceptionpublic java.lang.String getInvariantsErrorReport()
throws IndexException
IndexException