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
-
Constructor Summary
ConstructorDescriptionBplusDataFile
(String filePath, int additionalHeadSpace, int nodeSize, boolean compress) -
Method Summary
Modifier and TypeMethodDescriptionint
alloc
(int oldindex, byte[] data) Searches for free space in file and writes
data to that spaceboolean
checks free space listboolean
checks for double occurencesvoid
clear()
clear allvoid
close()
Close filevoid
create()
Create a file.void
delete()
delete fileelements()
get an iterator over file piecesvoid
flush()
flush out page tablevoid
free
(int index, boolean shadow) Frees up space at indexint
getFlags()
write flags to fileint
get node sizeint
getRoot()
get root locationlong
getSize()
get number of elements in page tableint
length
(long pos) length of fileboolean
open()
Open an existing file.byte[]
read
(int index, boolean shadow) Reads data at index from file and returns itlong[]
read groundsvoid
void
setBulkMode
(boolean mode) set bulk modevoid
setFlags
(int flags) write flags to filevoid
setGrounds
(long[] longs) write groundsvoid
setNodeSize
(int nodesize) set node sizevoid
setRoot
(int index) set root locationvoid
setSize
(long size) set number of elements in page tablevoid
start transactionvoid
commit transactionvoid
rollback transactionlong
write
(byte[] data) write data at index 0int
write
(int oldindex, byte[] data) Searches for free space in file and writes
data to that spacelong
writeOffset
(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:
IOException
EDBException
-
open
Open an existing file. Return true if successful.- Returns:
- Throws:
IOException
EDBException
-
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:
close
in interfaceAutoCloseable
- Specified by:
close
in 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:
IOException
EDBException
-
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
-