Class BPlusTreeFile<KeyType,KeyBufferType> 
java.lang.Object
com.semedy.reasoner.edb.persistentstore.bplustree.BPlusTreeFile<KeyType,KeyBufferType> 
- Type Parameters:
- KeyType-
- KeyBufferType-
This file handles the writing of nodes to files and the reading of nodes back.
- Author:
- angele
- 
Field SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionBPlusTreeFile(String filename, int m, int keyLengthInBytes, int nodeLengthInBytes, KeysFactory<KeyType, KeyBufferType> keysFactory, LeafFactory<KeyType, KeyBufferType> leafFactory, BPlusTree<KeyType, KeyBufferType> bplustree, int additionalHeadSpace, boolean compress) General constructor.
- 
Method SummaryModifier and TypeMethodDescriptionbooleancheckSanity(String message) checks sanityvoidclose()Close filevoidcreate()create filevoidflush()flush filebyte[]return file headergetNode(byte[] bytes, int offset) get node out of bytes and offsetlongget size of filebooleanopen()open fileintwrite flagslong[]readGrounds(long[] grounds) read groundsreadNode(int offset, boolean shadow) public method for reading a node at a given file offset.longread number of elementsintread offset of rootvoidreleaseNode(BPlusNode<KeyType, KeyBufferType> node, boolean shadow) free up disk space for bplus nodevoidbegin transactionvoidcommitvoidrollback transactionvoidwriteAdditionalHeadSpace(int additional) write additional headspace (used for grounds)voidwriteFlags(int flags) read flagsvoidwriteGrounds(long[] grounds) write groundsintwriteInternalNode(BPlusInternalNode<KeyType, KeyBufferType> toWrite, int offset) write an internal node at offsetintwriteLeaf(BPlusLeaf<KeyType, KeyBufferType> toWrite, int offset) write a leaf at offsetlongWrites a new internal node to the end of the file.intwriteNewLeaf(BPlusLeaf<KeyType, KeyBufferType> toWrite) Writes a new leaf to the end of the file.voidwriteNodeSize(int size) write node sizevoidwriteNumberOfElements(long numElements) write number of elementsvoidwriteRootOffset(int offset) write offset of root
- 
Field Details- 
DEFAULT_FILE_NAME- See Also:
 
 
- 
- 
Constructor Details- 
BPlusTreeFilepublic BPlusTreeFile(String filename, int m, int keyLengthInBytes, int nodeLengthInBytes, KeysFactory<KeyType, KeyBufferType> keysFactory, LeafFactory<KeyType, throws IOException, EDBExceptionKeyBufferType> leafFactory, BPlusTree<KeyType, KeyBufferType> bplustree, int additionalHeadSpace, boolean compress) General constructor.- Parameters:
- filename-
- m-
- keyLengthInBytes-
- nodeLengthInBytes-
- keysFactory-
- leafFactory-
- bplustree-
- additionalHeadSpace-
- Throws:
- IOException
- EDBException
 
 
- 
- 
Method Details- 
getSizeOnDiscpublic long getSizeOnDisc()get size of file- Returns:
 
- 
openopen file- Returns:
- Throws:
- EDBException
- IOException
 
- 
createcreate file- Throws:
- IOException
- EDBException
 
- 
getHeaderpublic byte[] getHeader()return file header- Returns:
 
- 
checkSanitychecks sanity- Returns:
 
- 
closeClose file- Throws:
- IOException
 
- 
flushflush file- Throws:
- IOException
 
- 
transactionCommitcommit- Throws:
- IOException
 
- 
transactionRollbackrollback transaction- Throws:
- IOException
 
- 
transactionBeginbegin transaction- Throws:
- IOException
 
- 
readNodepublic method for reading a node at a given file offset.
 First determines the type of node, then calls the appropriate helper method.- Parameters:
- offset-
- shadow- , read from shadow tree
- Returns:
- Throws:
- IOException
 
- 
getNodeget node out of bytes and offset- Parameters:
- bytes-
- offset-
- Returns:
- Throws:
- IOException
 
- 
writeNewInternalNodepublic long writeNewInternalNode(BPlusInternalNode<KeyType, KeyBufferType> toWrite) throws IOException, EDBExceptionWrites a new internal node to the end of the file.- Parameters:
- toWrite-
- Returns:
- location (file offset) of the leaf
- Throws:
- IOException
- EDBException
 
- 
writeNewLeafWrites a new leaf to the end of the file.- Parameters:
- toWrite-
- Returns:
- location (file offset) of the leaf
- Throws:
- IOException
- EDBException
 
- 
writeInternalNodepublic int writeInternalNode(BPlusInternalNode<KeyType, KeyBufferType> toWrite, int offset) throws IOException, EDBExceptionwrite an internal node at offset- Parameters:
- toWrite-
- offset-
- Returns:
- Throws:
- IOException
- EDBException
 
- 
writeLeafpublic int writeLeaf(BPlusLeaf<KeyType, KeyBufferType> toWrite, int offset) throws IOException, EDBExceptionwrite a leaf at offset- Parameters:
- toWrite-
- offset-
- Returns:
- Throws:
- IOException
- EDBException
 
- 
releaseNodefree up disk space for bplus node- Parameters:
- node-
- Throws:
- IOException
 
- 
writeNumberOfElementspublic void writeNumberOfElements(long numElements) write number of elements- Parameters:
- numElements-
 
- 
readNumberOfElementspublic long readNumberOfElements()read number of elements- Returns:
 
- 
readFlagswrite flags- Returns:
- Throws:
- IOException
 
- 
writeFlagsread flags- Parameters:
- flags-
- Throws:
- IOException
 
- 
writeNodeSizepublic void writeNodeSize(int size) write node size- Parameters:
- size-
 
- 
writeRootOffsetpublic void writeRootOffset(int offset) write offset of root- Parameters:
- offset-
 
- 
readRootOffsetpublic int readRootOffset()read offset of root- Returns:
 
- 
writeAdditionalHeadSpacewrite additional headspace (used for grounds)- Parameters:
- additional-
- Throws:
- IOException
 
- 
writeGroundswrite grounds- Parameters:
- grounds-
- Throws:
- IOException
 
- 
readGroundsread grounds- Parameters:
- grounds-
- Returns:
- Throws:
- IOException
 
 
-