Interface Reasoner
- All Known Implementing Classes:
ReasonerNotThreaded,ReasonerThreadedFactsPartitioning,ReasonerThreadedRulesPartitioning
public interface Reasoner
a reasoner performs the reasoning process
- Author:
- angele
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the reasoner.voidcompile(IntensionalDB idb, ExtensionalDB[] edbs, ReasoningMonitor monitor, SystemMonitor smonitor, boolean topdown, int maxNumberOfResults, boolean streamReasoning, boolean streamReasoningWithRetracts) compile rules for the reasoning processevaluate()starts evaluation and returns iterators for the results of the evaluationvoidStarts evaluation and feed the results into receiverStarts evaluation for several queries.voidIs called after reasoning process is finishedget queries after compilationReturns the reasoning symbol table used to create new symbols during reasoning
This reasoning symbol table is different to the base symbol table given by core.getSymbolTable()
To decode reasoning results always use this onevoidregister(InterruptFlag interruptFlag, List<EventResultReceiver> receiver, CoreReadLock edbReadLock) Register several queries for events caused by sensors or in case of
stream reasoning db caused by added facts.
Every time events from sensors arrive there might be one or more new results.
For every result receiver.receive is called
This is used for stream reasoningbooleanHave results contained whole edb relations?booleantest(Reader in, SymbolTable baseTable, ExternalDataTypeProvider datatypes, ExtensionalDB edb, boolean topdown, String path, BuiltinProvider builtinProvider, RewriterProvider rewriterProvider, Configuration config, Properties prp) Testing the evaluation.
-
Method Details
-
test
boolean test(Reader in, SymbolTable baseTable, ExternalDataTypeProvider datatypes, ExtensionalDB edb, boolean topdown, String path, BuiltinProvider builtinProvider, RewriterProvider rewriterProvider, Configuration config, Properties prp) throws ReasoningException, IOException, ReasoningException, InterruptedException, SemReasonerException Testing the evaluation.
The file contains rules and facts and solutions.
Solutions are given by the solutions predicate.
This method reads the file, stores the facts in an edb,
stores the rules in an idb, compiles and evaluates
the query and compares the results to the solutions- Parameters:
in- , reader for e.g. a filebaseTable- , symbol tableedb- , extensional databasetopdown- , top down evaluation (magic sets)path- , path to edbbuiltinProvider- , provides builtinsrewriterProvider- , provides rewritersconfig- , a configurationprp- , builtin properties- Returns:
- true, if results of evaluation are the same as the solutions inside the file
- Throws:
ReasoningExceptionIOExceptionInterruptedExceptionSemReasonerException
-
evaluate
void evaluate(Receiver receiver) throws InterruptedException, ReasoningException, IOException, SemReasonerException Starts evaluation and feed the results into receiver- Parameters:
receiver- , the results are sent to receiver- Throws:
InterruptedExceptionReasoningExceptionIOExceptionSemReasonerException
-
evaluate
List<TupleEnumerator> evaluate() throws InterruptedException, ReasoningException, IOException, SemReasonerExceptionstarts evaluation and returns iterators for the results of the evaluation- Returns:
- iterator for results
- Throws:
InterruptedExceptionReasoningExceptionIOExceptionSemReasonerException
-
evaluateSeveralQueries
List<List<TupleEnumerator>> evaluateSeveralQueries() throws InterruptedException, ReasoningException, IOException, SemReasonerExceptionStarts evaluation for several queries.
For every query a list of iterators for the results is returned.- Returns:
- , list of tuple enumerators for results
- Throws:
InterruptedExceptionReasoningExceptionIOExceptionSemReasonerException
-
close
Close the reasoner. Must be called to correctly finalize the reasoner -
evaluationFinished
Is called after reasoning process is finished -
getSymbolTable
SymbolTable getSymbolTable()Returns the reasoning symbol table used to create new symbols during reasoning
This reasoning symbol table is different to the base symbol table given by core.getSymbolTable()
To decode reasoning results always use this one- Returns:
-
compile
void compile(IntensionalDB idb, ExtensionalDB[] edbs, ReasoningMonitor monitor, SystemMonitor smonitor, boolean topdown, int maxNumberOfResults, boolean streamReasoning, boolean streamReasoningWithRetracts) throws InterruptedException, IOException, SemReasonerException compile rules for the reasoning process- Parameters:
idb- , intensional dbedbs- extensional dbsmonitor- , monitoring reasoning and memory consumptionsmonitor- , system monitor, used by system may be nulltopdown- , execution is done top down (magic sets)streamReasoningWithRetracts- , retracts in stream reasoningstreamReasoning- , stream reasoning is done- Throws:
InterruptedExceptionIOExceptionSemReasonerException
-
register
void register(InterruptFlag interruptFlag, List<EventResultReceiver> receiver, CoreReadLock edbReadLock) throws InterruptedException, IOException, SemReasonerException Register several queries for events caused by sensors or in case of
stream reasoning db caused by added facts.
Every time events from sensors arrive there might be one or more new results.
For every result receiver.receive is called
This is used for stream reasoning- Parameters:
interruptFlag- , interruptreceiver-edbReadLock- , the read lock for the extensional db, used during reasoning- Throws:
IOExceptionSemReasonerExceptionInterruptedException
-
resultsContainedEDBRelations
boolean resultsContainedEDBRelations()Have results contained whole edb relations?- Returns:
-
getQueries
get queries after compilation- Returns:
-