View Source RDF.Diff (RDF.ex v0.12.0)

A data structure for diffs between RDF.Graphs and RDF.Descriptions.

A RDF.Diff is a struct consisting of two fields additions and deletions with RDF.Graphs of added and deleted statements.

Link to this section Summary

Functions

Applies a diff to a RDF.Graph or RDF.Description by deleting the deletions and adding the additions of the diff.

Determines if a diff is empty.

Merges two diffs.

Creates a RDF.Diff struct.

Link to this section Types

@type t() :: %RDF.Diff{additions: RDF.Graph.t(), deletions: RDF.Graph.t()}

Link to this section Functions

@spec apply(t(), RDF.Description.t() | RDF.Graph.t()) :: RDF.Graph.t()

Applies a diff to a RDF.Graph or RDF.Description by deleting the deletions and adding the additions of the diff.

Deletions of statements which are not present in the given graph or description are simply ignored.

The result of an application is always a RDF.Graph, even if a RDF.Description is given and the additions from the diff are all about the subject of this description.

Link to this function

diff(original_rdf_data, new_rdf_data)

View Source

Computes a diff between two RDF.Graphs or RDF.Descriptions.

The first argument represents the original and the second argument the new version of the RDF data to be compared. Any combination of RDF.Graphs or RDF.Descriptions can be passed as first and second argument.

examples

Examples

iex> RDF.Diff.diff( ...> RDF.description(EX.S1, init: {EX.S1, EX.p1, [EX.O1, EX.O2]}), ...> RDF.graph([ ...> {EX.S1, EX.p1, [EX.O2, EX.O3]}, ...> {EX.S2, EX.p2, EX.O4} ...> ])) %RDF.Diff{

additions: RDF.graph([
  {EX.S1, EX.p1, EX.O3},
  {EX.S2, EX.p2, EX.O4}
]),
deletions: RDF.graph({EX.S1, EX.p1, EX.O1})

}

@spec empty?(t()) :: boolean()

Determines if a diff is empty.

A RDF.Diff is empty, if its additions and deletions graphs are empty.

@spec merge(t(), t()) :: t()

Merges two diffs.

The diffs are merged by adding up the additions and deletions of both diffs respectively.

@spec new(keyword()) :: t()

Creates a RDF.Diff struct.

Some initial additions and deletions can be provided optionally with the resp. additions and deletions keywords. The statements for the additions and deletions can be provided in any form supported by the RDF.Graph.new/1 function.