Skip to content

Stream to Relation Operators

Pieter Bonte edited this page May 27, 2021 · 9 revisions

public interface StreamToRelationOp<I, O> extends Consumer<I> {

    String iri();

    default boolean named() {
        return iri() != null;
    }

    Report report();

    Tick tick();

    Time time();
    
    Content<I, O> compute(long t_e, Window w);

    Content<I, O> getContent(long now);

    List<Content<I, O>> getContents(long now);

    TimeVarying<O> set(SDS<O> sds);

}

In RSP-QL syntax, an iri can be used to name the pair windowOp-stream. The methods iri() and named() of the StreamToRelationOp relates to this language feature.

The methods report(), tick(), time() relates to the engine Execution Semantics, and how it refelcts on the Operators implementation.

The most important methods are those related to content, which is also part of the SECRET MODEL, but specifically relates to the window behavior.

In particular, the StreamToRelationOp interface is parametrics.

  • I represents the variable type of the input, e.g., RDF TRIPLE, RDF GRAPHS OR TUPLE
  • O represents the variable type of the maintained status, e.g., BAG of RDF Triple, RDF Graph (set) or RELATION

It extends the Consumer interface (see below), which allow sending timestamped data items.

public interface Consumer<I> {

    void notify(I arg, long ts);
}

Factory of Stream to Relation Operators

RSP-QL is a declarative language, therefore we must decouple the runtime logic of the window operator from the syntax interpretation and parsing. The factory represents the logic of applying the Operator Specification to a given stream, under a given name.

public interface StreamToRelationOperatorFactory<I, O> {

    TimeVarying<O> apply(WebDataStream<I> s, IRI iri);

}

Window Instances

A S2R operator, once applied to a stream, determine a set of window instances that represent how the finite chuncks of the stream. A window instance is determined by an interval (o,c], where o represents the opening time instant and c represents the closing time instant.

For some window operators, such set is deterministic knowing the t0 (e.g,, sliding windows). For more sophysiticated S2R, e.g., data-driven windows, such set is not deterministic as it depends on the stream items.

RSP4J contains the Window interface and its implementation for to allow representing such scanarios.

public interface Window {

    long getC();

    long getO();

}

YASPER Implementations

YASPER includes two implementation of the window operators and related classes, based on the CQELS and C-SPARQL language semantics and the operational semantics of their prototypes.