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 TypeMethodDescriptionboolean
addTuple
(int tuple) add a tuple to the relationboolean
addTuple
(long[] tuple) add a tuple to the relationboolean
addTuple
(TupleBuffer tuple) add a tuple to the relationvoid
clear()
remove all tuplesvoid
close()
Close the relation.boolean
containsTuple
(int tuple) Is tuple contained in relation?boolean
containsTuple
(long[] tuple) Is tuple contained in relation?boolean
containsTuple
(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 tuplesvoid
flush()
Flush the relation.int
getArity()
returns the arity of the relationget the caching infoint
getDirectEncodedType
(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 relationint
returns the internal arity of tupleslong
getMaxValue
(int argument) returns the maximal value at that argument positionlong
getMinValue
(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).boolean
may relation contain duplicates?boolean
isDirectEncoded
(int i) are all values at argument i direct encodedboolean
isEmpty()
Is the relation empty?long[]
isOverwrittenByTuple
(long[] tuple) returns the tuple which will be overwritten by tuple.boolean
Is the relation persistent?boolean
Is the relation temporary only?long
returns the time of last modificationboolean
Might there be duplicates?long[]
overwriteTuple
(long[] tuple) Overwrite last argument of tuple.overwriteTuple
(TupleBuffer tuple) Overwrite last argument of tuple.void
readTupleFile
(String filepath) read tuples from a file in binary formvoid
registerListener
(RelationListener listener) register a listener for adding, removing, modifying tuplesboolean
removeTuple
(int tuple) remove a tuple from the relationboolean
removeTuple
(long[] tuple) remove a tuple from the relationboolean
removeTuple
(TupleBuffer tuple) remove a tuple from the relationvoid
select()
initializelong
size()
returns the number of tuples in relationlong
Return the size in bytes in main memory.void
add all tuples of R to thisvoid
writeBinary
(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:
EDBException
IOException
-
elements
returns an enumerator for all tuples- Returns:
- returns enumerator for tuples
- Throws:
IOException
EDBException
-
elements
returns an filteres enumerator for all tuples- Returns:
- returns enumerator for tuples
- Throws:
IOException
EDBException
-
size
returns the number of tuples in relation- Returns:
- number of tuples in relation
- Throws:
IOException
EDBException
-
createSortedIndex
ret or create a sorted index given by the argument positions in indexed positions- Parameters:
indexedpositions
-- Returns:
- Throws:
IOException
EDBException
-
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
null
if 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:
IOException
EDBException
-
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
null
if none is available
-
getIdentifier
String getIdentifier()returns a unique identifier for the relation- Returns:
- unique identifier for relation
-
clear
remove all tuples- Throws:
IOException
EDBException
-
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:
IOException
EDBException
-
flush
Flush the relation. Must be called to finalize the relation correctly- Throws:
IOException
EDBException
-
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:
IOException
EDBException
-
addTuple
add a tuple to the relation- Parameters:
tuple
- the tuple to add- Returns:
- tuple has been added
- Throws:
IOException
EDBException
-
addTuple
add a tuple to the relation- Parameters:
tuple
- the tuple to add- Returns:
- tuple has been added
- Throws:
IOException
EDBException
-
removeTuple
remove a tuple from the relation- Parameters:
tuple
- , address of tuple in tuple store- Returns:
- true, if tuple has been removed
- Throws:
IOException
EDBException
-
removeTuple
remove a tuple from the relation- Parameters:
tuple
- , tuple to be removed- Returns:
- true, if tuple has been removed
- Throws:
IOException
EDBException
-
removeTuple
remove a tuple from the relation- Parameters:
tuple
- , tuple to be removed- Returns:
- true, if tuple has been removed
- Throws:
IOException
EDBException
-
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:
IOException
EDBException
-
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:
IOException
EDBException
-
isOverwrittenByTuple
returns the tuple which will be overwritten by tuple.- Parameters:
tuple
-- Returns:
- Throws:
IOException
EDBException
-
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:
IOException
EDBException
-
readTupleFile
read tuples from a file in binary form- Parameters:
filepath
- , the file path to read from- Throws:
IOException
EDBException
-
getMinValue
returns the minimal value at that argument position- Parameters:
argument
- , argument position @return, minimal value- Throws:
IOException
EDBException
-
getMaxValue
returns the maximal value at that argument position- Parameters:
argument
- , argument position- Returns:
- max value at argument position
- Throws:
IOException
EDBException
-
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:
IOException
EDBException
-
hasDuplicates
boolean hasDuplicates()may relation contain duplicates?- Returns:
-