Package com.semedy.reasoner.edb.ramstore
Class MainMemoryBaseRelation
java.lang.Object
com.semedy.reasoner.edb.ramstore.MainMemoryBaseRelation
- All Implemented Interfaces:
BaseRelation
-
Constructor Summary
ConstructorsConstructorDescriptionMainMemoryBaseRelation(int arity, TupleStore tupleStore) MainMemoryBaseRelation(int arity, TupleStore tupleStore, boolean duplicates, ReasoningMonitor monitor) MainMemoryBaseRelation(int arity, TupleStore tupleStore, boolean duplicates, ReasoningMonitor monitor, boolean sorted) MainMemoryBaseRelation(int arity, TupleStore tupleStore, MainMemoryIndex primarykey, ReasoningMonitor monitor) -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddTuple(int tuple) add a tuple to the relationbooleanaddTuple(long[] t) add a tuple to the relationbooleanaddTuple(TupleBuffer terms) add a tuple to the relationvoidclear()remove all tuplesvoidclose()Close the relation.booleancontainsTuple(int tuple) Is tuple contained in relation?booleancontainsTuple(long[] tuple) Is tuple contained in relation?booleancontainsTuple(TupleBuffer tuple) Is tuple contained in relation?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 positionselements()returns an enumerator for all tupleselements(long[] filter) returns an filteres enumerator for all tuplesvoidflush()Flush the relation.intgetArity()returns the arity of the relationget the caching infoget checksum of 0th argumentintgetDirectEncodedType(int i) get the type of the direct encoded argumentreturns 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 tupleslonggetMaxValue(int argument) returns the maximal value at that argument positionlonggetMinValue(int argument) returns the minimal value at that argument positiongetSortedIndex(int[] indexedPositions) Get a sorted index given by the argument positions in indexed positions (if it already exists).booleanmay relation contain duplicates?booleanbooleanisDirectEncoded(int i) are all values at argument i direct encodedbooleanisEmpty()Is the relation empty?long[]isOverwrittenByTuple(long[] tuple) returns the tuple which will be overwritten by tuple.booleanIs the relation persistent?booleanIs the relation temporary only?longreturns the time of last modificationbooleanMight there be duplicates?long[]overwriteTuple(long[] tuple) Overwrite last argument of tuple.overwriteTuple(TupleBuffer tuple) Overwrite last argument of tuple.voidreadTupleFile(String filepath) read tuples from a file in binary formvoidregisterListener(RelationListener listener) register a listener for adding, removing, modifying tuplesvoidbooleanremoveTuple(int tuple) remove a tuple from the relationbooleanremoveTuple(long[] terms) remove a tuple from the relationbooleanremoveTuple(TupleBuffer terms) remove a tuple from the relationvoidselect()initializelongsize()returns the number of tuples in relationlongreturn number of bytes used in main memory.toString()voidadd all tuples of R to thisvoidwriteBinary(String filepath) write tuples in binary form to file
-
Constructor Details
-
MainMemoryBaseRelation
public MainMemoryBaseRelation(int arity, TupleStore tupleStore, boolean duplicates, ReasoningMonitor monitor) -
MainMemoryBaseRelation
-
MainMemoryBaseRelation
public MainMemoryBaseRelation(int arity, TupleStore tupleStore, boolean duplicates, ReasoningMonitor monitor, boolean sorted) -
MainMemoryBaseRelation
public MainMemoryBaseRelation(int arity, TupleStore tupleStore, MainMemoryIndex primarykey, ReasoningMonitor monitor)
-
-
Method Details
-
getChecksum
get checksum of 0th argument- Returns:
-
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
-
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
-
hasDuplicates
public boolean hasDuplicates()Description copied from interface:BaseRelationmay relation contain duplicates?- Specified by:
hasDuplicatesin interfaceBaseRelation- Returns:
-
getArity
public int getArity()Description copied from interface:BaseRelationreturns the arity of the relation- Specified by:
getArityin interfaceBaseRelation- Returns:
- arity of relation
-
elements
Description copied from interface:BaseRelationreturns an enumerator for all tuples- Specified by:
elementsin interfaceBaseRelation- Returns:
- returns enumerator for tuples
- Throws:
IOException
-
writeBinary
Description copied from interface:BaseRelationwrite tuples in binary form to file- Specified by:
writeBinaryin interfaceBaseRelation- Throws:
IOExceptionEDBException
-
readTupleFile
Description copied from interface:BaseRelationread tuples from a file in binary form- Specified by:
readTupleFilein interfaceBaseRelation- Parameters:
filepath- , the file path to read from- Throws:
IOExceptionEDBException
-
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
-
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
-
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:
t- the tuple to add- Returns:
- tuple has been added
- Throws:
IOException
-
addTuple
Description copied from interface:BaseRelationadd a tuple to the relation- Specified by:
addTuplein interfaceBaseRelation- Parameters:
terms- the tuple to add- Returns:
- tuple has been added
- Throws:
IOException
-
union
Description copied from interface:BaseRelationadd all tuples of R to this- Specified by:
unionin interfaceBaseRelation- 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
-
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
Description copied from interface:BaseRelationreturns the tuple which will be overwritten by tuple.- Specified by:
isOverwrittenByTuplein interfaceBaseRelation- Returns:
- Throws:
IOExceptionEDBException
-
removeTuple
Description copied from interface:BaseRelationremove a tuple from the relation- Specified by:
removeTuplein interfaceBaseRelation- Parameters:
terms- , tuple to be removed- Returns:
- true, if tuple has been removed
- Throws:
IOException
-
removeTuple
Description copied from interface:BaseRelationremove a tuple from the relation- Specified by:
removeTuplein interfaceBaseRelation- Parameters:
terms- , tuple to be removed- Returns:
- true, if tuple has been removed
- Throws:
IOException
-
removeTuple
public boolean removeTuple(int tuple) 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
-
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:
IOException
-
toString
-
clear
Description copied from interface:BaseRelationremove all tuples- Specified by:
clearin interfaceBaseRelation- Throws:
IOExceptionEDBException
-
isEmpty
Description copied from interface:BaseRelationIs the relation empty?- Specified by:
isEmptyin interfaceBaseRelation- Returns:
- relation is empty
- Throws:
IOException
-
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
-
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
-
close
public void close()Description copied from interface:BaseRelationClose the relation. Must be called to finalize the relation correctly- Specified by:
closein interfaceBaseRelation
-
getIdentifier
Description copied from interface:BaseRelationreturns a unique identifier for the relation- Specified by:
getIdentifierin interfaceBaseRelation- Returns:
- unique identifier for relation
-
lastModificationTime
public long lastModificationTime()Description copied from interface:BaseRelationreturns the time of last modification- Specified by:
lastModificationTimein interfaceBaseRelation- 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:
-
isTemporary
public boolean isTemporary()Description copied from interface:BaseRelationIs the relation temporary only?- Specified by:
isTemporaryin interfaceBaseRelation- Returns:
- is the relation persistent
-
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:
tuple- to be checked- Returns:
- tuple is contained
- Throws:
IOException
-
flush
public void flush()Description copied from interface:BaseRelationFlush the relation. Must be called to finalize the relation correctly- Specified by:
flushin interfaceBaseRelation
-
hasIndices
public boolean hasIndices() -
removeAllIndices
public void removeAllIndices() -
registerListener
Description copied from interface:BaseRelationregister a listener for adding, removing, modifying tuples- Specified by:
registerListenerin interfaceBaseRelation
-
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
-
select
public void select()Description copied from interface:BaseRelationinitialize- Specified by:
selectin interfaceBaseRelation
-