Class BPlusLeaf<KeyType,KeyBufferType> 
java.lang.Object
com.semedy.reasoner.edb.persistentstore.bplustree.BPlusNode<KeyType,KeyBufferType>
 
com.semedy.reasoner.edb.persistentstore.bplustree.BPlusLeaf<KeyType,KeyBufferType> 
- All Implemented Interfaces:
- CacheUnit
- Direct Known Subclasses:
- BPlusLeafRecords
A leaf is the node in a B+ tree containing records. Although we want them to be generic, 
most B+ trees are specialized. As a result, the only thing generic about the tree is the key
most B+ trees are specialized. As a result, the only thing generic about the tree is the key
- Author:
- angele
- 
Nested Class SummaryNested classes/interfaces inherited from class com.semedy.reasoner.edb.persistentstore.bplustree.BPlusNodeBPlusNode.BPlusStatus
- 
Constructor SummaryConstructorsConstructorDescriptionBPlusLeaf(BPlusKeys<KeyType, KeyBufferType> keys, int maxSizeInBytes, BPlusTree<KeyType, KeyBufferType> bplustree) BPlusLeaf(BPlusKeys<KeyType, KeyBufferType> keys, long[] records, int maxSizeInBytes, BPlusTree<KeyType, KeyBufferType> bplustree) Initializes leaf.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanappend a key with a recordlongBorrow the first recordlongborrows the rightmost recordbooleancheckSanity(String message, KeyType minKey, KeyType maxKey, DataFile df) checks whether all keys are sorted correctlybyte[]Map node to an array of bytesstatic BPlusLeaf<long[],TupleBuffer> createLeaf(byte[] bytes, KeysFactory<long[], TupleBuffer> keysFactory, BPlusTree<long[], TupleBuffer> bplustree) Method for creating a leaf from the given byte array.booleanDeletes the key (and the associated record offset) from this node.voiddestroy()free up ressources at the end (CacheManager.clear)voidperforms several cleaning up actions after borrowing from the right.voidperforms several cleanign up actions after borrowing from the left.getIndexBuffer(int index) get attached object at indexlonggetObjectSize(int index) get size of attached object at indexlonggetRecord(int index) get record at indexlong[]booleanInserts a key and the record offset into the node.booleanisLeaf()A quick checker to see if the node is a leaf- if so, we have found the final result of the search.voidremove()voidreplaces key at index by replacement keylongSearches for the given value.longintsearchIndex(KeyType key) Searches for index of the key Returns -1 it key is not containedintSearches for hte (possible) index of the keyintSearches for insert position of keyintSearches for insert position of keybooleansets for a given key the record.
 returns false if key is not therevoidsubstitute(BPlusKeys<KeyType, KeyBufferType> key, long[] record, long leftOffs) Methods inherited from class com.semedy.reasoner.edb.persistentstore.bplustree.BPlusNodeborrowFirstKey, borrowKey, canBeBorrowedFrom, clear, detach, getFather, getIndexInFather, getKeys, getLast, getNext, getNumKeys, getOffset, getStatus, isEmpty, isFull, isReleasable, release, setFather, setLast, setNext, setStatus, sizeInBytes, toString, touch, underflow
- 
Constructor Details- 
BPlusLeafpublic BPlusLeaf(BPlusKeys<KeyType, KeyBufferType> keys, int maxSizeInBytes, BPlusTree<KeyType, KeyBufferType> bplustree) - Parameters:
- keys- , given keys
- maxSizeInBytes- , max size of a node in bytes
- bplustree-
 
- 
BPlusLeafpublic BPlusLeaf(BPlusKeys<KeyType, KeyBufferType> keys, long[] records, int maxSizeInBytes, BPlusTree<KeyType, KeyBufferType> bplustree) Initializes leaf.- Parameters:
- keys-
- records-
- maxSizeInBytes-
- bplustree-
 
 
- 
- 
Method Details- 
substitute
- 
deleteDeletes the key (and the associated record offset) from this node.
 First, we find the index of the key. Make a temp array containing keys[0, indexToSkip - 1]
 copy keys[indexToSkip + 1, keys.length - 1] over. Do the same with the records.- Parameters:
- keyToDelete-
 
- 
replacereplaces key at index by replacement key- Parameters:
- replacement-
- index-
 
- 
insertInserts a key and the record offset into the node. First, we find the index where these items need to be. Then copy all elements up to that point into a temp array. Shove the new key in, copy the rest of the elements. use the same index and do the same with the records.- Parameters:
- key-
- record-
- Throws:
- IOException
 
- 
setsets for a given key the record.
 returns false if key is not there- Parameters:
- key-
- record-
 
- 
appendappend a key with a record- Parameters:
- key-
- record-
- Returns:
- Throws:
- IOException
 
- 
isLeafpublic boolean isLeaf()Description copied from class:BPlusNodeA quick checker to see if the node is a leaf- if so, we have found the final result of the search.- Specified by:
- isLeafin class- BPlusNode<KeyType,- KeyBufferType> 
- Returns:
- true if this is a leaf
 
- 
searchSearches for the given value.- Parameters:
- key-
- Returns:
- the value for the key, or -1 if not found.
 
- 
searchIndexToInsertSearches for insert position of key- Parameters:
- key-
- Returns:
- (possible) index position
 
- 
searchIndexToInsertByBufferSearches for insert position of key- Parameters:
- key-
- Returns:
- (possible) index position
 
- 
searchIndexSearches for index of the key Returns -1 it key is not contained- Parameters:
- key-
- Returns:
 
- 
searchIndexBufferSearches for hte (possible) index of the key- Parameters:
- key-
- Returns:
 
- 
searchBuffer
- 
getRecordspublic long[] getRecords()- Returns:
- array of records
 
- 
getRecordpublic long getRecord(int index) get record at index- Parameters:
- index-
- Returns:
 
- 
getIndexBufferget attached object at index- Throws:
- IOException
 
- 
getObjectSizeget size of attached object at index- Throws:
- IOException
 
- 
borrowRecordpublic long borrowRecord()borrows the rightmost record- Returns:
- the rightmost record
 
- 
doneBorrowingpublic void doneBorrowing()Description copied from class:BPlusNodeperforms several cleaning up actions after borrowing from the right.- Specified by:
- doneBorrowingin class- BPlusNode<KeyType,- KeyBufferType> 
 
- 
borrowFirstRecordpublic long borrowFirstRecord()Borrow the first record- Returns:
- the first record
 
- 
doneBorrowingFirstpublic void doneBorrowingFirst()Description copied from class:BPlusNodeperforms several cleanign up actions after borrowing from the left.- Specified by:
- doneBorrowingFirstin class- BPlusNode<KeyType,- KeyBufferType> 
 
- 
checkSanityDescription copied from class:BPlusNodechecks whether all keys are sorted correctly- Specified by:
- checkSanityin class- BPlusNode<KeyType,- KeyBufferType> 
- Returns:
 
- 
removepublic void remove()
- 
destroypublic void destroy()Description copied from interface:CacheUnitfree up ressources at the end (CacheManager.clear)
- 
createBytespublic byte[] createBytes()Map node to an array of bytes- Returns:
 
- 
createLeafpublic static BPlusLeaf<long[],TupleBuffer> createLeaf(byte[] bytes, KeysFactory<long[], TupleBuffer> keysFactory, BPlusTree<long[], TupleBuffer> bplustree) Method for creating a leaf from the given byte array.- Parameters:
- bytes-
- Returns:
 
 
-