Package com.semedy.reasoner.api.edb
Interface BaseRelation
- All Known Subinterfaces:
Relation
- All Known Implementing Classes:
CrossProductBaseRelation,MainMemoryBaseRelation,MainMemoryRelation,MainMemorySubRelation,MixedRelation,OneToOneBaseRelation,PersistentRelation,ReasoningMonitorRelation,RelationAdapter
public interface BaseRelation
A relation is a set of tuples, i.e. a container for facts.
Facts are encoded which means that a relation contains tuples of long codes.
The terms for the codes may be found in the symbol table.
Facts are encoded which means that a relation contains tuples of long codes.
The terms for the codes may be found in the symbol table.
- Author:
- angele
-
Method Summary
Modifier and TypeMethodDescriptionbooleanaddTuple(int tuple) add a tuple to the relationbooleanaddTuple(long[] tuple) add a tuple to the relationbooleanaddTuple(TupleBuffer tuple) 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 infointgetDirectEncodedType(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?booleanisDirectEncoded(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 tuplesbooleanremoveTuple(int tuple) remove a tuple from the relationbooleanremoveTuple(long[] tuple) remove a tuple from the relationbooleanremoveTuple(TupleBuffer tuple) remove a tuple from the relationvoidselect()initializelongsize()returns the number of tuples in relationlongReturn the size in bytes in main memory.voidadd all tuples of R to thisvoidwriteBinary(String filepath) write tuples in binary form to file
-
Method Details
-
getArity
int getArity()returns the arity of the relation- Returns:
- arity of relation
-
getInternalArity
int getInternalArity()returns the internal arity of tuples- Returns:
-
select
initialize- Throws:
EDBExceptionIOException
-
elements
returns an enumerator for all tuples- Returns:
- returns enumerator for tuples
- Throws:
IOExceptionEDBException
-
elements
returns an filteres enumerator for all tuples- Returns:
- returns enumerator for tuples
- Throws:
IOExceptionEDBException
-
size
returns the number of tuples in relation- Returns:
- number of tuples in relation
- Throws:
IOExceptionEDBException
-
createSortedIndex
ret or create a sorted index given by the argument positions in indexed positions- Parameters:
indexedpositions-- Returns:
- Throws:
IOExceptionEDBException
-
getSortedIndex
Get a sorted index given by the argument positions in indexed positions (if it already exists).
Returns null if it does not exist.- Parameters:
indexedpositions- the indexed positions- Returns:
- the corresponding index or
nullif none is available
-
createIndex
Get or create a simple (not sorted index) by the argument positions in indexed positions.- Parameters:
indexedpositions- , positions which are indexed- Returns:
- index
- Throws:
IOExceptionEDBException
-
getIndex
Get an index given by the argument positions in indexed positions (if it already exists).
Returns null if it does not exist.- Parameters:
indexedpositions- the indexed positions- Returns:
- the corresponding index or
nullif none is available
-
getIdentifier
String getIdentifier()returns a unique identifier for the relation- Returns:
- unique identifier for relation
-
clear
remove all tuples- Throws:
IOExceptionEDBException
-
isEmpty
Is the relation empty?- Returns:
- relation is empty
- Throws:
IOException
-
isPersistent
boolean isPersistent()Is the relation persistent?- Returns:
- is the relation persistent
-
isTemporary
boolean isTemporary()Is the relation temporary only?- Returns:
- is the relation persistent
-
close
Close the relation. Must be called to finalize the relation correctly- Throws:
IOExceptionEDBException
-
flush
Flush the relation. Must be called to finalize the relation correctly- Throws:
IOExceptionEDBException
-
getCacheInfo
CacheInfo getCacheInfo()get the caching info- Returns:
- object containing caching info
-
containsTuple
Is tuple contained in relation?- Parameters:
tuple- to be checked- Returns:
- tuple is contained
- Throws:
IOException
-
containsTuple
Is tuple contained in relation?- Parameters:
tuple- to be checked- Returns:
- tuple is contained
- Throws:
IOException
-
containsTuple
Is tuple contained in relation?- Parameters:
tuple- to be checked- Returns:
- tuple is contained
- Throws:
IOException
-
addTuple
add a tuple to the relation- Parameters:
tuple- the tuple to add- Returns:
- tuple has been added
- Throws:
IOExceptionEDBException
-
addTuple
add a tuple to the relation- Parameters:
tuple- the tuple to add- Returns:
- tuple has been added
- Throws:
IOExceptionEDBException
-
addTuple
add a tuple to the relation- Parameters:
tuple- the tuple to add- Returns:
- tuple has been added
- Throws:
IOExceptionEDBException
-
removeTuple
remove a tuple from the relation- Parameters:
tuple- , address of tuple in tuple store- Returns:
- true, if tuple has been removed
- Throws:
IOExceptionEDBException
-
removeTuple
remove a tuple from the relation- Parameters:
tuple- , tuple to be removed- Returns:
- true, if tuple has been removed
- Throws:
IOExceptionEDBException
-
removeTuple
remove a tuple from the relation- 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- Parameters:
tuple- , overwrite tuple- Returns:
- the overwritten tuple
- 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- Parameters:
tuple- , overwrite tuple- Returns:
- the overwritten tuple
- Throws:
IOExceptionEDBException
-
isOverwrittenByTuple
returns the tuple which will be overwritten by tuple.- Parameters:
tuple-- Returns:
- Throws:
IOExceptionEDBException
-
getInputBuffer
TupleStore getInputBuffer()get an input buffer for relation- Returns:
- a tuple store which serves as buffer for input tuples
-
sizeInBytes
long sizeInBytes()Return the size in bytes in main memory. Used for cache management- Returns:
- approximate number of size in bytes
-
writeBinary
write tuples in binary form to file- Parameters:
filepath-- Throws:
IOExceptionEDBException
-
readTupleFile
read tuples from a file in binary form- Parameters:
filepath- , the file path to read from- Throws:
IOExceptionEDBException
-
getMinValue
returns the minimal value at that argument position- Parameters:
argument- , argument position @return, minimal value- Throws:
IOExceptionEDBException
-
getMaxValue
returns the maximal value at that argument position- Parameters:
argument- , argument position- Returns:
- max value at argument position
- Throws:
IOExceptionEDBException
-
lastModificationTime
long lastModificationTime()returns the time of last modification- Returns:
- time of last modification
-
mayContainDuplicates
boolean mayContainDuplicates()Might there be duplicates?- Returns:
- , might there be duplicates in relation
-
isDirectEncoded
boolean isDirectEncoded(int i) are all values at argument i direct encoded- Parameters:
i- , argument index- Returns:
-
getDirectEncodedType
int getDirectEncodedType(int i) get the type of the direct encoded argument- Parameters:
i-- Returns:
-
registerListener
register a listener for adding, removing, modifying tuples- Parameters:
listener-
-
union
add all tuples of R to this- Parameters:
R-- Throws:
IOExceptionEDBException
-
hasDuplicates
boolean hasDuplicates()may relation contain duplicates?- Returns:
-