Class BPlusKeysVariableBytes
java.lang.Object
com.semedy.reasoner.edb.persistentstore.bplustree.BPlusKeysVariableBytes
- All Implemented Interfaces:
BPlusKeys<byte[],ByteBuffer>
variable number, variable sized byte arrays as keys of a bplus node
- Author:
- angele
-
Constructor Summary
ConstructorsConstructorDescriptionBPlusKeysVariableBytes(int[] keys, short[] lengths, byte[] bytes, int fillsize, int numKeys, int keyLength) BPlusKeysVariableBytes(int initialNumberOfKeys, int initialLength) -
Method Summary
Modifier and TypeMethodDescriptionvoidappend(byte[] key) append key at endintcapacity()how many keys can be contained?booleancheckSanity(String message, byte[] minKey, byte[] maxKey) check the correct sorting sequence of keysvoidclear()remove all keysintcompare(byte[] key1, byte[] key2) compare two keysintcompare(byte[] key, int index) compare key with key at index indexintcompare(int index1, int index2) intcompareBuffer(ByteBuffer key, int index) intcompareNew(byte[] key1, byte[] key2) intcompareNew(byte[] key, int index) intcompareNew(int index1, int index2) intcompareS(int index1, int index2) voidcopy(BPlusKeys<byte[], ByteBuffer> b, int numKey) copy numKeys keys into key container b, starting at left most keyvoidensureCapacity(int n, int length) ensures the capacity for n keys (variable number of keys)byte[]get(int i) return key with index ivoidgetBuffer(int i, ByteBuffer result, BPlusNode<byte[], ByteBuffer> node) intgetKeyData(byte[] fileData, int start, int numKey, int[] key, short[] length) intinsert(byte[] key) inserts keyvoidinsertAtIndex(byte[] key, int indexToInsert) inserts key at indexToInsertintreturns the size of a key in bytes if it is fix
otherwise -1 is returned in addition if key is addedintkeySizeInBytes(byte[] key) returns the number of bytes needed in addition if key is addedintnumKeys()return the current number of keysintreadFileData(byte[] fileData, int start, int numKey) read numkey keys from array of bytes starting at start returns start+number of read bytesvoidremove(int indexToSkip) remove key at indexToSkip from set of keysvoidreplace(byte[] key, byte[] replacement, int numKey) replaces key by replacementvoidreplace(byte[] replacement, int numKey) replaces key by replacement at indexvoidreplaceByBuffer(ByteBuffer replacement, int index) replaces key by replacement at indexintsearch(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 addedintsearch(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 addedintsearchBuffer(ByteBuffer key, boolean indicateNotContained, boolean indicateContained) intsearchBuffer(ByteBuffer key, int[] index, int begin, boolean indicateNotContained, boolean next) intsearchBuffer(ByteBuffer key, int begin, boolean indicateNotContained) intsearchKey(byte[] key, int[] index, int begin, boolean indicateNotContained, boolean next) voidset(int i, byte[] key) set key with index iintreturns the size in bytes for writing the keys to a fileintsplit()where to splitBPlusKeys<byte[],ByteBuffer> splitLeft(int number, int n) returns left number keys n is the resulting capacity for keysBPlusKeys<byte[],ByteBuffer> splitRight(int index, int n) returns right keys starting at index n is the resulting capacity for keystoString()intwriteFileData(byte[] fileData, int start) write key data to byte array starting at start Returns start + number of written bytes
-
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
Description copied from interface:BPlusKeyscheck the correct sorting sequence of keys- Specified by:
checkSanityin interfaceBPlusKeys<byte[],ByteBuffer> - Returns:
-
clear
public void clear()Description copied from interface:BPlusKeysremove all keys- Specified by:
clearin interfaceBPlusKeys<byte[],ByteBuffer>
-
capacity
public int capacity()Description copied from interface:BPlusKeyshow many keys can be contained?- Specified by:
capacityin interfaceBPlusKeys<byte[],ByteBuffer> - Returns:
-
numKeys
public int numKeys()Description copied from interface:BPlusKeysreturn the current number of keys- Specified by:
numKeysin interfaceBPlusKeys<byte[],ByteBuffer> - Returns:
-
get
public byte[] get(int i) Description copied from interface:BPlusKeysreturn key with index i- Specified by:
getin interfaceBPlusKeys<byte[],ByteBuffer> - Returns:
-
getBuffer
- Specified by:
getBufferin interfaceBPlusKeys<byte[],ByteBuffer>
-
set
public void set(int i, byte[] key) Description copied from interface:BPlusKeysset key with index i- Specified by:
setin interfaceBPlusKeys<byte[],ByteBuffer>
-
compare
public int compare(byte[] key, int index) Description copied from interface:BPlusKeyscompare key with key at index index- Specified by:
comparein interfaceBPlusKeys<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
- Specified by:
compareBufferin interfaceBPlusKeys<byte[],ByteBuffer>
-
compareNew
public int compareNew(byte[] key1, byte[] key2) -
compare
public int compare(byte[] key1, byte[] key2) Description copied from interface:BPlusKeyscompare two keys- Specified by:
comparein interfaceBPlusKeys<byte[],ByteBuffer> - Returns:
-
search
public int search(byte[] key, boolean indicateNotContained, boolean indicateContained) Description copied from interface:BPlusKeyssearch 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:
searchin interfaceBPlusKeys<byte[],ByteBuffer> indicateNotContained- , if key is not contained returns -1indicateContained- , if key is contained returns -1- Returns:
-
searchBuffer
- Specified by:
searchBufferin interfaceBPlusKeys<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:BPlusKeyssearch 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:
searchin interfaceBPlusKeys<byte[],ByteBuffer> - Returns:
-
searchBuffer
- Specified by:
searchBufferin interfaceBPlusKeys<byte[],ByteBuffer>
-
remove
public void remove(int indexToSkip) Description copied from interface:BPlusKeysremove key at indexToSkip from set of keys- Specified by:
removein interfaceBPlusKeys<byte[],ByteBuffer>
-
insert
public int insert(byte[] key) Description copied from interface:BPlusKeysinserts key- Specified by:
insertin interfaceBPlusKeys<byte[],ByteBuffer> - Returns:
-
replace
public void replace(byte[] key, byte[] replacement, int numKey) Description copied from interface:BPlusKeysreplaces key by replacement- Specified by:
replacein interfaceBPlusKeys<byte[],ByteBuffer>
-
replace
public void replace(byte[] replacement, int numKey) Description copied from interface:BPlusKeysreplaces key by replacement at index- Specified by:
replacein interfaceBPlusKeys<byte[],ByteBuffer>
-
replaceByBuffer
Description copied from interface:BPlusKeysreplaces key by replacement at index- Specified by:
replaceByBufferin interfaceBPlusKeys<byte[],ByteBuffer>
-
insertAtIndex
public void insertAtIndex(byte[] key, int indexToInsert) Description copied from interface:BPlusKeysinserts key at indexToInsert- Specified by:
insertAtIndexin interfaceBPlusKeys<byte[],ByteBuffer>
-
append
public void append(byte[] key) Description copied from interface:BPlusKeysappend key at end- Specified by:
appendin interfaceBPlusKeys<byte[],ByteBuffer>
-
splitLeft
Description copied from interface:BPlusKeysreturns left number keys n is the resulting capacity for keys- Specified by:
splitLeftin interfaceBPlusKeys<byte[],ByteBuffer> - Returns:
-
splitRight
Description copied from interface:BPlusKeysreturns right keys starting at index n is the resulting capacity for keys- Specified by:
splitRightin interfaceBPlusKeys<byte[],ByteBuffer> - Returns:
-
copy
Description copied from interface:BPlusKeyscopy numKeys keys into key container b, starting at left most key- Specified by:
copyin interfaceBPlusKeys<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:BPlusKeysread numkey keys from array of bytes starting at start returns start+number of read bytes- Specified by:
readFileDatain interfaceBPlusKeys<byte[],ByteBuffer> - Returns:
-
writeFileData
public int writeFileData(byte[] fileData, int start) Description copied from interface:BPlusKeyswrite key data to byte array starting at start Returns start + number of written bytes- Specified by:
writeFileDatain interfaceBPlusKeys<byte[],ByteBuffer> - Returns:
-
toString
- Specified by:
toStringin interfaceBPlusKeys<byte[],ByteBuffer> - Overrides:
toStringin classObject
-
sizeInBytes
public int sizeInBytes()Description copied from interface:BPlusKeysreturns the size in bytes for writing the keys to a file- Specified by:
sizeInBytesin interfaceBPlusKeys<byte[],ByteBuffer> - Returns:
-
keySizeInBytes
public int keySizeInBytes(byte[] key) Description copied from interface:BPlusKeysreturns the number of bytes needed in addition if key is added- Specified by:
keySizeInBytesin interfaceBPlusKeys<byte[],ByteBuffer> - Returns:
-
ensureCapacity
public void ensureCapacity(int n, int length) Description copied from interface:BPlusKeysensures the capacity for n keys (variable number of keys)- Specified by:
ensureCapacityin interfaceBPlusKeys<byte[],ByteBuffer> length- , the whole length in bytes for all keys
-
keySizeInBytes
public int keySizeInBytes()Description copied from interface:BPlusKeysreturns the size of a key in bytes if it is fix
otherwise -1 is returned in addition if key is added- Specified by:
keySizeInBytesin interfaceBPlusKeys<byte[],ByteBuffer> - Returns:
-
split
public int split()Description copied from interface:BPlusKeyswhere to split- Specified by:
splitin interfaceBPlusKeys<byte[],ByteBuffer> - Returns:
-