Package com.semedy.reasoner.reasoning
Class ReasonerNotThreaded
java.lang.Object
com.semedy.reasoner.reasoning.ReasonerNotThreaded
- All Implemented Interfaces:
Reasoner
Reasoner.
Reasoner selects rules according to queries,
rewrites the rules with the rewriters,
compiles rules into execution structure,
executes the rules,
and finally creates the answers
Reasoner selects rules according to queries,
rewrites the rules with the rewriters,
compiles rules into execution structure,
executes the rules,
and finally creates the answers
- Author:
- angele
-
Constructor Summary
ConstructorsConstructorDescriptionReasonerNotThreaded(InterruptFlag interruptFlag, SymbolTable symboltable, BuiltinProvider builtinFactory, boolean skipAnswers, long maxNumberOfResults, boolean cepReasoning, boolean cepReasoningWithRetracts, String tempDir, boolean swapping, Properties builtinProperties) ReasonerNotThreaded(InterruptFlag interruptFlag, SymbolTable symboltable, BuiltinProvider builtinFactory, ReasoningMonitor monitor, boolean skipAnswers, long maxNumberOfResults, SimpleSemaphore semaphorForSensors, boolean cepReasoning, boolean cepReasoningWithRetracts, String tempDir, boolean swapping, Properties builtinProperties) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the reasoner.voidcompile(IntensionalDB idb, ExtensionalDB[] edbs, ReasoningMonitor monitor, SystemMonitor smonitor, boolean topdown, int[] partsVector, boolean cepReasoningWithRetracts, boolean cepReasoning) voidcompile(IntensionalDB idb, ExtensionalDB[] edbs, ReasoningMonitor monitor, SystemMonitor smonitor, boolean topdown, int maxNumberOfResults, boolean streamReasoning, boolean cepReasoningWithRetracts) Compile rules to a data flowevaluate()Start evaluation and return an iterator for the resultsvoidStarts evaluation and feed the results into receiverStarts evaluation for several queries.voidevaluation is finishedget queries after compilationReturns the reasoning symbol table used to create new symbols during reasoningvoidregister(InterruptFlag interruptFlag, EventResultReceiver receiver, CoreReadLock edbReadLock) voidregister(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.
-
Constructor Details
-
ReasonerNotThreaded
public ReasonerNotThreaded(InterruptFlag interruptFlag, SymbolTable symboltable, BuiltinProvider builtinFactory, ReasoningMonitor monitor, boolean skipAnswers, long maxNumberOfResults, SimpleSemaphore semaphorForSensors, boolean cepReasoning, boolean cepReasoningWithRetracts, String tempDir, boolean swapping, Properties builtinProperties) -
ReasonerNotThreaded
public ReasonerNotThreaded(InterruptFlag interruptFlag, SymbolTable symboltable, BuiltinProvider builtinFactory, boolean skipAnswers, long maxNumberOfResults, boolean cepReasoning, boolean cepReasoningWithRetracts, String tempDir, boolean swapping, Properties builtinProperties)
-
-
Method Details
-
test
public boolean test(Reader in, SymbolTable baseTable, ExternalDataTypeProvider datatypes, ExtensionalDB edb, boolean topdown, String path, BuiltinProvider builtinProvider, RewriterProvider rewriterProvider, Configuration config, Properties prp) throws IOException, SemReasonerException, InterruptedException 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 with the solutions- Specified by:
testin interfaceReasoner- Parameters:
in-baseTable-datatypes-topdown-path-builtinProvider-rewriterProvider-config-edb- , extensional databaseprp- , builtin properties- Returns:
- Throws:
SemReasonerExceptionInterruptedExceptionIOExceptionReasoningException
-
evaluate
public void evaluate(Receiver receiver) throws InterruptedException, SemReasonerException, IOException Description copied from interface:ReasonerStarts evaluation and feed the results into receiver- Specified by:
evaluatein interfaceReasoner- Parameters:
receiver-- Throws:
IOException- evaluate the current data flow and send results to receiverInterruptedException- @throws TransactionException @throwsReasoningExceptionSemReasonerException
-
evaluate
public List<TupleEnumerator> evaluate() throws InterruptedException, SemReasonerException, IOExceptionStart evaluation and return an iterator for the results- Specified by:
evaluatein interfaceReasoner- Returns:
- Throws:
TransactionExceptionInterruptedExceptionSemReasonerExceptionIOExceptionReasoningException
-
close
public void close()Close the reasoner. Must be called to correctly finalize the reasoner -
evaluationFinished
evaluation is finished- Specified by:
evaluationFinishedin interfaceReasoner- Throws:
ReasoningExceptionSemReasonerExceptionIOExceptionInterruptedException
-
getSymbolTable
Returns the reasoning symbol table used to create new symbols during reasoning- Specified by:
getSymbolTablein interfaceReasoner- Returns:
-
compile
public void compile(IntensionalDB idb, ExtensionalDB[] edbs, ReasoningMonitor monitor, SystemMonitor smonitor, boolean topdown, int maxNumberOfResults, boolean streamReasoning, boolean cepReasoningWithRetracts) throws InterruptedException, SemReasonerException, IOException Compile rules to a data flow- Specified by:
compilein interfaceReasoner- Parameters:
idb- , intensional dbedbs- extensional dbsmonitor- reasoning monitorsmonitor- system monitortopdown- execution is done top downmaxNumberOfResults- , max number of resultsstreamReasoning- , enable stream reasoningcepReasoningWithRetracts- , allow retracts for stream reasoning- Throws:
InterruptedExceptionIOExceptionSemReasonerException
-
compile
public void compile(IntensionalDB idb, ExtensionalDB[] edbs, ReasoningMonitor monitor, SystemMonitor smonitor, boolean topdown, int[] partsVector, boolean cepReasoningWithRetracts, boolean cepReasoning) throws SemReasonerException, IOException - Throws:
SemReasonerExceptionIOException
-
evaluateSeveralQueries
public List<List<TupleEnumerator>> evaluateSeveralQueries() throws InterruptedException, SemReasonerException, IOExceptionDescription copied from interface:ReasonerStarts evaluation for several queries.
For every query a list of iterators for the results is returned.- Specified by:
evaluateSeveralQueriesin interfaceReasoner- Returns:
- , list of tuple enumerators for results
- Throws:
InterruptedExceptionReasoningExceptionSemReasonerExceptionIOException
-
register
public void register(InterruptFlag interruptFlag, EventResultReceiver receiver, CoreReadLock edbReadLock) throws InterruptedException, SemReasonerException, IOException - Parameters:
receiver-- Throws:
IOException- evaluate the current data flow and send results to receiverInterruptedException- @throws TransactionException @throwsSemReasonerException
-
register
public void register(InterruptFlag interruptFlag, List<EventResultReceiver> receiver, CoreReadLock edbReadLock) throws InterruptedException, SemReasonerException, IOException Description copied from interface:ReasonerRegister 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- Specified by:
registerin interfaceReasoner- Parameters:
interruptFlag- , interruptedbReadLock- , the read lock for the extensional db, used during reasoning- Throws:
SemReasonerExceptionIOExceptionInterruptedException
-
resultsContainedEDBRelations
public boolean resultsContainedEDBRelations()Description copied from interface:ReasonerHave results contained whole edb relations?- Specified by:
resultsContainedEDBRelationsin interfaceReasoner- Returns:
-
getQueries
Description copied from interface:Reasonerget queries after compilation- Specified by:
getQueriesin interfaceReasoner- Returns:
-