Class PersistentRelation
java.lang.Object
com.semedy.reasoner.edb.persistentstore.PersistentRelation
- All Implemented Interfaces:
BaseRelation,Relation,Closeable,AutoCloseable
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPersistentRelation(FileName filename, String workdir, String edbdir, String logDir, boolean compress) PersistentRelation(FileName filename, String workdir, String edbdir, String logDir, boolean temporary, boolean compress) PersistentRelation(FileName filename, String workdir, String edbdir, String logDir, boolean compress, long[] grounds) PersistentRelation(FileName filename, String workdir, String edbdir, String logDir, TupleStore tupleStore, boolean temporary, boolean compress) -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanaddTuple(int tuple) add a tuple to the relationbooleanaddTuple(long[] tuple) add a tuple to the relationbooleanaddTuple(TupleBuffer tuple) add a tuple to the relationvoidvoidbugLogMessage(String message) voidcheckNumbers(String message) booleancheckSanity(String message, boolean shadow) check sanity of persistent relationvoidclear()remove all tuplesvoidclose()Close the relation.voidcloseBulkLoad(BulkLoadConsumer consume) booleancontainsTuple(int tuple) Is tuple contained in relation?booleancontainsTuple(long[] tuple) Is tuple contained in relation?booleancontainsTuple(TupleBuffer tpl) Is tuple contained in relation?longcount()voidcreate()createIndex(int[] indexedpositions) Get or create a simple (not sorted index) by the argument positions in indexed positions.createSortedIndex(int[] indexedpositions) ret or create a sorted index given by the argument positions in indexed positionsvoiddelete()remove all tuples and release filesvoiddeSelect()release ressources because relation is currently not usedelements()returns an enumerator for all tupleselements(long[] filter) returns an filteres enumerator for all tuplesvoidflush()Flush the relation.voidForce closing (instead of closing is blocked)voidForce deleting (instead of deleting is blocked)intgetArity()returns the arity of the relationget the caching infoget standard path for binary fileintgetDirectEncodedType(int i) get the type of the direct encoded argumentreturns the file name for the relationlong[]get ground arguments, which are ground in all tuplesreturns a unique identifier for the relationgetIndex(int[] indexedpositions) Get an index given by the argument positions in indexed positions (if it already exists).get an input buffer for relationintreturns the internal arity of tuplescom.semedy.reasoner.edb.persistentstore.PersistentRelation.IterativeLoadConsumerlonggetMaxValue(int argument) returns the maximal value at that argument positionlonggetMinValue(int argument) returns the minimal value at that argument positiongetName()get a unique name of the relationlonggetNumberOfDifferentValues(int position) Returns the number of different values at the argument positions.longgetNumberOfDifferentValues(int position, long value) Returns the number of values occurring at the argument positions
Used for statisticslonggetNumberOfMatchingTuples(int[] arguments, long[] values) longgetNumberOfTuples(int position, long term) returns the predicate symbol for the relationBPlusTree<long[],TupleBuffer> getSortedIndex(int[] indexedpositions) Get a sorted index given by the argument positions in indexed positions (if it already exists).booleanmay relation contain duplicates?booleanbooleanhasSortedIndex(int[] indexedPositions) booleanisDirectEncoded(int i) are all values at argument i direct encodedbooleanisEmpty()Is the relation empty?long[]isOverwrittenByTuple(long[] tuple) returns tuple which is overwritten by tuplebooleanIs the relation persistent?booleanIs the relation temporary only?longreturns the time of last modificationbooleanMight there be duplicates?voidopen()long[]overwriteTuple(long[] tuple) Overwrite last argument of tuple.overwriteTuple(TupleBuffer tuple) Overwrite last argument of tuple.voidreadBinaryFromBackup(String filepath) read tuples from a binary backup filevoidreadBinaryRewrite(String datafilepath) read binary tuple file into empty!voidreadTupleFile(String datafilepath) read tuples from a file in binary formvoidregisterListener(RelationListener listener) register a listener for adding, removing, modifying tuplesbooleanremoveTuple(int tuple) remove a tuple from the relationbooleanremoveTuple(long[] tuple) remove a tuple from the relationbooleanremoveTuple(TupleBuffer tuple) remove a tuple from the relationbooleansearchForRecord(long record) voidselect()initializelongsize()returns the number of tuples in relationlongreturn number of bytes used in main memory.voidtoString()voidbegin transactionvoidcommit last changesvoidrbort last changesvoidadd all tuples of R to thisvoidvoidvoidwriteBinary(String filepath) write tuples in binary form to filevoidwriteBinaryToBackup(String filepath) write tuples to a binary backup filevoidwriteBinaryWithGrounds(String filepath) write complete tuples to a binary file
-
Field Details
-
NODESIZE
public static int NODESIZEthe node size
-
-
Constructor Details
-
PersistentRelation
-
PersistentRelation
-
PersistentRelation
-
PersistentRelation
public PersistentRelation(FileName filename, String workdir, String edbdir, String logDir, TupleStore tupleStore, boolean temporary, boolean compress)
-
-
Method Details
-
getName
Description copied from interface:Relationget a unique name of the relation -
getGrounds
public long[] getGrounds()get ground arguments, which are ground in all tuples- Specified by:
getGroundsin interfaceRelation- Returns:
-
checkSanity
check sanity of persistent relation- Specified by:
checkSanityin interfaceRelationshadow- , check in shadow tree- Returns:
- Throws:
IOExceptionEDBException
-
count
- Throws:
IOExceptionEDBException
-
isTemporary
public boolean isTemporary()Description copied from interface:BaseRelationIs the relation temporary only?- Specified by:
isTemporaryin interfaceBaseRelation- Returns:
- is the relation persistent
-
sizeInBytes
public long sizeInBytes()return number of bytes used in main memory. Used for cache management- Specified by:
sizeInBytesin interfaceBaseRelation- Returns:
- approximate number of size in bytes
-
getDataFilePath
Description copied from interface:Relationget standard path for binary file- Specified by:
getDataFilePathin interfaceRelation- Returns:
-
getTreeFilePath
-
getPrimaryKey
-
getPredicateSymbol
Description copied from interface:Relationreturns the predicate symbol for the relation- Specified by:
getPredicateSymbolin interfaceRelation- Returns:
-
getFilename
Description copied from interface:Relationreturns the file name for the relation- Specified by:
getFilenamein interfaceRelation- Returns:
-
getFileName
-
create
- Throws:
IOExceptionEDBException
-
open
- Throws:
IOExceptionEDBException
-
readBinaryRewrite
read binary tuple file into empty! relation.
Rewrite tuple file to eliminate duplicates- Parameters:
datafilepath-- Throws:
IOExceptionEDBException
-
readTupleFile
Description copied from interface:BaseRelationread tuples from a file in binary form- Specified by:
readTupleFilein interfaceBaseRelation- Specified by:
readTupleFilein interfaceRelation- Parameters:
datafilepath- , the file path to read from- Throws:
IOExceptionEDBException
-
getBulkLoadConsumer
- Throws:
IOExceptionEDBException
-
closeBulkLoad
- Throws:
IOExceptionEDBException
-
getIterativeLoadConsumer
public com.semedy.reasoner.edb.persistentstore.PersistentRelation.IterativeLoadConsumer getIterativeLoadConsumer() throws EDBException, IOException- Throws:
EDBExceptionIOException
-
close
Description copied from interface:BaseRelationClose the relation. Must be called to finalize the relation correctly- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceBaseRelation- Specified by:
closein interfaceCloseable- Throws:
IOException
-
flush
Description copied from interface:BaseRelationFlush the relation. Must be called to finalize the relation correctly- Specified by:
flushin interfaceBaseRelation- Throws:
IOExceptionEDBException
-
delete
Description copied from interface:Relationremove all tuples and release files- Specified by:
deletein interfaceRelation- Throws:
IOException
-
forceClose
Force closing (instead of closing is blocked)- Throws:
IOExceptionEDBException
-
forceDelete
Force deleting (instead of deleting is blocked)- Throws:
IOException
-
blockClosingNDeleting
public void blockClosingNDeleting() -
clear
Description copied from interface:BaseRelationremove all tuples- Specified by:
clearin interfaceBaseRelation- Throws:
IOExceptionEDBException
-
writeBinary
Description copied from interface:BaseRelationwrite tuples in binary form to file- Specified by:
writeBinaryin interfaceBaseRelation- Specified by:
writeBinaryin interfaceRelation- Throws:
IOExceptionEDBException
-
writeBinaryWithGrounds
Description copied from interface:Relationwrite complete tuples to a binary file- Specified by:
writeBinaryWithGroundsin interfaceRelation- Throws:
IOExceptionEDBException
-
writeBinaryToBackup
Description copied from interface:Relationwrite tuples to a binary backup file- Specified by:
writeBinaryToBackupin interfaceRelation- Throws:
IOExceptionEDBException
-
readBinaryFromBackup
Description copied from interface:Relationread tuples from a binary backup file- Specified by:
readBinaryFromBackupin interfaceRelation- Throws:
IOExceptionEDBException
-
addIndex
-
writeBinary
- Throws:
IOExceptionEDBException
-
createSortedIndex
Description copied from interface:BaseRelationret or create a sorted index given by the argument positions in indexed positions- Specified by:
createSortedIndexin interfaceBaseRelation- Returns:
- Throws:
IOExceptionEDBException
-
checkNumbers
- Throws:
EDBExceptionIOException
-
transactionBegin
Description copied from interface:Relationbegin transaction- Specified by:
transactionBeginin interfaceRelation- Throws:
EDBExceptionIOException
-
transactionCommit
Description copied from interface:Relationcommit last changes- Specified by:
transactionCommitin interfaceRelation- Throws:
EDBExceptionIOException
-
transactionRollback
Description copied from interface:Relationrbort last changes- Specified by:
transactionRollbackin interfaceRelation- Throws:
EDBExceptionIOException
-
hasSortedIndex
public boolean hasSortedIndex(int[] indexedPositions) -
getUniqueKey
-
getArity
public int getArity()Description copied from interface:BaseRelationreturns the arity of the relation- Specified by:
getArityin interfaceBaseRelation- Returns:
- arity of relation
-
size
public long size()Description copied from interface:BaseRelationreturns the number of tuples in relation- Specified by:
sizein interfaceBaseRelation- Returns:
- number of tuples in relation
-
isEmpty
Description copied from interface:BaseRelationIs the relation empty?- Specified by:
isEmptyin interfaceBaseRelation- Returns:
- relation is empty
- Throws:
IOException
-
getNumberOfDifferentValues
Description copied from interface:RelationReturns the number of different values at the argument positions.
Used for statistics.- Specified by:
getNumberOfDifferentValuesin interfaceRelation- Parameters:
position- , argument position- Returns:
- Throws:
EDBExceptionIOException
-
getNumberOfDifferentValues
Description copied from interface:RelationReturns the number of values occurring at the argument positions
Used for statistics- Specified by:
getNumberOfDifferentValuesin interfaceRelation- Parameters:
position- , argument positionvalue- , the concrete value- Returns:
- Throws:
EDBExceptionIOException
-
getNumberOfMatchingTuples
public long getNumberOfMatchingTuples(int[] arguments, long[] values) throws IOException, EDBException - Throws:
IOExceptionEDBException
-
getNumberOfTuples
- Throws:
IOExceptionEDBException
-
removeTuple
Description copied from interface:BaseRelationremove a tuple from the relation- Specified by:
removeTuplein interfaceBaseRelation- Parameters:
tuple- , tuple to be removed- Returns:
- true, if tuple has been removed
- Throws:
IOExceptionEDBException
-
overwriteTuple
Overwrite last argument of tuple.
First arguments are unique keys for tuple
Especially useful for triples [subject,predicate,object]
and object is changed- Specified by:
overwriteTuplein interfaceBaseRelation- Parameters:
tuple-- Returns:
- overwritten tuple
- Throws:
IOExceptionEDBException
-
overwriteTuple
Description copied from interface:BaseRelationOverwrite last argument of tuple.
First arguments are unique keys for tuple
Especially useful for triples [subject,predicate,object]
and object is changed- Specified by:
overwriteTuplein interfaceBaseRelation- Parameters:
tuple- , overwrite tuple- Returns:
- the overwritten tuple
- Throws:
IOExceptionEDBException
-
isOverwrittenByTuple
returns tuple which is overwritten by tuple- Specified by:
isOverwrittenByTuplein interfaceBaseRelation- Returns:
- Throws:
IOException
-
removeTuple
Description copied from interface:BaseRelationremove a tuple from the relation- Specified by:
removeTuplein interfaceBaseRelation- Parameters:
tuple- , tuple to be removed- Returns:
- true, if tuple has been removed
- Throws:
IOExceptionEDBException
-
containsTuple
Description copied from interface:BaseRelationIs tuple contained in relation?- Specified by:
containsTuplein interfaceBaseRelation- Parameters:
tuple- to be checked- Returns:
- tuple is contained
- Throws:
IOException
-
containsTuple
Description copied from interface:BaseRelationIs tuple contained in relation?- Specified by:
containsTuplein interfaceBaseRelation- Parameters:
tuple- to be checked- Returns:
- tuple is contained
- Throws:
IOException
-
containsTuple
Description copied from interface:BaseRelationIs tuple contained in relation?- Specified by:
containsTuplein interfaceBaseRelation- Parameters:
tpl- to be checked- Returns:
- tuple is contained
- Throws:
IOException
-
searchForRecord
- Throws:
IOException
-
bugLogMessage
- Throws:
EDBExceptionIOException
-
addTuple
Description copied from interface:BaseRelationadd a tuple to the relation- Specified by:
addTuplein interfaceBaseRelation- Parameters:
tuple- the tuple to add- Returns:
- tuple has been added
- Throws:
IOExceptionEDBException
-
addTuple
Description copied from interface:BaseRelationadd a tuple to the relation- Specified by:
addTuplein interfaceBaseRelation- Parameters:
tuple- the tuple to add- Returns:
- tuple has been added
- Throws:
IOExceptionEDBException
-
elements
Description copied from interface:BaseRelationreturns an enumerator for all tuples- Specified by:
elementsin interfaceBaseRelation- Returns:
- returns enumerator for tuples
- Throws:
IOException
-
createIndex
Description copied from interface:BaseRelationGet or create a simple (not sorted index) by the argument positions in indexed positions.- Specified by:
createIndexin interfaceBaseRelation- Parameters:
indexedpositions- , positions which are indexed- Returns:
- index
- Throws:
IOExceptionEDBException
-
getIndex
Description copied from interface:BaseRelationGet an index given by the argument positions in indexed positions (if it already exists).
Returns null if it does not exist.- Specified by:
getIndexin interfaceBaseRelation- Parameters:
indexedpositions- the indexed positions- Returns:
- the corresponding index or
nullif none is available
-
getSortedIndex
Description copied from interface:BaseRelationGet a sorted index given by the argument positions in indexed positions (if it already exists).
Returns null if it does not exist.- Specified by:
getSortedIndexin interfaceBaseRelation- Parameters:
indexedpositions- the indexed positions- Returns:
- the corresponding index or
nullif none is available
-
addTuple
Description copied from interface:BaseRelationadd a tuple to the relation- Specified by:
addTuplein interfaceBaseRelation- Parameters:
tuple- the tuple to add- Returns:
- tuple has been added
- Throws:
IOExceptionEDBException
-
removeTuple
Description copied from interface:BaseRelationremove a tuple from the relation- Specified by:
removeTuplein interfaceBaseRelation- Parameters:
tuple- , address of tuple in tuple store- Returns:
- true, if tuple has been removed
- Throws:
IOExceptionEDBException
-
toString
-
getInputBuffer
Description copied from interface:BaseRelationget an input buffer for relation- Specified by:
getInputBufferin interfaceBaseRelation- Returns:
- a tuple store which serves as buffer for input tuples
-
isPersistent
public boolean isPersistent()Description copied from interface:BaseRelationIs the relation persistent?- Specified by:
isPersistentin interfaceBaseRelation- Returns:
- is the relation persistent
-
getCacheInfo
Description copied from interface:BaseRelationget the caching info- Specified by:
getCacheInfoin interfaceBaseRelation- Returns:
- object containing caching info
-
getMinValue
Description copied from interface:BaseRelationreturns the minimal value at that argument position- Specified by:
getMinValuein interfaceBaseRelation- Parameters:
argument- , argument position @return, minimal value- Throws:
IOException
-
getMaxValue
Description copied from interface:BaseRelationreturns the maximal value at that argument position- Specified by:
getMaxValuein interfaceBaseRelation- Parameters:
argument- , argument position- Returns:
- max value at argument position
- Throws:
IOException
-
select
Description copied from interface:BaseRelationinitialize- Specified by:
selectin interfaceBaseRelation- Specified by:
selectin interfaceRelation- Throws:
IOException
-
getIdentifier
Description copied from interface:BaseRelationreturns a unique identifier for the relation- Specified by:
getIdentifierin interfaceBaseRelation- Returns:
- unique identifier for relation
-
unionRelation
- Throws:
IOExceptionEDBException
-
subtractRelation
- Throws:
IOExceptionEDBException
-
deSelect
Description copied from interface:Relationrelease ressources because relation is currently not used- Specified by:
deSelectin interfaceRelation- Throws:
IOException
-
lastModificationTime
public long lastModificationTime()Description copied from interface:BaseRelationreturns the time of last modification- Specified by:
lastModificationTimein interfaceBaseRelation- Specified by:
lastModificationTimein interfaceRelation- Returns:
- time of last modification
-
mayContainDuplicates
public boolean mayContainDuplicates()Description copied from interface:BaseRelationMight there be duplicates?- Specified by:
mayContainDuplicatesin interfaceBaseRelation- Returns:
- , might there be duplicates in relation
-
isDirectEncoded
public boolean isDirectEncoded(int i) Description copied from interface:BaseRelationare all values at argument i direct encoded- Specified by:
isDirectEncodedin interfaceBaseRelation- Parameters:
i- , argument index- Returns:
-
getDirectEncodedType
public int getDirectEncodedType(int i) Description copied from interface:BaseRelationget the type of the direct encoded argument- Specified by:
getDirectEncodedTypein interfaceBaseRelation- Returns:
-
hasIndices
public boolean hasIndices() -
registerListener
Description copied from interface:BaseRelationregister a listener for adding, removing, modifying tuples- Specified by:
registerListenerin interfaceBaseRelation
-
union
Description copied from interface:BaseRelationadd all tuples of R to this- Specified by:
unionin interfaceBaseRelation- Throws:
IOExceptionEDBException
-
hasDuplicates
public boolean hasDuplicates()Description copied from interface:BaseRelationmay relation contain duplicates?- Specified by:
hasDuplicatesin interfaceBaseRelation- Returns:
-
getInternalArity
public int getInternalArity()Description copied from interface:BaseRelationreturns the internal arity of tuples- Specified by:
getInternalArityin interfaceBaseRelation- Returns:
-
elements
Description copied from interface:BaseRelationreturns an filteres enumerator for all tuples- Specified by:
elementsin interfaceBaseRelation- Returns:
- returns enumerator for tuples
- Throws:
IOExceptionEDBException
-