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
ConstructorDescriptionReasonerNotThreaded
(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 TypeMethodDescriptionvoid
close()
Close the reasoner.void
compile
(IntensionalDB idb, ExtensionalDB[] edbs, ReasoningMonitor monitor, SystemMonitor smonitor, boolean topdown, int[] partsVector, boolean cepReasoningWithRetracts, boolean cepReasoning) void
compile
(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 resultsvoid
Starts evaluation and feed the results into receiverStarts evaluation for several queries.void
evaluation is finishedget queries after compilationReturns the reasoning symbol table used to create new symbols during reasoningvoid
register
(InterruptFlag interruptFlag, EventResultReceiver receiver, CoreReadLock edbReadLock) void
register
(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 reasoningboolean
Have results contained whole edb relations?boolean
test
(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:
test
in interfaceReasoner
- Parameters:
in
-baseTable
-datatypes
-topdown
-path
-builtinProvider
-rewriterProvider
-config
-edb
- , extensional databaseprp
- , builtin properties- Returns:
- Throws:
SemReasonerException
InterruptedException
IOException
ReasoningException
-
evaluate
public void evaluate(Receiver receiver) throws InterruptedException, SemReasonerException, IOException Description copied from interface:Reasoner
Starts evaluation and feed the results into receiver- Specified by:
evaluate
in interfaceReasoner
- Parameters:
receiver
-- Throws:
IOException
- evaluate the current data flow and send results to receiverInterruptedException
- @throws TransactionException @throwsReasoningException
SemReasonerException
-
evaluate
public List<TupleEnumerator> evaluate() throws InterruptedException, SemReasonerException, IOExceptionStart evaluation and return an iterator for the results- Specified by:
evaluate
in interfaceReasoner
- Returns:
- Throws:
TransactionException
InterruptedException
SemReasonerException
IOException
ReasoningException
-
close
public void close()Close the reasoner. Must be called to correctly finalize the reasoner -
evaluationFinished
evaluation is finished- Specified by:
evaluationFinished
in interfaceReasoner
- Throws:
ReasoningException
SemReasonerException
IOException
InterruptedException
-
getSymbolTable
Returns the reasoning symbol table used to create new symbols during reasoning- Specified by:
getSymbolTable
in 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:
compile
in 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:
InterruptedException
IOException
SemReasonerException
-
compile
public void compile(IntensionalDB idb, ExtensionalDB[] edbs, ReasoningMonitor monitor, SystemMonitor smonitor, boolean topdown, int[] partsVector, boolean cepReasoningWithRetracts, boolean cepReasoning) throws SemReasonerException, IOException - Throws:
SemReasonerException
IOException
-
evaluateSeveralQueries
public List<List<TupleEnumerator>> evaluateSeveralQueries() throws InterruptedException, SemReasonerException, IOExceptionDescription copied from interface:Reasoner
Starts evaluation for several queries.
For every query a list of iterators for the results is returned.- Specified by:
evaluateSeveralQueries
in interfaceReasoner
- Returns:
- , list of tuple enumerators for results
- Throws:
InterruptedException
ReasoningException
SemReasonerException
IOException
-
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:Reasoner
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- Specified by:
register
in interfaceReasoner
- Parameters:
interruptFlag
- , interruptedbReadLock
- , the read lock for the extensional db, used during reasoning- Throws:
SemReasonerException
IOException
InterruptedException
-
resultsContainedEDBRelations
public boolean resultsContainedEDBRelations()Description copied from interface:Reasoner
Have results contained whole edb relations?- Specified by:
resultsContainedEDBRelations
in interfaceReasoner
- Returns:
-
getQueries
Description copied from interface:Reasoner
get queries after compilation- Specified by:
getQueries
in interfaceReasoner
- Returns:
-