Class DatasetPatch
Dataset in one
write transaction.
Recording the changes and applying them are two separate steps: add(org.apache.jena.graph.Node, org.apache.jena.graph.Node, org.apache.jena.graph.Node, org.apache.jena.graph.Node) and delete(org.apache.jena.graph.Node, org.apache.jena.graph.Node, org.apache.jena.graph.Node, org.apache.jena.graph.Node) only record the change, and the patch is played onto the dataset — as a single write
transaction on dataset — only once the recording Consumer returns. This lets
callers build up a patch from several sources — several models, a filtered stream of a live graph
— without holding the dataset's write lock while they do it.
-
Method Summary
Modifier and TypeMethodDescriptionadd(org.apache.jena.graph.Node graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Records the addition of a triple to the given graph.addAll(org.apache.jena.graph.Node graph, org.apache.jena.rdf.model.Model model) Records the addition of every triple of the model to the given graph.static voidapply(org.apache.jena.query.Dataset dataset, Consumer<DatasetPatch> changes) Records changes and applies them to the dataset as a single patch.static voidapplyReading(org.apache.jena.query.Dataset dataset, Consumer<DatasetPatch> changes) Records changes inside a read transaction on the dataset, then applies them as one patch.delete(org.apache.jena.graph.Node graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Records the deletion of a triple from the given graph.deleteAll(org.apache.jena.graph.Node graph, org.apache.jena.rdf.model.Model model) Records the deletion of every triple of the model from the given graph.
-
Method Details
-
apply
Records changes and applies them to the dataset as a single patch.- Parameters:
dataset- the dataset to patchchanges- records the additions and deletions to apply
-
applyReading
public static void applyReading(org.apache.jena.query.Dataset dataset, Consumer<DatasetPatch> changes) Records changes inside a read transaction on the dataset, then applies them as one patch.Use this instead of
apply(org.apache.jena.query.Dataset, java.util.function.Consumer<ai.chatur.cortex.core.jena.DatasetPatch>)when recording the changes needs to read the dataset being patched — for example, streaming the triples of a live named graph to decide what to delete. The read transaction covers only the recording; applying the resulting patch is a separate write transaction, opened after the read transaction has closed.- Parameters:
dataset- the dataset to patchchanges- records the additions and deletions to apply, with a read transaction ondatasetheld open for the duration
-
add
public DatasetPatch add(org.apache.jena.graph.Node graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Records the addition of a triple to the given graph.- Parameters:
graph- the named graph the triple belongs to, orQuad.defaultGraphIRIfor the default graphsubject- the subject of the triplepredicate- the predicate of the tripleobject- the object of the triple- Returns:
- this patch, for chaining
-
delete
public DatasetPatch delete(org.apache.jena.graph.Node graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Records the deletion of a triple from the given graph.- Parameters:
graph- the named graph the triple belongs to, orQuad.defaultGraphIRIfor the default graphsubject- the subject of the triplepredicate- the predicate of the tripleobject- the object of the triple- Returns:
- this patch, for chaining
-
addAll
Records the addition of every triple of the model to the given graph.- Parameters:
graph- the named graph to add the triples to, orQuad.defaultGraphIRIfor the default graphmodel- the model whose triples are added- Returns:
- this patch, for chaining
-
deleteAll
public DatasetPatch deleteAll(org.apache.jena.graph.Node graph, org.apache.jena.rdf.model.Model model) Records the deletion of every triple of the model from the given graph.- Parameters:
graph- the named graph to delete the triples from, orQuad.defaultGraphIRIfor the default graphmodel- the model whose triples are deleted- Returns:
- this patch, for chaining
-