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
ConstructorsConstructorDescriptionMixedRelation(PersistentRelation baseRelation) MixedRelation(String name, int arity, long[] grounds) -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddTuple(long[] tuple) add a tuple to the relationbooleanaddTuple(TupleBuffer buf) add a tuple to the relationbooleancheckSanity(String message, boolean shadow) check the sanity of a relationvoidclear()remove all tuplesvoidclose()Close the relation.longcount()voiddelete()remove all tuples and release filesvoiddestroy()free up ressources at the end (CacheManager.clear)voidflush()Flush the relation.get standard path for binary filegetLast()longgetMaxValue(int argument) returns the maximal value at that argument positionlonggetMinValue(int argument) returns the minimal value at that argument positiongetNext()longgetNumberOfDifferentValues(int argument) Returns the number of different values at the argument positions.longgetNumberOfDifferentValues(int argument, long value) Returns the number of values occurring at the argument positions
Used for statisticsget the persistent relation behind itbooleanisEmpty()Is the relation empty?booleanis this unit releasablevoidreadTupleFile(String filepath) read tuples from a (compressed) binary filevoidrelease()Cache management calls this method to release the cache unit.voidremove()booleanremoveTuple(long[] buf) remove a tuple from the relationbooleanremoveTuple(TupleBuffer buf) remove a tuple from the relationvoidselect()intialize the use: the tuples are copied from the persistent part to the main memory partvoidvoidpointers in a list for cache managementvoidsetPersistentRelation(PersistentRelation persistentRelation) adds the persistent partlongsize()returns the number of tuples in relationlongsize in bytes, usded for cache managementtoString()voidtouch()touch a cache unit.voidbegin transactionvoidcommit last changesvoidrbort 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:
EDBExceptionIOException
-
getNumberOfDifferentValues
Description copied from interface:RelationReturns the number of different values at the argument positions.
Used for statistics.- Specified by:
getNumberOfDifferentValuesin interfaceRelation- Overrides:
getNumberOfDifferentValuesin classMainMemoryRelation- Parameters:
argument- , 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- Overrides:
getNumberOfDifferentValuesin classMainMemoryRelation- Parameters:
argument- , argument positionvalue- , the concrete value- Returns:
- Throws:
EDBExceptionIOException
-
getMinValue
Description copied from interface:BaseRelationreturns the minimal value at that argument position- Specified by:
getMinValuein interfaceBaseRelation- Overrides:
getMinValuein classMainMemoryRelation- Parameters:
argument- , argument position @return, minimal value- Throws:
IOExceptionEDBException
-
getMaxValue
Description copied from interface:BaseRelationreturns the maximal value at that argument position- Specified by:
getMaxValuein interfaceBaseRelation- Overrides:
getMaxValuein classMainMemoryRelation- Parameters:
argument- , argument position- Returns:
- max value at argument position
- Throws:
IOExceptionEDBException
-
isEmpty
Description copied from interface:BaseRelationIs the relation empty?- Specified by:
isEmptyin interfaceBaseRelation- Overrides:
isEmptyin 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:
selectin interfaceBaseRelation- Specified by:
selectin interfaceRelation- Overrides:
selectin classMainMemoryRelation- Throws:
EDBExceptionIOException
-
size
Description copied from interface:BaseRelationreturns the number of tuples in relation- Specified by:
sizein interfaceBaseRelation- Overrides:
sizein classMainMemoryRelation- Returns:
- number of tuples in relation
- Throws:
IOExceptionEDBException
-
addTuple
Description copied from interface:BaseRelationadd a tuple to the relation- Specified by:
addTuplein interfaceBaseRelation- Overrides:
addTuplein classMainMemoryRelation- Parameters:
buf- 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- Overrides:
addTuplein classMainMemoryRelation- 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- Overrides:
removeTuplein classMainMemoryRelation- Parameters:
buf- , tuple to be removed- Returns:
- true, if tuple has been removed
- Throws:
IOExceptionEDBException
-
removeTuple
Description copied from interface:BaseRelationremove a tuple from the relation- Specified by:
removeTuplein interfaceBaseRelation- Overrides:
removeTuplein classMainMemoryRelation- Parameters:
buf- , tuple to be removed- Returns:
- true, if tuple has been removed
- Throws:
IOExceptionEDBException
-
clear
Description copied from interface:BaseRelationremove all tuples- Specified by:
clearin interfaceBaseRelation- Overrides:
clearin classMainMemoryRelation- Throws:
IOExceptionEDBException
-
delete
Description copied from interface:Relationremove all tuples and release files- Specified by:
deletein interfaceRelation- Overrides:
deletein classMainMemoryRelation- Throws:
IOException
-
readTupleFile
Description copied from interface:Relationread tuples from a (compressed) binary file- Specified by:
readTupleFilein interfaceBaseRelation- Specified by:
readTupleFilein interfaceRelation- Overrides:
readTupleFilein classMainMemoryRelation- Parameters:
filepath- , the file path to read from- Throws:
IOExceptionEDBException
-
close
Description copied from interface:BaseRelationClose the relation. Must be called to finalize the relation correctly- Specified by:
closein interfaceBaseRelation- Overrides:
closein classMainMemoryRelation- Throws:
IOException
-
flush
Description copied from interface:BaseRelationFlush the relation. Must be called to finalize the relation correctly- Specified by:
flushin interfaceBaseRelation- Overrides:
flushin classMainMemoryRelation- Throws:
IOExceptionEDBException
-
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:
touchin interfaceCacheUnit- Throws:
EDBExceptionIOException
-
setNext
pointers in a list for cache management -
getNext
-
setLast
-
getLast
-
release
Cache management calls this method to release the cache unit.- Specified by:
releasein interfaceCacheUnit- Throws:
IOExceptionEDBException
-
isReleasable
public boolean isReleasable()is this unit releasable- Specified by:
isReleasablein interfaceCacheUnit- Returns:
-
sizeInBytes
public long sizeInBytes()Description copied from class:MainMemoryRelationsize in bytes, usded for cache management- Specified by:
sizeInBytesin interfaceBaseRelation- Specified by:
sizeInBytesin interfaceCacheUnit- Overrides:
sizeInBytesin classMainMemoryRelation- Returns:
- approximate number of size in bytes
-
remove
public void remove() -
destroy
public void destroy()Description copied from interface:CacheUnitfree up ressources at the end (CacheManager.clear) -
transactionRollback
Description copied from interface:Relationrbort last changes- Specified by:
transactionRollbackin interfaceRelation- Overrides:
transactionRollbackin classMainMemoryRelation- Throws:
EDBExceptionIOException
-
transactionCommit
Description copied from interface:Relationcommit last changes- Specified by:
transactionCommitin interfaceRelation- Overrides:
transactionCommitin classMainMemoryRelation- Throws:
EDBExceptionIOException
-
checkSanity
Description copied from interface:Relationcheck the sanity of a relation- Specified by:
checkSanityin interfaceRelation- Overrides:
checkSanityin classMainMemoryRelationshadow- , check in shadow tree- Throws:
IOExceptionEDBException
-
getDataFilePath
Description copied from interface:Relationget standard path for binary file- Specified by:
getDataFilePathin interfaceRelation- Overrides:
getDataFilePathin classMainMemoryRelation- Returns:
-
transactionBegin
Description copied from interface:Relationbegin transaction- Specified by:
transactionBeginin interfaceRelation- Overrides:
transactionBeginin classMainMemoryRelation- Throws:
EDBExceptionIOException
-
toString
- Overrides:
toStringin classMainMemoryRelation
-