/sesamestream

Event-driven semantics with the Sesame framework

Primary LanguageJavaOtherNOASSERTION

SesameStream

SesameStream logo|width=94px|height=65px

SesameStream is a continuous SPARQL query engine for real-time applications, built with the Sesame RDF framework. It implements a subset (see below) of the SPARQL query language and matches streaming RDF data against queries with low latency, responding to individual statements with the query answers they complete. The query engine conserves resources by indexing only those statements which match against already-submitted queries, making it appropriate for processing long, noisy data streams. SesameStream was developed for use in wearable and ubiquitous computing contexts in which sensor data must be combined with background semantics under real time constraints of a few tens of milliseconds.

Here is a usage example in Java:

String query = "SELECT ?foo ?bar WHERE { ... }";

QueryEngine queryEngine = new QueryEngineImpl();

BindingSetHandler handler = new BindingSetHandler() {
    public void handle(final BindingSet answer) {
        System.out.println("found an answer to the continuous query: " + answer);
    }
};
Subscription sub = queryEngine.addQuery(query, handler);    

// normally, this would be a streaming data source
Collection<Statement> data = ...
for (Statement s : data) {
    // as new statements are added, computed query answers will be pushed to the BindingSetHandler
    queryEngine.addStatement(s);        
}

// cancel the query subscription at any time;
// no further answers will be computed/produced for the corresponding query
sub.cancel();

For projects which use Maven, SesameStream snapshots and release packages can be imported by adding configuration like the following to the project's POM:

    <dependency>
        <groupId>edu.rpi.twc.sesamestream</groupId>
        <artifactId>sesamestream-impl</artifactId>
        <version>1.0</version>
    </dependency>

or if you will implement the API (e.g. for a SesameStream proxy),

    <dependency>
        <groupId>edu.rpi.twc.sesamestream</groupId>
        <artifactId>sesamestream-api</artifactId>
        <version>1.0</version>
    </dependency>

The latest Maven packages can be browsed here. See also:

Send questions or comments to:

Josh email

Syntax reference

SPARQL syntax currently supported by SesameStream includes:

  • SELECT queries. SELECT subscriptions in SesameStream produce query answers indefinitely unless cancelled.
  • ASK queries. ASK subscriptions produce at most one query answer (indicating a result of true) and then are cancelled automatically, similarly to a SELECT query with a LIMIT of 1.
  • CONSTRUCT queries. Each query answer contains "subject", "predicate", and "object" bindings which may be turned into an RDF statement.
  • basic graph patterns
  • variable projection
  • all RDF Term syntax and triple pattern syntax via Sesame
  • FILTER constraints, with all SPARQL operator functions supported via Sesame except for EXISTS
  • DISTINCT modifier. Use with care if the streaming data source may produce an unlimited number of solutions.
  • REDUCED modifier. Similar to DISTINCT, but safe for long streams. Each subscription maintains a solution set which begins to recycle after it reaches a certain size, configurable with SesameStream.setReducedModifierCapacity().
  • LIMIT clause. Once LIMIT number of answers have been produced, the subscription is cancelled.
  • OFFSET clause. Since query answers roughly follow the order in which input statements are received, OFFSET can be practically useful even without ORDER BY (see below)

Syntax explicitly not supported:

  • ORDER BY. This is a closed-world operation which requires a finite data set or window; SesameStream queries over a stream of data and an infinite window.
  • SPARQL 1.1 aggregates. See above

Syntax not yet supported: