Package com.semedy.reasoner.reasoning
Class ReasonerThreadedRulesPartitioning
java.lang.Object
com.semedy.reasoner.reasoning.ReasonerThreadedRulesPartitioning
- All Implemented Interfaces:
Reasoner
Threaded reasoner
- Author:
- angele
-
Constructor Summary
ConstructorDescriptionReasonerThreadedRulesPartitioning
(InterruptFlag interruptFlag, SymbolTable symboltable, BuiltinProvider builtinFactory, int reasoningthreads, boolean skipAnswers, int maxNumberOfResults, ReasoningMonitor monitor, boolean cepReasoning, boolean cepReasoningWithRetracts, String tempDir, boolean swapping, Properties builtinProperties, int pulsedTuples, boolean sorted) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close the reasoner.void
compile
(IntensionalDB idb, ExtensionalDB[] edbs, ReasoningMonitor monitor, SystemMonitor smonitor, boolean topdown, int maxNumberOfResults, boolean cepReasoningWithRetracts, boolean cepReasoning) compile rules for the reasoning processevaluate()
starts evaluation and returns iterators for the results of the evaluationevaluate
(ReasoningMonitor monitor) void
Starts evaluation and feed the results into receiverStarts evaluation for several queries.void
Is 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 onevoid
register
(EventResultReceiver receiver) void
register
(InterruptFlag interruptFlag, List<EventResultReceiver> receiver) 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 reasoningvoid
register
(InterruptFlag interruptFlag, List<EventResultReceiver> receiver, CoreReadLock edbReadLock, SimpleSemaphore semaphore) void
register
(InterruptFlag interruptFlag, List<EventResultReceiver> receiver, SimpleSemaphore semaphore) boolean
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
-
ReasonerThreadedRulesPartitioning
public ReasonerThreadedRulesPartitioning(InterruptFlag interruptFlag, SymbolTable symboltable, BuiltinProvider builtinFactory, int reasoningthreads, boolean skipAnswers, int maxNumberOfResults, ReasoningMonitor monitor, boolean cepReasoning, boolean cepReasoningWithRetracts, String tempDir, boolean swapping, Properties builtinProperties, int pulsedTuples, boolean sorted)
-
-
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 ReasoningException Description copied from interface:Reasoner
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- Specified by:
test
in interfaceReasoner
- 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:
ReasoningException
-
evaluate
public List<TupleEnumerator> evaluate(ReasoningMonitor monitor) throws InterruptedException, IOException, SemReasonerException -
evaluate
public void evaluate(Receiver receiver) throws InterruptedException, IOException, SemReasonerException Description copied from interface:Reasoner
Starts evaluation and feed the results into receiver- Specified by:
evaluate
in interfaceReasoner
- Parameters:
receiver
- , the results are sent to receiver- Throws:
InterruptedException
IOException
ReasoningException
SemReasonerException
-
evaluate
public List<TupleEnumerator> evaluate() throws InterruptedException, IOException, SemReasonerExceptionDescription copied from interface:Reasoner
starts evaluation and returns iterators for the results of the evaluation- Specified by:
evaluate
in interfaceReasoner
- Returns:
- iterator for results
- Throws:
InterruptedException
IOException
ReasoningException
SemReasonerException
-
close
Description copied from interface:Reasoner
Close the reasoner. Must be called to correctly finalize the reasoner- Specified by:
close
in interfaceReasoner
- Throws:
ReasoningException
InterruptedException
-
getSymbolTable
Description copied from interface:Reasoner
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- Specified by:
getSymbolTable
in interfaceReasoner
- Returns:
-
compile
public void compile(IntensionalDB idb, ExtensionalDB[] edbs, ReasoningMonitor monitor, SystemMonitor smonitor, boolean topdown, int maxNumberOfResults, boolean cepReasoningWithRetracts, boolean cepReasoning) throws InterruptedException, IOException, SemReasonerException Description copied from interface:Reasoner
compile rules for the reasoning process- Specified by:
compile
in interfaceReasoner
- 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)cepReasoningWithRetracts
- , stream reasoning is donecepReasoning
- , retracts in stream reasoning- Throws:
InterruptedException
IOException
SemReasonerException
-
register
-
evaluateSeveralQueries
public List<List<TupleEnumerator>> evaluateSeveralQueries() throws InterruptedException, ReasoningExceptionDescription 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
-
register
-
register
public void register(InterruptFlag interruptFlag, List<EventResultReceiver> receiver, SimpleSemaphore semaphore) -
register
public void register(InterruptFlag interruptFlag, List<EventResultReceiver> receiver, CoreReadLock edbReadLock) throws InterruptedException, ReasoningException 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:
InterruptedException
ReasoningException
-
register
public void register(InterruptFlag interruptFlag, List<EventResultReceiver> receiver, CoreReadLock edbReadLock, SimpleSemaphore semaphore) -
evaluationFinished
Description copied from interface:Reasoner
Is called after reasoning process is finished- Specified by:
evaluationFinished
in interfaceReasoner
- Throws:
ReasoningException
IOException
-
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:
-