Class TupleFile
java.lang.Object
com.semedy.reasoner.edb.persistentstore.TupleFile
- All Implemented Interfaces:
Closeable,AutoCloseable
a tuple file is a flat binary file containing all tuples in a sequence.
It stores added tuples in a redundant way as they are already stored in the bplus tree
It gets invalidated as soon as tuples are removed
It stores added tuples in a redundant way as they are already stored in the bplus tree
It gets invalidated as soon as tuples are removed
- Author:
- juergen
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()close tuple filevoidcreate()Create a tuple file.voidCreate a tuple file.voidOpen existing tuple file for appending tuples or create new one.voiddelete()delete tuple fileelements()Return an enumerator for the tuples.Iterator<byte[]>Return an enumerator for the tuples.longlength of the filevoidflush()flush the tuple fileintgetArity()get the file namegetPath()get path of the tuple filebooleanisEmpty()Is the tuple file empty, i.e. contains no tuples.booleanisValid()is tuple file validbooleanopen()Open an existing tuple file.voidsetValid(boolean valid) set valid state fo tuple filevoidsortElements(ExternalSortTuplesConsumer consumer, String tempDir) Sort the tuples.voidsortElements(String tempDir) Sort elements in tuple file.voidsortElementsIndexed(ExternalSortTuplesConsumer consumer, int[] indexedPositions, String tempDir) Sort elements according to the indexed positions.toString()voidadd all tuples from T into thisvoidwrite(byte[] tuple) append tuple (as bytes) to tuple filevoidwrite(long[] tuple) append tuple (as longs) to tuple filevoidwrite(TupleBuffer tuple) append tuple (as tuple buffer) to tuple file
-
Constructor Details
-
TupleFile
-
TupleFile
-
TupleFile
-
-
Method Details
-
getArity
public int getArity() -
getPath
get path of the tuple file- Returns:
-
getFileName
get the file name- Returns:
-
fileLength
public long fileLength()length of the file- Returns:
-
close
close tuple file- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
isValid
public boolean isValid()is tuple file valid- Returns:
-
flush
flush the tuple file- Throws:
IOException
-
setValid
set valid state fo tuple file- Parameters:
valid-- Throws:
IOException
-
write
append tuple (as bytes) to tuple file- Parameters:
tuple-- Throws:
IOException
-
write
append tuple (as longs) to tuple file- Parameters:
tuple-- Throws:
IOException
-
write
append tuple (as tuple buffer) to tuple file- Parameters:
tuple-- Throws:
IOException
-
delete
delete tuple file- Throws:
IOException
-
create
Create a tuple file.
Must be called after constructor to really create a file.- Throws:
IOException
-
create
Create a tuple file.
Must be called after constructor to really create a file.- Throws:
IOException
-
open
Open an existing tuple file.- Returns:
- Throws:
IOException
-
createOrAppend
Open existing tuple file for appending tuples or create new one.- Throws:
IOException
-
isEmpty
Is the tuple file empty, i.e. contains no tuples.- Returns:
- Throws:
IOExceptionEDBException
-
elements
Return an enumerator for the tuples.- Returns:
- Throws:
IOException
-
elementsAsBytes
Return an enumerator for the tuples.
It enumerates the tuples as byte vectors.- Returns:
- Throws:
IOException
-
sortElements
public void sortElements(ExternalSortTuplesConsumer consumer, String tempDir) throws IOException, EDBException Sort the tuples.
The consumer receives the single tuples in sorted order.- Parameters:
consumer-tempDir-- Throws:
IOExceptionEDBException
-
sortElements
Sort elements in tuple file.- Parameters:
tempDir-- Throws:
IOExceptionEDBException
-
sortElementsIndexed
public void sortElementsIndexed(ExternalSortTuplesConsumer consumer, int[] indexedPositions, String tempDir) throws IOException, EDBException Sort elements according to the indexed positions.
The consumer receives the tuples in this sequence.- Parameters:
consumer-indexedPositions-tempDir-- Throws:
IOExceptionEDBException
-
toString
-
union
add all tuples from T into this- Parameters:
T- , tuples to add- Throws:
IOExceptionEDBException
-