Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

Latest commit

 

History

History
120 lines (97 loc) · 3.27 KB

File metadata and controls

120 lines (97 loc) · 3.27 KB

Comunica Contextify Version Query Operation Actor

npm version Build Status Coverage Status

A Query Operation actor that detects graph-based version operations and rewrites them to operations with a version context.

This module is part of the Comunica framework, and should only be used by developers that want to build their own query engine.

Click here if you just want to query with Comunica.

Install

$ yarn add @comunica/actor-query-operation-contextify-version

Configure

After installing, this package can be added to your engine's configuration as follows:

{
  "@context": [
    ...
    "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-query-operation-contextify-version/^1.0.0/components/context.jsonld"  
  ],
  "actors": [
    ...
    {
      "@id": "config-sets:contextify-version.json#myContextifyVersionQueryOperator",
      "@type": "ActorQueryOperationContextifyVersion",
      "cbqo:mediatorQueryOperation": { "@id": "config-sets:sparql-queryoperators.json#mediatorQueryOperation" },
      "caqocv:Actor/QueryOperation/ContextifyVersion/baseGraphUri": "http://graph.version.",
      "caqocv:Actor/QueryOperation/ContextifyVersion/numericalVersions": true
    }
  ]
}

Config Parameters

  • caqocv:Actor/QueryOperation/ContextifyVersion/baseGraphUri: The base URI of the graph to contextify. If this is not provided, then graphs will be converted to version identifiers as-is.
  • caqocv:Actor/QueryOperation/ContextifyVersion/numericalVersions: If versions should be parsed as integers.

Examples

Assuming a base graph URI http://ex/g/.

Version Materialization

Input query:

SELECT * WHERE {
  GRAPH <http://ex/g/1> {
    ?s ?p ?o
  }
}

Output context:

{
  "version": {
    "type": "version-materialization",
    "version": 1
  }
}

Output query:

SELECT * WHERE {
  ?s ?p ?o
}

Delta Materialization

Input query:

SELECT * WHERE {
  GRAPH <http://ex/g/4> {
    ?s ?p ?o
  } .
  FILTER (NOT EXISTS {
    GRAPH <http://ex/g/2> {
      ?s ?p ?o
    }
  }) 
}

Output context:

{
  "version": {
    "queryAdditions": true,
    "type": "delta-materialization",
    "versionEnd": 4,
    "versionStart": 2
  }
}

Output query:

SELECT * WHERE {
  ?s ?p ?o
}

Note: Flipping the versions would make this a deletions query instead of an additions query, i.e., queryAdditions would be set to false.