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
ConstructorDescriptionBPlusKeysVariableBytes
(int[] keys, short[] lengths, byte[] bytes, int fillsize, int numKeys, int keyLength) BPlusKeysVariableBytes
(int initialNumberOfKeys, int initialLength) -
Method Summary
Modifier and TypeMethodDescriptionvoid
append
(byte[] key) append key at endint
capacity()
how many keys can be contained?boolean
checkSanity
(String message, byte[] minKey, byte[] maxKey) check the correct sorting sequence of keysvoid
clear()
remove all keysint
compare
(byte[] key1, byte[] key2) compare two keysint
compare
(byte[] key, int index) compare key with key at index indexint
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 keyvoid
ensureCapacity
(int n, int length) ensures the capacity for n keys (variable number of keys)byte[]
get
(int i) return key with index ivoid
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 keyvoid
insertAtIndex
(byte[] key, int indexToInsert) inserts key at indexToInsertint
returns the size of a key in bytes if it is fix
otherwise -1 is returned in addition if key is addedint
keySizeInBytes
(byte[] key) returns the number of bytes needed in addition if key is addedint
numKeys()
return the current number of keysint
readFileData
(byte[] fileData, int start, int numKey) read numkey keys from array of bytes starting at start returns start+number of read bytesvoid
remove
(int indexToSkip) remove key at indexToSkip from set of keysvoid
replace
(byte[] key, byte[] replacement, int numKey) replaces key by replacementvoid
replace
(byte[] replacement, int numKey) replaces key by replacement at indexvoid
replaceByBuffer
(ByteBuffer replacement, int index) replaces key by replacement at indexint
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 addedint
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 addedint
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 iint
returns the size in bytes for writing the keys to a fileint
split()
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()
int
writeFileData
(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:BPlusKeys
check the correct sorting sequence of keys- Specified by:
checkSanity
in interfaceBPlusKeys<byte[],
ByteBuffer> - Returns:
-
clear
public void clear()Description copied from interface:BPlusKeys
remove all keys- Specified by:
clear
in interfaceBPlusKeys<byte[],
ByteBuffer>
-
capacity
public int capacity()Description copied from interface:BPlusKeys
how many keys can be contained?- Specified by:
capacity
in interfaceBPlusKeys<byte[],
ByteBuffer> - Returns:
-
numKeys
public int numKeys()Description copied from interface:BPlusKeys
return the current number of keys- Specified by:
numKeys
in interfaceBPlusKeys<byte[],
ByteBuffer> - Returns:
-
get
public byte[] get(int i) Description copied from interface:BPlusKeys
return key with index i- Specified by:
get
in interfaceBPlusKeys<byte[],
ByteBuffer> - Returns:
-
getBuffer
- Specified by:
getBuffer
in interfaceBPlusKeys<byte[],
ByteBuffer>
-
set
public void set(int i, byte[] key) Description copied from interface:BPlusKeys
set key with index i- Specified by:
set
in interfaceBPlusKeys<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 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:
compareBuffer
in interfaceBPlusKeys<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 interfaceBPlusKeys<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 interfaceBPlusKeys<byte[],
ByteBuffer> indicateNotContained
- , if key is not contained returns -1indicateContained
- , if key is contained returns -1- Returns:
-
searchBuffer
- Specified by:
searchBuffer
in 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: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 interfaceBPlusKeys<byte[],
ByteBuffer> - Returns:
-
searchBuffer
- Specified by:
searchBuffer
in interfaceBPlusKeys<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 interfaceBPlusKeys<byte[],
ByteBuffer>
-
insert
public int insert(byte[] key) Description copied from interface:BPlusKeys
inserts key- Specified by:
insert
in interfaceBPlusKeys<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 interfaceBPlusKeys<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 interfaceBPlusKeys<byte[],
ByteBuffer>
-
replaceByBuffer
Description copied from interface:BPlusKeys
replaces key by replacement at index- Specified by:
replaceByBuffer
in interfaceBPlusKeys<byte[],
ByteBuffer>
-
insertAtIndex
public void insertAtIndex(byte[] key, int indexToInsert) Description copied from interface:BPlusKeys
inserts key at indexToInsert- Specified by:
insertAtIndex
in interfaceBPlusKeys<byte[],
ByteBuffer>
-
append
public void append(byte[] key) Description copied from interface:BPlusKeys
append key at end- Specified by:
append
in interfaceBPlusKeys<byte[],
ByteBuffer>
-
splitLeft
Description copied from interface:BPlusKeys
returns left number keys n is the resulting capacity for keys- Specified by:
splitLeft
in interfaceBPlusKeys<byte[],
ByteBuffer> - Returns:
-
splitRight
Description copied from interface:BPlusKeys
returns right keys starting at index n is the resulting capacity for keys- Specified by:
splitRight
in interfaceBPlusKeys<byte[],
ByteBuffer> - Returns:
-
copy
Description copied from interface:BPlusKeys
copy numKeys keys into key container b, starting at left most key- Specified by:
copy
in 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:BPlusKeys
read numkey keys from array of bytes starting at start returns start+number of read bytes- Specified by:
readFileData
in interfaceBPlusKeys<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 interfaceBPlusKeys<byte[],
ByteBuffer> - Returns:
-
toString
- Specified by:
toString
in interfaceBPlusKeys<byte[],
ByteBuffer> - Overrides:
toString
in classObject
-
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 interfaceBPlusKeys<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 interfaceBPlusKeys<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 interfaceBPlusKeys<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 interfaceBPlusKeys<byte[],
ByteBuffer> - Returns:
-
split
public int split()Description copied from interface:BPlusKeys
where to split- Specified by:
split
in interfaceBPlusKeys<byte[],
ByteBuffer> - Returns:
-