Class BplusDataFile
java.lang.Object
com.semedy.reasoner.edb.persistentstore.bplustree.BplusDataFile
- All Implemented Interfaces:
Closeable,AutoCloseable
Manages file space for data like bplus nodes, indice values, symbols etc.
File space is managed with variable piece sizes.
A free space list is managed. Data are compressed with lz4
File space is managed with variable piece sizes.
A free space list is managed. Data are compressed with lz4
- Author:
- angele
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBplusDataFile(String filePath, int additionalHeadSpace, int nodeSize, boolean compress) -
Method Summary
Modifier and TypeMethodDescriptionintalloc(int oldindex, byte[] data) Searches for free space in file and writes
data to that spacebooleanchecks free space listbooleanchecks for double occurencesvoidclear()clear allvoidclose()Close filevoidcreate()Create a file.voiddelete()delete fileelements()get an iterator over file piecesvoidflush()flush out page tablevoidfree(int index, boolean shadow) Frees up space at indexintgetFlags()write flags to fileintget node sizeintgetRoot()get root locationlonggetSize()get number of elements in page tableintlength(long pos) length of filebooleanopen()Open an existing file.byte[]read(int index, boolean shadow) Reads data at index from file and returns itlong[]read groundsvoidvoidsetBulkMode(boolean mode) set bulk modevoidsetFlags(int flags) write flags to filevoidsetGrounds(long[] longs) write groundsvoidsetNodeSize(int nodesize) set node sizevoidsetRoot(int index) set root locationvoidsetSize(long size) set number of elements in page tablevoidstart transactionvoidcommit transactionvoidrollback transactionlongwrite(byte[] data) write data at index 0intwrite(int oldindex, byte[] data) Searches for free space in file and writes
data to that spacelongwriteOffset(int oldindex, byte[] data) Write to an offset and return (new) offset
-
Field Details
-
_count
public static int _count -
buglog
public static boolean buglog
-
-
Constructor Details
-
BplusDataFile
-
-
Method Details
-
setBugLog
-
create
Create a file. If it exists it will be cleared. File has a header of 32 bytes- Throws:
IOExceptionEDBException
-
open
Open an existing file. Return true if successful.- Returns:
- Throws:
IOExceptionEDBException
-
checkSanity1
public boolean checkSanity1()checks for double occurences- Returns:
-
checkSanity
public boolean checkSanity()checks free space list- Returns:
-
write
Searches for free space in file and writes
data to that space- Parameters:
data- to write to fileoldindex- , index to write to- Throws:
IOException
-
alloc
Searches for free space in file and writes
data to that space- Parameters:
data- to write to fileoldindex- , index to write to- Throws:
IOException
-
writeOffset
Write to an offset and return (new) offset- Parameters:
oldindex-data-- Returns:
- Throws:
IOException
-
read
Reads data at index from file and returns it- Parameters:
index-shadow- , read from shadow tree- Returns:
- Throws:
IOException
-
free
Frees up space at index- Parameters:
index-- Throws:
IOException
-
setFlags
write flags to file- Parameters:
flags-- Throws:
IOException
-
getFlags
write flags to file- Parameters:
flags-- Throws:
IOException
-
close
Close file- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
flush
flush out page table- Throws:
IOException
-
setGrounds
write grounds- Throws:
IOException
-
readGrounds
read grounds- Throws:
IOException
-
write
write data at index 0- Throws:
IOException
-
delete
public void delete()delete file -
setBulkMode
public void setBulkMode(boolean mode) set bulk mode -
transactionCommit
commit transaction- Throws:
IOException
-
transactionBegin
start transaction- Throws:
IOException
-
transactionRollback
rollback transaction- Throws:
IOException
-
length
length of file- Throws:
IOException
-
clear
clear all- Throws:
IOExceptionEDBException
-
elements
get an iterator over file pieces -
setRoot
public void setRoot(int index) set root location -
getRoot
public int getRoot()get root location -
setNodeSize
public void setNodeSize(int nodesize) set node size -
getNodeSize
public int getNodeSize()get node size -
setSize
public void setSize(long size) set number of elements in page table -
getSize
public long getSize()get number of elements in page table
-