Class BPlusNode<KeyType,KeyBufferType>

java.lang.Object
com.semedy.reasoner.edb.persistentstore.bplustree.BPlusNode<KeyType,KeyBufferType>
All Implemented Interfaces:
CacheUnit
Direct Known Subclasses:
BPlusInternalNode, BPlusLeaf

public abstract class BPlusNode<KeyType,KeyBufferType> extends Object implements CacheUnit
This class represents a node within a B+ tree, stored on disk.
Author:
angele
  • Constructor Details

  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getStatus

      public BPlusNode.BPlusStatus getStatus()
      get status of bplus node
      Returns:
    • setStatus

      public void setStatus(BPlusNode.BPlusStatus status)
      set status of bplus node
      Parameters:
      status -
    • getOffset

      public int getOffset()
      return the file offset of the node
      Returns:
    • isLeaf

      public abstract boolean isLeaf()
      A quick checker to see if the node is a leaf- if so, we have found the final result of the search.
      Returns:
      true if this is a leaf
    • setFather

      public void setFather(BPlusInternalNode<KeyType,KeyBufferType> daddy, int index)
      set the father node and the index in father node
    • getFather

      get the father node
      Returns:
    • getIndexInFather

      public int getIndexInFather()
      get the index in father node
      Returns:
    • detach

      public void detach()
      detach node from his father
    • getKeys

      public BPlusKeys<KeyType,KeyBufferType> getKeys()
      Returns the array of keys
      Returns:
      the keys
    • getNumKeys

      public int getNumKeys()
      Returns the number of keys in keys
      Returns:
      number of keys present
    • isFull

      public boolean isFull()
      Returns:
      true if the node is full
    • isEmpty

      public boolean isEmpty()
      Returns:
      true if the node is empty
    • underflow

      public boolean underflow()
      Returns:
      true if we have < ceiling(m/2) -1 keys
    • canBeBorrowedFrom

      public boolean canBeBorrowedFrom()
      Answers the question: Do we have keys to spare?
      Returns:
      true if we can, false otherwise.
    • borrowKey

      public KeyType borrowKey()
      Returns:
      the last key
    • borrowFirstKey

      public KeyType borrowFirstKey()
      Returns:
      the first key
    • clear

      public void clear()
      set the left sibling offset
    • doneBorrowing

      public abstract void doneBorrowing()
      performs several cleaning up actions after borrowing from the right.
    • doneBorrowingFirst

      public abstract void doneBorrowingFirst()
      performs several cleanign up actions after borrowing from the left.
    • checkSanity

      public abstract boolean checkSanity(String message, KeyType minKey, KeyType maxKey, DataFile df)
      checks whether all keys are sorted correctly
      Returns:
    • touch

      public void touch() throws IOException
      touch a cache unit.
      this means for cache management that this unit
      will be used and has a lower prio to be released
      Specified by:
      touch in interface CacheUnit
      Throws:
      IOException
    • setNext

      public void setNext(CacheUnit next)
      pointers in a list for cache management
      Specified by:
      setNext in interface CacheUnit
      Parameters:
      next -
    • getNext

      public CacheUnit getNext()
      Specified by:
      getNext in interface CacheUnit
    • setLast

      public void setLast(CacheUnit last)
      Specified by:
      setLast in interface CacheUnit
    • getLast

      public CacheUnit getLast()
      Specified by:
      getLast in interface CacheUnit
    • release

      public void release() throws IOException
      Cache management calls this method to release the cache unit.
      Specified by:
      release in interface CacheUnit
      Throws:
      IOException
    • isReleasable

      public boolean isReleasable()
      is this unit releasable
      Specified by:
      isReleasable in interface CacheUnit
      Returns:
    • sizeInBytes

      public long sizeInBytes()
      Description copied from interface: CacheUnit
      releases this number of bytes
      Specified by:
      sizeInBytes in interface CacheUnit
      Returns: