Tool determining the containment relation in between two RSPQL queries.
npm install rspql-containment-checkerThe RSPQL Containment Checker is a tool that extends the SPeCS SPARQL Containment solver to check containment between two RSP-QL queries. The RSP-QL queries are translated to SPARQL queries, along with their streaming semantics, and then the containment is checked using the SPeCS tool for the SPARQL queries. The streaming semantics are utilized to determine if the RSP-QL queries are on the same data source and if they are compatible for containment checking.
Once the compatibility is established, the containment checking is performed using the SPeCS tool.
The RSP-QL containment checker is presented as a HTTP service that can be accessed via a REST API. The server accepts RSP-QL queries and returns the containment result. The RSP-QL containment checker is implemented with Typescript and Node.js.
The RSPQL containment checker can be utilized as a NPM package or as a standalone tool. It is designed to be used in a Node.js environment, and it can be integrated into other applications or used as a command-line tool.
To use the RSPQL Containment Checker as a NPM package, you can install it using the following command:
``bash`
npm install rspql-containment-checker
You can then import the package in your Node.js application and use it to check the containment of RSP-QL queries. Here is an example of how to use the package:
`ts
import { ContainmentChecker } from "rspql-containment-checker";
async function checkContainment(subquery: string, superquery: string) {
const checker = new ContainmentChecker();
try {
const result = await checker.checkContainment(subquery, superquery);
console.log(Containment result: ${result.containment});Error checking containment: ${error.message}
} catch (error) {
console.error();
}
}
// Example usage
let subquery = PREFIX ex:
REGISTER RStream
let superquery = PREFIX ex:
REGISTER RStream
console.log(checkContainment(subquery, superquery));
// Output: Containment result: true
`
where subquery and superquery are the RSP-QL queries you want to check for containment. The checkContainment method will return a boolean value indicating whether the subquery is contained in the superquery.
To install the RSPQL Containment Checker, follow these steps:
1. Clone the repository:
`bash`
git clone https://github.com/SolidLabResearch/rspql-containment-checker.git
2. Install the relevant dependencies:
`bash`
npm install
`
3. Build the project:
bash`
npm run build
`
4. Start the containment checker tool with
bash`
npm run start containment-checker
http://localhost:8085
This will start the RSPQL Containment Checker server on . You can change the port in the src/index.ts file.
The RSPQL containment checker is implemented as a REST API. You can use any HTTP client to send requests to the server. The server accepts RSP-QL queries and returns the containment result in JSON format.
The RSPQL Containment Checker provides the following API endpoints:
- POST /containment: This endpoint checks the containment of two RSP-QL queries. The request body should contain the following JSON object:`json`
{
"subquery": "
"superquery": "
}`
The response will contain the containment result in the following format:json`
{
"containment": "
}
When the containment checker is up and running,
For the two RSP-QL queries:
`sparql`
PREFIX ex:
REGISTER RStream
and
`sparql`
PREFIX ex:
REGISTER RStream /containment
You can check the containment between the queries by doing a POST request to the endpoint with the following example of JSON:`json`
{
"subquery": "PREFIX ex:
The server will respond with the containment result:
`json`
{
"containment": true
}
This indicates that the first query is contained in the second query.
The RSPQL Containment Checker also provides an isomorphism check for the two queries. Isomorphism relation is basically double containment on the both sides.
The isomorphism check can also be performed using the POST /containment endpoint. The request body should contain the following JSON object:`json`
{
"query1": "
"query2": "
}
The response will contain the isomorphism result in the following format:
`json`
{
"isomorphism": "
}
We utilize the RSPQL Query Isomorphism tool to check the isomorphism.
Since the isomorphism relation is cheaper to compute than the containment relation, we first check for isomorphism before checking for containment. In case the two queries are isomorphic, we return the result as true without checking for containment.false
If the two queries are not isomorphic, we check for containment and return the result as if the containment check fails and true` if the containment check passes.