Class InferenceService
Reasoner.
The inference results are materialized into a separate dataset that serves as the read model
for queries and search, leaving the dataset of approved assertions untouched. A single inference
model is kept for the lifetime of the service. addInference(Model) extends it
incrementally as branches are approved, so a single approve never recomputes the closure from scratch.
recomputeInference() rebuilds it from a fresh in-memory copy of the assertions instead:
it runs once at application startup, and as the fallback inside approve if the
incremental update throws. Either way only the difference to the current inference graph is
applied, as an RDF patch, so the full-text index wrapped around the inference dataset only ever
indexes statements that are genuinely new.
-
Constructor Summary
ConstructorsConstructorDescriptionInferenceService(org.apache.jena.query.Dataset assertions, org.apache.jena.query.Dataset inferences, org.apache.jena.reasoner.Reasoner reasoner) Creates the service. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddInference(org.apache.jena.rdf.model.Model novel) Extends the inference closure with newly approved assertions and patches the inference dataset with the difference, without recomputing the closure from scratch.voidRecomputes the inference closure from the current assertions and patches the inference dataset with the difference: statements no longer entailed are deleted, novel ones are added, and statements already present are left untouched so they are not reindexed.
-
Constructor Details
-
InferenceService
public InferenceService(org.apache.jena.query.Dataset assertions, org.apache.jena.query.Dataset inferences, org.apache.jena.reasoner.Reasoner reasoner) Creates the service.- Parameters:
assertions- the dataset holding the approved assertionsinferences- the dataset the inference results are materialized intoreasoner- the reasoner used to derive new statements
-
-
Method Details
-
recomputeInference
public void recomputeInference()Recomputes the inference closure from the current assertions and patches the inference dataset with the difference: statements no longer entailed are deleted, novel ones are added, and statements already present are left untouched so they are not reindexed.The assertions are copied into memory, so the inference model never reads the transactional assertions dataset after this method returns.
-
addInference
public void addInference(org.apache.jena.rdf.model.Model novel) Extends the inference closure with newly approved assertions and patches the inference dataset with the difference, without recomputing the closure from scratch.Falls back to
recomputeInference()if the closure has not been computed yet — the assertions dataset already contains the novel statements.- Parameters:
novel- the newly approved assertions
-