On 03/08/17 08:29, Qian Liu wrote:

Recently when I try to use Jena to develop a stream based provenance
aware sparql query engine, I confront some problems. Does anyone
know the detailed mechanism about how Jena SPARQL Algebra operators
apply onto the RDF dataset? I know there is OpExecutor Class, but I
need the detailed procedures. i.e., It seems that Jena firstly get
the query Plan, and QueryIterator, but I don’t find where it connects
the queries with the dataset.

A good way to find out is to trace the execution of a single query in an IDE debugger.

In QueryEngineMain we have:

QueryIterator qIter = QC.execute(op, qIter1, execCxt) ;

The ExecutionContext has a reference to the dataset and current active graph.

QC.execute calls OpExecutor.execute.
which calls OpExecutor::exec(op, qIter)
which calls visitor-pattern code to dispatch the op to the correct OpExecutor method.

All getting data from the dataset goes through one of:

execute OpBGP
execute OpPath
execute OpQuadBlock
execute OpDatasetNames (a special case)

OpTriple and OpQuad do not arise in execution normally.

See also StageGenerators for access specialised graphs and special policies for accessing data - in the in-memory setup, it where the call to QueryIterBlockTriples and hence Graph.find to access the graph happens.

According to my understanding, it happens during the
> ResultSet.nextBinding() method. But I don’t know how?

Via iteration. Every OpExecutor method returns a QueryIterator. ResultSet.nextBinding is calling the topmost QueryIterator.next which
pulls the structure setup by OpExecutor etc i.e more QueryIterator.

There are many QueryIterator classes including - roughly - one per algebra operation.

> and this is only for SELECT queries, how about other types of queries.

See QueryExecutionBase

Evaluation is evaluate the WHERE clause via OpExecutor then process for ASK/CONSTRUCT etc if necessary.

----
For small scale usage, you main find the "reference" query engine easier. It is a naive, materializing, functional evaluation of an op. QueryEngineRef.

    Andy

Reply via email to