Interface BPlusKeys<KeyType,KeyBufferType>
- Type Parameters:
KeyType-
- All Known Implementing Classes:
BPlusKeysFixedLong,BPlusKeysVariableBytes
public interface BPlusKeys<KeyType,KeyBufferType>
Describes an interface to the keys of a bplus node
- Author:
- angele
-
Method Summary
Modifier and TypeMethodDescriptionvoidappend key at endintcapacity()how many keys can be contained?booleancheckSanity(String message, KeyType minKey, KeyType maxKey) check the correct sorting sequence of keysvoidclear()remove all keysintcompare key with key at index indexintcompare two keysintcompareBuffer(KeyBufferType key, int index) voidcopy(BPlusKeys<KeyType, KeyBufferType> b, int numKeys) copy numKeys keys into key container b, starting at left most keyvoidensureCapacity(int n, int totalLengthInBytes) ensures the capacity for n keys (variable number of keys)get(int i) return key with index ivoidgetBuffer(int i, KeyBufferType result, BPlusNode<KeyType, KeyBufferType> node) intinserts keyvoidinsertAtIndex(KeyType 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(KeyType key) returns the number of bytes needed in addition if key is addedintnumKeys()return the current number of keysintreadFileData(byte[] fileData, int start, int numKeys) 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 keysvoidreplaces key by replacement at indexvoidreplaces key by replacementvoidreplaceByBuffer(KeyBufferType replacement, int index) replaces key by replacement at indexintsearch for key if indicateNodContained==true results -1 if key has not been found otherwise results the index where the key has to be addedintsearch 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(KeyBufferType key, boolean indicateNotContained, boolean indicateContained) intsearchBuffer(KeyBufferType key, int begin, boolean indicateNotContained) voidset key with index iintreturns the size in bytes for writing the keys to a fileintsplit()where to splitsplitLeft(int number, int n) returns left number keys n is the resulting capacity for keyssplitRight(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
-
Method Details
-
clear
void clear()remove all keys -
capacity
int capacity()how many keys can be contained?- Returns:
-
split
int split()where to split- Returns:
-
numKeys
int numKeys()return the current number of keys- Returns:
-
sizeInBytes
int sizeInBytes()returns the size in bytes for writing the keys to a file- Returns:
-
keySizeInBytes
returns the number of bytes needed in addition if key is added- Parameters:
key-- Returns:
-
keySizeInBytes
int keySizeInBytes()returns the size of a key in bytes if it is fix
otherwise -1 is returned in addition if key is added- Returns:
-
get
return key with index i- Parameters:
i-- Returns:
-
getBuffer
-
set
set key with index i- Parameters:
i-key-
-
compare
compare key with key at index index- Parameters:
key-index-- Returns:
-
compareBuffer
-
compare
compare two keys- Parameters:
key1-key2-- Returns:
-
search
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- Parameters:
key-indicateNotContained- , if key is not contained returns -1indicateContained- , if key is contained returns -1- Returns:
-
searchBuffer
-
search
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- Parameters:
key-begin-indicateNotContained-- Returns:
-
searchBuffer
-
remove
void remove(int indexToSkip) remove key at indexToSkip from set of keys- Parameters:
indexToSkip-
-
insert
inserts key- Parameters:
key-- Returns:
-
replace
replaces key by replacement- Parameters:
key-replacement-numKeys-
-
replace
replaces key by replacement at index- Parameters:
replacement-index-
-
replaceByBuffer
replaces key by replacement at index- Parameters:
replacement-index-
-
insertAtIndex
inserts key at indexToInsert- Parameters:
key-indexToInsert-
-
append
append key at end- Parameters:
key-
-
splitLeft
returns left number keys n is the resulting capacity for keys- Parameters:
number-n-- Returns:
-
splitRight
returns right keys starting at index n is the resulting capacity for keys- Parameters:
index-n-- Returns:
-
copy
copy numKeys keys into key container b, starting at left most key- Parameters:
b-numKeys-
-
readFileData
int readFileData(byte[] fileData, int start, int numKeys) read numkey keys from array of bytes starting at start returns start+number of read bytes- Parameters:
fileData-start-numKeys-- Returns:
-
writeFileData
int writeFileData(byte[] fileData, int start) write key data to byte array starting at start Returns start + number of written bytes- Parameters:
fileData-start-- Returns:
-
ensureCapacity
void ensureCapacity(int n, int totalLengthInBytes) ensures the capacity for n keys (variable number of keys)- Parameters:
n-totalLengthInBytes- , the whole length in bytes for all keys
-
checkSanity
check the correct sorting sequence of keys- Returns:
-
toString
String toString()
-