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 TypeMethodDescriptionvoid
close()
close tuple filevoid
create()
Create a tuple file.void
Create a tuple file.void
Open existing tuple file for appending tuples or create new one.void
delete()
delete tuple fileelements()
Return an enumerator for the tuples.Iterator<byte[]>
Return an enumerator for the tuples.long
length of the filevoid
flush()
flush the tuple fileint
getArity()
get the file namegetPath()
get path of the tuple fileboolean
isEmpty()
Is the tuple file empty, i.e. contains no tuples.boolean
isValid()
is tuple file validboolean
open()
Open an existing tuple file.void
setValid
(boolean valid) set valid state fo tuple filevoid
sortElements
(ExternalSortTuplesConsumer consumer, String tempDir) Sort the tuples.void
sortElements
(String tempDir) Sort elements in tuple file.void
sortElementsIndexed
(ExternalSortTuplesConsumer consumer, int[] indexedPositions, String tempDir) Sort elements according to the indexed positions.toString()
void
add all tuples from T into thisvoid
write
(byte[] tuple) append tuple (as bytes) to tuple filevoid
write
(long[] tuple) append tuple (as longs) to tuple filevoid
write
(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:
close
in interfaceAutoCloseable
- Specified by:
close
in 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:
IOException
EDBException
-
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:
IOException
EDBException
-
sortElements
Sort elements in tuple file.- Parameters:
tempDir
-- Throws:
IOException
EDBException
-
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:
IOException
EDBException
-
toString
-
union
add all tuples from T into this- Parameters:
T
- , tuples to add- Throws:
IOException
EDBException
-