Crate spareval

Source
Expand description

§spareval

Latest Version Released API docs Crates.io downloads actions status Gitter

spareval is a SPARQL Query evaluator.

It relies on the spargebra and sparopt crates.

This crate is intended to be a building piece for SPARQL implementations like oxigraph.

use oxrdf::{Dataset, GraphName, NamedNode, Quad};
use spareval::{QueryEvaluator, QueryResults};
use spargebra::Query;

let ex = NamedNode::new("http://example.com").unwrap();
let dataset = Dataset::from_iter([Quad::new(
    ex.clone(),
    ex.clone(),
    ex.clone(),
    GraphName::DefaultGraph,
)]);
let query = Query::parse("SELECT * WHERE { ?s ?p ?o }", None).unwrap();
let results = QueryEvaluator::new().execute(dataset, &query);
if let QueryResults::Solutions(solutions) = results.unwrap() {
    let solutions = solutions.collect::<Result<Vec<_>, _>>().unwrap();
    assert_eq!(solutions.len(), 1);
    assert_eq!(solutions[0]["s"], ex.into());
}

§Cargo features

  • rdf-star: enables SPARQL-star.
  • sep-0002: enables the SEP-0002 (ADJUST function and a lot of arithmetic on xsd:date, xsd:time, xsd:yearMonthDuration and xsd:dayTimeDuration).
  • sep-0006: enables the SEP-0006 (LATERAL keyword).
  • calendar-ext: arithmetic on xsd:gYear, xsd:gYearMonth, xsd:gMonth, xsd:gMonthDay and xsd:gDay.

§License

This project is licensed under either of

  • Apache License, Version 2.0, (LICENSE-APACHE or <http://www.apache.org/licenses/LICENSE-2.0>)
  • MIT license (LICENSE-MIT or <http://opensource.org/licenses/MIT>)

at your option.

§Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Oxigraph by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Structs§

ExpressionTriple
InternalQuad
QueryEvaluator
Evaluates a query against a given RDF dataset
QueryExplanation
The explanation of a query.
QuerySolution
Tuple associating variables and terms that are the result of a SPARQL query.
QuerySolutionIter
An iterator over QuerySolutions.
QueryTripleIter
An iterator over the triples that compose a graph solution.

Enums§

ExpressionTerm
A term as understood by the expression evaluator
QueryEvaluationError
A SPARQL evaluation error
QueryResults
Results of a SPARQL query.

Traits§

DefaultServiceHandler
Default handler for SPARQL 1.1 Federated Query SERVICEs.
QueryableDataset
A RDF dataset that can be queried using SPARQL
ServiceHandler
Handler for SPARQL 1.1 Federated Query SERVICEs.