Class BPlusNode<KeyType,KeyBufferType>
java.lang.Object
com.semedy.reasoner.edb.persistentstore.bplustree.BPlusNode<KeyType,KeyBufferType>
- All Implemented Interfaces:
CacheUnit
- Direct Known Subclasses:
BPlusInternalNode,BPlusLeaf
This class represents a node within a B+ tree, stored on disk.
- Author:
- angele
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionBPlusNode(BPlusKeys<KeyType, KeyBufferType> keys, int maxSizeInBytes, BPlusTree<KeyType, KeyBufferType> bplustree) Constructor for shared data. -
Method Summary
Modifier and TypeMethodDescriptionbooleanAnswers the question: Do we have keys to spare?abstract booleancheckSanity(String message, KeyType minKey, KeyType maxKey, DataFile df) checks whether all keys are sorted correctlyvoidclear()set the left sibling offsetvoiddetach()detach node from his fatherabstract voidperforms several cleaning up actions after borrowing from the right.abstract voidperforms several cleanign up actions after borrowing from the left.get the father nodeintget the index in father nodegetKeys()Returns the array of keysgetLast()getNext()intReturns the number of keys in keysintreturn the file offset of the nodeget status of bplus nodebooleanisEmpty()booleanisFull()abstract booleanisLeaf()A quick checker to see if the node is a leaf- if so, we have found the final result of the search.booleanis this unit releasablevoidrelease()Cache management calls this method to release the cache unit.voidsetFather(BPlusInternalNode<KeyType, KeyBufferType> daddy, int index) set the father node and the index in father nodevoidvoidpointers in a list for cache managementvoidsetStatus(BPlusNode.BPlusStatus status) set status of bplus nodelongreleases this number of bytestoString()voidtouch()touch a cache unit.boolean
-
Constructor Details
-
BPlusNode
public BPlusNode(BPlusKeys<KeyType, KeyBufferType> keys, int maxSizeInBytes, BPlusTree<KeyType, KeyBufferType> bplustree) Constructor for shared data.- Parameters:
keys-maxSizeInBytes-
-
-
Method Details
-
toString
-
getStatus
get status of bplus node- Returns:
-
setStatus
set status of bplus node- Parameters:
status-
-
getOffset
public int getOffset()return the file offset of the node- Returns:
-
isLeaf
public abstract boolean isLeaf()A quick checker to see if the node is a leaf- if so, we have found the final result of the search.- Returns:
- true if this is a leaf
-
setFather
set the father node and the index in father node -
getFather
get the father node- Returns:
-
getIndexInFather
public int getIndexInFather()get the index in father node- Returns:
-
detach
public void detach()detach node from his father -
getKeys
Returns the array of keys- Returns:
- the keys
-
getNumKeys
public int getNumKeys()Returns the number of keys in keys- Returns:
- number of keys present
-
isFull
public boolean isFull()- Returns:
- true if the node is full
-
isEmpty
public boolean isEmpty()- Returns:
- true if the node is empty
-
underflow
public boolean underflow()- Returns:
- true if we have < ceiling(m/2) -1 keys
-
canBeBorrowedFrom
public boolean canBeBorrowedFrom()Answers the question: Do we have keys to spare?- Returns:
- true if we can, false otherwise.
-
borrowKey
- Returns:
- the last key
-
borrowFirstKey
- Returns:
- the first key
-
clear
public void clear()set the left sibling offset -
doneBorrowing
public abstract void doneBorrowing()performs several cleaning up actions after borrowing from the right. -
doneBorrowingFirst
public abstract void doneBorrowingFirst()performs several cleanign up actions after borrowing from the left. -
checkSanity
checks whether all keys are sorted correctly- Returns:
-
touch
touch a cache unit.
this means for cache management that this unit
will be used and has a lower prio to be released- Specified by:
touchin interfaceCacheUnit- Throws:
IOException
-
setNext
pointers in a list for cache management -
getNext
-
setLast
-
getLast
-
release
Cache management calls this method to release the cache unit.- Specified by:
releasein interfaceCacheUnit- Throws:
IOException
-
isReleasable
public boolean isReleasable()is this unit releasable- Specified by:
isReleasablein interfaceCacheUnit- Returns:
-
sizeInBytes
public long sizeInBytes()Description copied from interface:CacheUnitreleases this number of bytes- Specified by:
sizeInBytesin interfaceCacheUnit- Returns:
-