public class ReasoningEngine extends Object implements TransactionListener
The reasoning engine uses its own connection to the database to carry out reasoning tasks.
TODO: we need to clarify conceptually whether it would be correct to run several reasoner threads in parallel. In theory, reasoning here is strictly monotonic so there should not be a problem. In practice, we might miss certain triples because the order of transactions might be messed up. Maybe it makes more sense to parallelize the execution or rules instead.
User: Sebastian Schaffert (sschaffert@apache.org)
Modifier and Type | Field and Description |
---|---|
protected static com.google.common.base.Equivalence<org.openrdf.model.Statement> |
equivalence |
Modifier | Constructor and Description |
---|---|
protected |
ReasoningEngine() |
|
ReasoningEngine(KiWiReasoningPersistence persistence,
TransactionalSail store,
ReasoningConfiguration config) |
Modifier and Type | Method and Description |
---|---|
void |
afterCommit(TransactionData data)
Incrementally apply the updates that are contained in the transaction
data to the reasoning programs that are in the system.
|
void |
beforeCommit(TransactionData data)
Called before a transaction commits.
|
protected void |
endTask()
Stop the currently active reasoning task.
|
protected Set<Justification> |
getBaseJustifications(KiWiReasoningConnection connection,
Set<Justification> justifications)
For all justifications contained in the set passed as argument, create corresponding base justifications,
i.e.
|
protected Collection<Justification> |
getJustifications(KiWiReasoningConnection connection,
KiWiTriple t,
Set<Justification> transactionJustifications)
Return the justifications for the triple passed as argument.
|
boolean |
isRunning()
Return true in case the reasoner is currently executing, false otherwise.
|
void |
loadPrograms() |
protected static QueryResult |
matches(Pattern pattern,
KiWiTriple triple) |
void |
notifyAddRule(Rule rule)
In case a new rule has been added to one of the reasoning programs, process only this rule addition
incrementally.
|
void |
notifyRemoveRules()
In case an existing rule has been removed from one of the reasoning programs, remove all triples
that are based on this rule by consulting the justifications that use this rule.
|
void |
programChanged(Program program) |
void |
reRunPrograms()
Clean all inferred triples and re-run all reasoning rules.
|
void |
rollback(TransactionData data)
Called when a transaction rolls back.
|
void |
shutdown() |
void |
shutdown(boolean force) |
protected void |
startTask(String name,
String taskGroup)
Start a new reasoner task to collect status messages.
|
protected void |
updateTaskMaxProgress(int progress)
Set the maximum steps needed in the task progress (if any)
|
protected void |
updateTaskProgress(int progress)
Update the task progress (if any)
|
protected void |
updateTaskStatus(String message)
Update the status of the reasoner task with the given message.
|
protected static com.google.common.base.Equivalence<org.openrdf.model.Statement> equivalence
protected ReasoningEngine()
public ReasoningEngine(KiWiReasoningPersistence persistence, TransactionalSail store, ReasoningConfiguration config)
public void loadPrograms()
public void programChanged(Program program)
public void notifyAddRule(Rule rule)
rule
- public void notifyRemoveRules()
public void afterCommit(TransactionData data)
Called after a transaction has committed. The transaction data will contain all changes done in the transaction since the last commit. This method should be used in case the transaction listener aims to perform additional activities in a new transaction or outside the transaction management, e.g. notifying a server on the network, adding data to a cache, or similar.
afterCommit
in interface TransactionListener
data
- public void beforeCommit(TransactionData data)
beforeCommit
in interface TransactionListener
data
- public void rollback(TransactionData data)
rollback
in interface TransactionListener
protected void startTask(String name, String taskGroup)
name
- protected void endTask()
protected void updateTaskStatus(String message)
message
- protected void updateTaskProgress(int progress)
progress
- protected void updateTaskMaxProgress(int progress)
progress
- public void reRunPrograms()
protected Collection<Justification> getJustifications(KiWiReasoningConnection connection, KiWiTriple t, Set<Justification> transactionJustifications) throws SQLException
t
- SQLException
protected Set<Justification> getBaseJustifications(KiWiReasoningConnection connection, Set<Justification> justifications) throws SQLException, ReasoningException
justifications
- SQLException
ReasoningException
protected static QueryResult matches(Pattern pattern, KiWiTriple triple)
public boolean isRunning()
public void shutdown()
public void shutdown(boolean force)
Copyright © 2012–2018 The Apache Software Foundation. All rights reserved.