java.lang.Object
org.aspectj.org.eclipse.jdt.internal.core.nd.db.BTree

public class BTree extends Object
Implements B-Tree search structure.
  • Field Details

    • RECORD_SIZE

      public static final int RECORD_SIZE
      See Also:
      Constant Field Values
    • db

      protected final Database 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

      protected final IBTreeComparator cmp
  • Constructor Details

    • BTree

      public BTree(Nd nd, long rootPointer, IBTreeComparator cmp)
    • BTree

      public BTree(Nd nd, long rootPointer, int degree, IBTreeComparator cmp)
      Constructor.
      Parameters:
      nd - the database containing the btree
      rootPointer - offset into database of the pointer to the root node
  • Method Details

    • getFactory

      public static ITypeFactory<BTree> getFactory(IBTreeComparator cmp)
    • getFactory

      public static ITypeFactory<BTree> getFactory(int degree, IBTreeComparator cmp)
    • getRoot

      protected long getRoot() throws IndexException
      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

      public long insert(long record) throws IndexException
      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

      public void delete(long record) throws IndexException
      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 IndexException
      Merge 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 dst
      keyProvider - the node that provides the median key for the new node
      kIndex - the index of the key in the node mid which is to become the new node's median key
      dst - the node which is the basis and result of the merge
      Throws:
      IndexException
    • accept

      public boolean accept(IBTreeVisitor visitor) throws IndexException
      Visit all nodes beginning when the visitor comparator returns >= 0 until the visitor visit returns falls.
      Parameters:
      visitor -
      Throws:
      IndexException
    • getInvariantsErrorReport

      public String getInvariantsErrorReport() throws IndexException
      Debugging method for checking B-tree invariants
      Returns:
      the empty String if B-tree invariants hold, otherwise a human readable report
      Throws:
      IndexException