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
-
Constructor Summary
ConstructorDescriptionBPlusNode
(BPlusKeys<KeyType, KeyBufferType> keys, int maxSizeInBytes, BPlusTree<KeyType, KeyBufferType> bplustree) Constructor for shared data. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Answers the question: Do we have keys to spare?abstract boolean
checkSanity
(String message, KeyType minKey, KeyType maxKey, DataFile df) checks whether all keys are sorted correctlyvoid
clear()
set the left sibling offsetvoid
detach()
detach node from his fatherabstract void
performs several cleaning up actions after borrowing from the right.abstract void
performs several cleanign up actions after borrowing from the left.get the father nodeint
get the index in father nodegetKeys()
Returns the array of keysgetLast()
getNext()
int
Returns the number of keys in keysint
return the file offset of the nodeget status of bplus nodeboolean
isEmpty()
boolean
isFull()
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.boolean
is this unit releasablevoid
release()
Cache management calls this method to release the cache unit.void
setFather
(BPlusInternalNode<KeyType, KeyBufferType> daddy, int index) set the father node and the index in father nodevoid
void
pointers in a list for cache managementvoid
setStatus
(BPlusNode.BPlusStatus status) set status of bplus nodelong
releases this number of bytestoString()
void
touch()
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:
touch
in 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:
release
in interfaceCacheUnit
- Throws:
IOException
-
isReleasable
public boolean isReleasable()is this unit releasable- Specified by:
isReleasable
in interfaceCacheUnit
- Returns:
-
sizeInBytes
public long sizeInBytes()Description copied from interface:CacheUnit
releases this number of bytes- Specified by:
sizeInBytes
in interfaceCacheUnit
- Returns:
-