Search in sources :

Example 6 with QueryEngineFactory

use of org.apache.jena.sparql.engine.QueryEngineFactory in project jena by apache.

the class QueryExecDatasetBuilder method build.

@Override
public QueryExec build() {
    Objects.requireNonNull(query, "No query for QueryExec");
    // Queries can have FROM/FROM NAMED or VALUES to get data.
    // Objects.requireNonNull(dataset, "No dataset for QueryExec");
    query.setResultVars();
    Context cxt = getContext();
    QueryEngineFactory qeFactory = QueryEngineRegistry.get().find(query, dataset, cxt);
    if (qeFactory == null) {
        Log.warn(QueryExecDatasetBuilder.class, "Failed to find a QueryEngineFactory");
        return null;
    }
    // Initial bindings / parameterized query
    Query queryActual = query;
    String queryStringActual = queryString;
    if (substitutionMap != null && !substitutionMap.isEmpty()) {
        queryActual = QueryTransformOps.transform(query, substitutionMap);
        queryStringActual = null;
    }
    defaultTimeoutsFromContext(this, cxt);
    if (dataset != null)
        cxt.set(ARQConstants.sysCurrentDataset, DatasetFactory.wrap(dataset));
    if (queryActual != null)
        cxt.set(ARQConstants.sysCurrentQuery, queryActual);
    QueryExec qExec = new QueryExecDataset(queryActual, queryStringActual, dataset, cxt, qeFactory, initialTimeout, initialTimeoutUnit, overallTimeout, overallTimeoutUnit, initialBinding);
    return qExec;
}
Also used : Context(org.apache.jena.sparql.util.Context) QueryEngineFactory(org.apache.jena.sparql.engine.QueryEngineFactory)

Aggregations

QueryEngineFactory (org.apache.jena.sparql.engine.QueryEngineFactory)6 QueryExecutionBase (org.apache.jena.sparql.engine.QueryExecutionBase)3 Plan (org.apache.jena.sparql.engine.Plan)2 IndentedWriter (org.apache.jena.atlas.io.IndentedWriter)1 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)1 SerializationContext (org.apache.jena.sparql.serializer.SerializationContext)1 Context (org.apache.jena.sparql.util.Context)1