Class BPlusKeysVariableBytes

java.lang.Object
com.semedy.reasoner.edb.persistentstore.bplustree.BPlusKeysVariableBytes
All Implemented Interfaces:
BPlusKeys<byte[],ByteBuffer>

public class BPlusKeysVariableBytes extends Object implements BPlusKeys<byte[],ByteBuffer>
variable number, variable sized byte arrays as keys of a bplus node
Author:
angele
  • Constructor Summary

    Constructors
    Constructor
    Description
    BPlusKeysVariableBytes(int[] keys, short[] lengths, byte[] bytes, int fillsize, int numKeys, int keyLength)
     
    BPlusKeysVariableBytes(int initialNumberOfKeys, int initialLength)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    append(byte[] key)
    append key at end
    int
    how many keys can be contained?
    boolean
    checkSanity(String message, byte[] minKey, byte[] maxKey)
    check the correct sorting sequence of keys
    void
    remove all keys
    int
    compare(byte[] key1, byte[] key2)
    compare two keys
    int
    compare(byte[] key, int index)
    compare key with key at index index
    int
    compare(int index1, int index2)
     
    int
    compareBuffer(ByteBuffer key, int index)
     
    int
    compareNew(byte[] key1, byte[] key2)
     
    int
    compareNew(byte[] key, int index)
     
    int
    compareNew(int index1, int index2)
     
    int
    compareS(int index1, int index2)
     
    void
    copy(BPlusKeys<byte[],ByteBuffer> b, int numKey)
    copy numKeys keys into key container b, starting at left most key
    void
    ensureCapacity(int n, int length)
    ensures the capacity for n keys (variable number of keys)
    byte[]
    get(int i)
    return key with index i
    void
    getBuffer(int i, ByteBuffer result, BPlusNode<byte[],ByteBuffer> node)
     
    int
    getKeyData(byte[] fileData, int start, int numKey, int[] key, short[] length)
     
    int
    insert(byte[] key)
    inserts key
    void
    insertAtIndex(byte[] key, int indexToInsert)
    inserts key at indexToInsert
    int
    returns the size of a key in bytes if it is fix
    otherwise -1 is returned in addition if key is added
    int
    keySizeInBytes(byte[] key)
    returns the number of bytes needed in addition if key is added
    int
    return the current number of keys
    int
    readFileData(byte[] fileData, int start, int numKey)
    read numkey keys from array of bytes starting at start returns start+number of read bytes
    void
    remove(int indexToSkip)
    remove key at indexToSkip from set of keys
    void
    replace(byte[] key, byte[] replacement, int numKey)
    replaces key by replacement
    void
    replace(byte[] replacement, int numKey)
    replaces key by replacement at index
    void
    replaceByBuffer(ByteBuffer replacement, int index)
    replaces key by replacement at index
    int
    search(byte[] key, boolean indicateNotContained, boolean indicateContained)
    search for key if indicateNodContained==true results -1 if key has not been found otherwise results the index where the key has to be added
    int
    search(byte[] key, int begin, boolean indicateNotContained)
    search for key beginning from a start index if indicateNodContained==true results -1 if key has not been found otherwise results the index where the key has to be added
    int
    searchBuffer(ByteBuffer key, boolean indicateNotContained, boolean indicateContained)
     
    int
    searchBuffer(ByteBuffer key, int[] index, int begin, boolean indicateNotContained, boolean next)
     
    int
    searchBuffer(ByteBuffer key, int begin, boolean indicateNotContained)
     
    int
    searchKey(byte[] key, int[] index, int begin, boolean indicateNotContained, boolean next)
     
    void
    set(int i, byte[] key)
    set key with index i
    int
    returns the size in bytes for writing the keys to a file
    int
    where to split
    splitLeft(int number, int n)
    returns left number keys n is the resulting capacity for keys
    splitRight(int index, int n)
    returns right keys starting at index n is the resulting capacity for keys
     
    int
    writeFileData(byte[] fileData, int start)
    write key data to byte array starting at start Returns start + number of written bytes

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • BPlusKeysVariableBytes

      public BPlusKeysVariableBytes(int initialNumberOfKeys, int initialLength)
    • BPlusKeysVariableBytes

      public BPlusKeysVariableBytes(int[] keys, short[] lengths, byte[] bytes, int fillsize, int numKeys, int keyLength)
  • Method Details

    • checkSanity

      public boolean checkSanity(String message, byte[] minKey, byte[] maxKey)
      Description copied from interface: BPlusKeys
      check the correct sorting sequence of keys
      Specified by:
      checkSanity in interface BPlusKeys<byte[],ByteBuffer>
      Returns:
    • clear

      public void clear()
      Description copied from interface: BPlusKeys
      remove all keys
      Specified by:
      clear in interface BPlusKeys<byte[],ByteBuffer>
    • capacity

      public int capacity()
      Description copied from interface: BPlusKeys
      how many keys can be contained?
      Specified by:
      capacity in interface BPlusKeys<byte[],ByteBuffer>
      Returns:
    • numKeys

      public int numKeys()
      Description copied from interface: BPlusKeys
      return the current number of keys
      Specified by:
      numKeys in interface BPlusKeys<byte[],ByteBuffer>
      Returns:
    • get

      public byte[] get(int i)
      Description copied from interface: BPlusKeys
      return key with index i
      Specified by:
      get in interface BPlusKeys<byte[],ByteBuffer>
      Returns:
    • getBuffer

      public void getBuffer(int i, ByteBuffer result, BPlusNode<byte[],ByteBuffer> node)
      Specified by:
      getBuffer in interface BPlusKeys<byte[],ByteBuffer>
    • set

      public void set(int i, byte[] key)
      Description copied from interface: BPlusKeys
      set key with index i
      Specified by:
      set in interface BPlusKeys<byte[],ByteBuffer>
    • compare

      public int compare(byte[] key, int index)
      Description copied from interface: BPlusKeys
      compare key with key at index index
      Specified by:
      compare in interface BPlusKeys<byte[],ByteBuffer>
      Returns:
    • compareNew

      public int compareNew(byte[] key, int index)
    • compareS

      public int compareS(int index1, int index2)
    • compare

      public int compare(int index1, int index2)
    • compareNew

      public int compareNew(int index1, int index2)
    • compareBuffer

      public int compareBuffer(ByteBuffer key, int index)
      Specified by:
      compareBuffer in interface BPlusKeys<byte[],ByteBuffer>
    • compareNew

      public int compareNew(byte[] key1, byte[] key2)
    • compare

      public int compare(byte[] key1, byte[] key2)
      Description copied from interface: BPlusKeys
      compare two keys
      Specified by:
      compare in interface BPlusKeys<byte[],ByteBuffer>
      Returns:
    • search

      public int search(byte[] key, boolean indicateNotContained, boolean indicateContained)
      Description copied from interface: BPlusKeys
      search for key if indicateNodContained==true results -1 if key has not been found otherwise results the index where the key has to be added
      Specified by:
      search in interface BPlusKeys<byte[],ByteBuffer>
      indicateNotContained - , if key is not contained returns -1
      indicateContained - , if key is contained returns -1
      Returns:
    • searchBuffer

      public int searchBuffer(ByteBuffer key, boolean indicateNotContained, boolean indicateContained)
      Specified by:
      searchBuffer in interface BPlusKeys<byte[],ByteBuffer>
    • searchBuffer

      public int searchBuffer(ByteBuffer key, int[] index, int begin, boolean indicateNotContained, boolean next)
    • searchKey

      public int searchKey(byte[] key, int[] index, int begin, boolean indicateNotContained, boolean next)
    • search

      public int search(byte[] key, int begin, boolean indicateNotContained)
      Description copied from interface: BPlusKeys
      search for key beginning from a start index if indicateNodContained==true results -1 if key has not been found otherwise results the index where the key has to be added
      Specified by:
      search in interface BPlusKeys<byte[],ByteBuffer>
      Returns:
    • searchBuffer

      public int searchBuffer(ByteBuffer key, int begin, boolean indicateNotContained)
      Specified by:
      searchBuffer in interface BPlusKeys<byte[],ByteBuffer>
    • remove

      public void remove(int indexToSkip)
      Description copied from interface: BPlusKeys
      remove key at indexToSkip from set of keys
      Specified by:
      remove in interface BPlusKeys<byte[],ByteBuffer>
    • insert

      public int insert(byte[] key)
      Description copied from interface: BPlusKeys
      inserts key
      Specified by:
      insert in interface BPlusKeys<byte[],ByteBuffer>
      Returns:
    • replace

      public void replace(byte[] key, byte[] replacement, int numKey)
      Description copied from interface: BPlusKeys
      replaces key by replacement
      Specified by:
      replace in interface BPlusKeys<byte[],ByteBuffer>
    • replace

      public void replace(byte[] replacement, int numKey)
      Description copied from interface: BPlusKeys
      replaces key by replacement at index
      Specified by:
      replace in interface BPlusKeys<byte[],ByteBuffer>
    • replaceByBuffer

      public void replaceByBuffer(ByteBuffer replacement, int index)
      Description copied from interface: BPlusKeys
      replaces key by replacement at index
      Specified by:
      replaceByBuffer in interface BPlusKeys<byte[],ByteBuffer>
    • insertAtIndex

      public void insertAtIndex(byte[] key, int indexToInsert)
      Description copied from interface: BPlusKeys
      inserts key at indexToInsert
      Specified by:
      insertAtIndex in interface BPlusKeys<byte[],ByteBuffer>
    • append

      public void append(byte[] key)
      Description copied from interface: BPlusKeys
      append key at end
      Specified by:
      append in interface BPlusKeys<byte[],ByteBuffer>
    • splitLeft

      public BPlusKeys<byte[],ByteBuffer> splitLeft(int number, int n)
      Description copied from interface: BPlusKeys
      returns left number keys n is the resulting capacity for keys
      Specified by:
      splitLeft in interface BPlusKeys<byte[],ByteBuffer>
      Returns:
    • splitRight

      public BPlusKeys<byte[],ByteBuffer> splitRight(int index, int n)
      Description copied from interface: BPlusKeys
      returns right keys starting at index n is the resulting capacity for keys
      Specified by:
      splitRight in interface BPlusKeys<byte[],ByteBuffer>
      Returns:
    • copy

      public void copy(BPlusKeys<byte[],ByteBuffer> b, int numKey)
      Description copied from interface: BPlusKeys
      copy numKeys keys into key container b, starting at left most key
      Specified by:
      copy in interface BPlusKeys<byte[],ByteBuffer>
    • getKeyData

      public int getKeyData(byte[] fileData, int start, int numKey, int[] key, short[] length)
    • readFileData

      public int readFileData(byte[] fileData, int start, int numKey)
      Description copied from interface: BPlusKeys
      read numkey keys from array of bytes starting at start returns start+number of read bytes
      Specified by:
      readFileData in interface BPlusKeys<byte[],ByteBuffer>
      Returns:
    • writeFileData

      public int writeFileData(byte[] fileData, int start)
      Description copied from interface: BPlusKeys
      write key data to byte array starting at start Returns start + number of written bytes
      Specified by:
      writeFileData in interface BPlusKeys<byte[],ByteBuffer>
      Returns:
    • toString

      public String toString()
      Specified by:
      toString in interface BPlusKeys<byte[],ByteBuffer>
      Overrides:
      toString in class Object
    • sizeInBytes

      public int sizeInBytes()
      Description copied from interface: BPlusKeys
      returns the size in bytes for writing the keys to a file
      Specified by:
      sizeInBytes in interface BPlusKeys<byte[],ByteBuffer>
      Returns:
    • keySizeInBytes

      public int keySizeInBytes(byte[] key)
      Description copied from interface: BPlusKeys
      returns the number of bytes needed in addition if key is added
      Specified by:
      keySizeInBytes in interface BPlusKeys<byte[],ByteBuffer>
      Returns:
    • ensureCapacity

      public void ensureCapacity(int n, int length)
      Description copied from interface: BPlusKeys
      ensures the capacity for n keys (variable number of keys)
      Specified by:
      ensureCapacity in interface BPlusKeys<byte[],ByteBuffer>
      length - , the whole length in bytes for all keys
    • keySizeInBytes

      public int keySizeInBytes()
      Description copied from interface: BPlusKeys
      returns the size of a key in bytes if it is fix
      otherwise -1 is returned in addition if key is added
      Specified by:
      keySizeInBytes in interface BPlusKeys<byte[],ByteBuffer>
      Returns:
    • split

      public int split()
      Description copied from interface: BPlusKeys
      where to split
      Specified by:
      split in interface BPlusKeys<byte[],ByteBuffer>
      Returns: