Package com.semedy.reasoner.edb.ramstore
Class MixedRelation
java.lang.Object
com.semedy.reasoner.edb.ramstore.MainMemoryRelation
com.semedy.reasoner.edb.ramstore.MixedRelation
- All Implemented Interfaces:
BaseRelation
,Relation
,CacheUnit
- Direct Known Subclasses:
MainMemorySubRelation
Represents a mixed relation, i.e. tuples are stored persistent and in main memory.
Used to cache tuples from persistent storage model. Writes through, i.e.
tuples added or removed are also removed in persistent part.
For reading and reasoning the main memory part is used. Tuples are always copied from persistent
part to main memory part and not vice versa (e.g. for readBinary tuples are read into persistent
part and then copied into the main memory part, the same with setPersistentRelation
Used to cache tuples from persistent storage model. Writes through, i.e.
tuples added or removed are also removed in persistent part.
For reading and reasoning the main memory part is used. Tuples are always copied from persistent
part to main memory part and not vice versa (e.g. for readBinary tuples are read into persistent
part and then copied into the main memory part, the same with setPersistentRelation
- Author:
- angele
-
Field Summary
Fields inherited from class com.semedy.reasoner.edb.ramstore.MainMemoryRelation
_baseRelation
-
Constructor Summary
ConstructorDescriptionMixedRelation
(PersistentRelation baseRelation) MixedRelation
(String name, int arity, long[] grounds) -
Method Summary
Modifier and TypeMethodDescriptionboolean
addTuple
(long[] tuple) add a tuple to the relationboolean
addTuple
(TupleBuffer buf) add a tuple to the relationboolean
checkSanity
(String message, boolean shadow) check the sanity of a relationvoid
clear()
remove all tuplesvoid
close()
Close the relation.long
count()
void
delete()
remove all tuples and release filesvoid
destroy()
free up ressources at the end (CacheManager.clear)void
flush()
Flush the relation.get standard path for binary filegetLast()
long
getMaxValue
(int argument) returns the maximal value at that argument positionlong
getMinValue
(int argument) returns the minimal value at that argument positiongetNext()
long
getNumberOfDifferentValues
(int argument) Returns the number of different values at the argument positions.long
getNumberOfDifferentValues
(int argument, long value) Returns the number of values occurring at the argument positions
Used for statisticsget the persistent relation behind itboolean
isEmpty()
Is the relation empty?boolean
is this unit releasablevoid
readTupleFile
(String filepath) read tuples from a (compressed) binary filevoid
release()
Cache management calls this method to release the cache unit.void
remove()
boolean
removeTuple
(long[] buf) remove a tuple from the relationboolean
removeTuple
(TupleBuffer buf) remove a tuple from the relationvoid
select()
intialize the use: the tuples are copied from the persistent part to the main memory partvoid
void
pointers in a list for cache managementvoid
setPersistentRelation
(PersistentRelation persistentRelation) adds the persistent partlong
size()
returns the number of tuples in relationlong
size in bytes, usded for cache managementtoString()
void
touch()
touch a cache unit.void
begin transactionvoid
commit last changesvoid
rbort last changesMethods inherited from class com.semedy.reasoner.edb.ramstore.MainMemoryRelation
addSubRelation, addTuple, containsTuple, containsTuple, containsTuple, createIndex, createSortedIndex, deSelect, elements, elements, getArity, getCacheInfo, getDirectEncodedType, getFilename, getGrounds, getIdentifier, getIndex, getInputBuffer, getInternalArity, getName, getPredicateSymbol, getSortedIndex, getTupleStore, getValues, hasDuplicates, isDirectEncoded, isOverwrittenByTuple, isPersistent, isTemporary, lastModificationTime, mayContainDuplicates, overwriteTuple, overwriteTuple, readBinaryFromBackup, registerListener, removeTuple, union, writeBinary, writeBinaryToBackup, writeBinaryWithGrounds
-
Constructor Details
-
MixedRelation
-
MixedRelation
- Parameters:
baseRelation
-
-
-
Method Details
-
count
- Throws:
EDBException
IOException
-
getNumberOfDifferentValues
Description copied from interface:Relation
Returns the number of different values at the argument positions.
Used for statistics.- Specified by:
getNumberOfDifferentValues
in interfaceRelation
- Overrides:
getNumberOfDifferentValues
in classMainMemoryRelation
- Parameters:
argument
- , argument position- Returns:
- Throws:
EDBException
IOException
-
getNumberOfDifferentValues
Description copied from interface:Relation
Returns the number of values occurring at the argument positions
Used for statistics- Specified by:
getNumberOfDifferentValues
in interfaceRelation
- Overrides:
getNumberOfDifferentValues
in classMainMemoryRelation
- Parameters:
argument
- , argument positionvalue
- , the concrete value- Returns:
- Throws:
EDBException
IOException
-
getMinValue
Description copied from interface:BaseRelation
returns the minimal value at that argument position- Specified by:
getMinValue
in interfaceBaseRelation
- Overrides:
getMinValue
in classMainMemoryRelation
- Parameters:
argument
- , argument position @return, minimal value- Throws:
IOException
EDBException
-
getMaxValue
Description copied from interface:BaseRelation
returns the maximal value at that argument position- Specified by:
getMaxValue
in interfaceBaseRelation
- Overrides:
getMaxValue
in classMainMemoryRelation
- Parameters:
argument
- , argument position- Returns:
- max value at argument position
- Throws:
IOException
EDBException
-
isEmpty
Description copied from interface:BaseRelation
Is the relation empty?- Specified by:
isEmpty
in interfaceBaseRelation
- Overrides:
isEmpty
in classMainMemoryRelation
- Returns:
- relation is empty
- Throws:
IOException
-
setPersistentRelation
adds the persistent part- Parameters:
persistentRelation
-
-
getPersistentRelation
get the persistent relation behind it- Returns:
-
select
intialize the use: the tuples are copied from the persistent part to the main memory part- Specified by:
select
in interfaceBaseRelation
- Specified by:
select
in interfaceRelation
- Overrides:
select
in classMainMemoryRelation
- Throws:
EDBException
IOException
-
size
Description copied from interface:BaseRelation
returns the number of tuples in relation- Specified by:
size
in interfaceBaseRelation
- Overrides:
size
in classMainMemoryRelation
- Returns:
- number of tuples in relation
- Throws:
IOException
EDBException
-
addTuple
Description copied from interface:BaseRelation
add a tuple to the relation- Specified by:
addTuple
in interfaceBaseRelation
- Overrides:
addTuple
in classMainMemoryRelation
- Parameters:
buf
- the tuple to add- Returns:
- tuple has been added
- Throws:
IOException
EDBException
-
addTuple
Description copied from interface:BaseRelation
add a tuple to the relation- Specified by:
addTuple
in interfaceBaseRelation
- Overrides:
addTuple
in classMainMemoryRelation
- Parameters:
tuple
- the tuple to add- Returns:
- tuple has been added
- Throws:
IOException
EDBException
-
removeTuple
Description copied from interface:BaseRelation
remove a tuple from the relation- Specified by:
removeTuple
in interfaceBaseRelation
- Overrides:
removeTuple
in classMainMemoryRelation
- Parameters:
buf
- , tuple to be removed- Returns:
- true, if tuple has been removed
- Throws:
IOException
EDBException
-
removeTuple
Description copied from interface:BaseRelation
remove a tuple from the relation- Specified by:
removeTuple
in interfaceBaseRelation
- Overrides:
removeTuple
in classMainMemoryRelation
- Parameters:
buf
- , tuple to be removed- Returns:
- true, if tuple has been removed
- Throws:
IOException
EDBException
-
clear
Description copied from interface:BaseRelation
remove all tuples- Specified by:
clear
in interfaceBaseRelation
- Overrides:
clear
in classMainMemoryRelation
- Throws:
IOException
EDBException
-
delete
Description copied from interface:Relation
remove all tuples and release files- Specified by:
delete
in interfaceRelation
- Overrides:
delete
in classMainMemoryRelation
- Throws:
IOException
-
readTupleFile
Description copied from interface:Relation
read tuples from a (compressed) binary file- Specified by:
readTupleFile
in interfaceBaseRelation
- Specified by:
readTupleFile
in interfaceRelation
- Overrides:
readTupleFile
in classMainMemoryRelation
- Parameters:
filepath
- , the file path to read from- Throws:
IOException
EDBException
-
close
Description copied from interface:BaseRelation
Close the relation. Must be called to finalize the relation correctly- Specified by:
close
in interfaceBaseRelation
- Overrides:
close
in classMainMemoryRelation
- Throws:
IOException
-
flush
Description copied from interface:BaseRelation
Flush the relation. Must be called to finalize the relation correctly- Specified by:
flush
in interfaceBaseRelation
- Overrides:
flush
in classMainMemoryRelation
- Throws:
IOException
EDBException
-
touch
touch a cache unit.
this means for cache management that this unit
will be used and has a lower prio to be released- Specified by:
touch
in interfaceCacheUnit
- Throws:
EDBException
IOException
-
setNext
pointers in a list for cache management -
getNext
-
setLast
-
getLast
-
release
Cache management calls this method to release the cache unit.- Specified by:
release
in interfaceCacheUnit
- Throws:
IOException
EDBException
-
isReleasable
public boolean isReleasable()is this unit releasable- Specified by:
isReleasable
in interfaceCacheUnit
- Returns:
-
sizeInBytes
public long sizeInBytes()Description copied from class:MainMemoryRelation
size in bytes, usded for cache management- Specified by:
sizeInBytes
in interfaceBaseRelation
- Specified by:
sizeInBytes
in interfaceCacheUnit
- Overrides:
sizeInBytes
in classMainMemoryRelation
- Returns:
- approximate number of size in bytes
-
remove
public void remove() -
destroy
public void destroy()Description copied from interface:CacheUnit
free up ressources at the end (CacheManager.clear) -
transactionRollback
Description copied from interface:Relation
rbort last changes- Specified by:
transactionRollback
in interfaceRelation
- Overrides:
transactionRollback
in classMainMemoryRelation
- Throws:
EDBException
IOException
-
transactionCommit
Description copied from interface:Relation
commit last changes- Specified by:
transactionCommit
in interfaceRelation
- Overrides:
transactionCommit
in classMainMemoryRelation
- Throws:
EDBException
IOException
-
checkSanity
Description copied from interface:Relation
check the sanity of a relation- Specified by:
checkSanity
in interfaceRelation
- Overrides:
checkSanity
in classMainMemoryRelation
shadow
- , check in shadow tree- Throws:
IOException
EDBException
-
getDataFilePath
Description copied from interface:Relation
get standard path for binary file- Specified by:
getDataFilePath
in interfaceRelation
- Overrides:
getDataFilePath
in classMainMemoryRelation
- Returns:
-
transactionBegin
Description copied from interface:Relation
begin transaction- Specified by:
transactionBegin
in interfaceRelation
- Overrides:
transactionBegin
in classMainMemoryRelation
- Throws:
EDBException
IOException
-
toString
- Overrides:
toString
in classMainMemoryRelation
-