Search in sources :

Example 1 with SDBRequest

use of org.apache.jena.sdb.core.SDBRequest in project jena by apache.

the class TupleTable method iterator.

public QueryIterator iterator() {
    SDBRequest request = new SDBRequest(store, null);
    String tableName = desc.getTableName();
    SQLBridge b = store.getSQLBridgeFactory().create(request, sqlTable, vars);
    b.build();
    try {
        String sqlStr = store.getSQLGenerator().generateSQL(request, b.getSqlNode());
        //System.out.println(sqlStr) ;
        ResultSetJDBC tableData = store.getConnection().execQuery(sqlStr);
        ExecutionContext execCxt = new ExecutionContext(new Context(), null, null, null);
        return b.assembleResults(tableData, BindingRoot.create(), execCxt);
    } catch (SQLException ex) {
        throw new SDBExceptionSQL(ex);
    }
}
Also used : Context(org.apache.jena.sparql.util.Context) ExecutionContext(org.apache.jena.sparql.engine.ExecutionContext) ExecutionContext(org.apache.jena.sparql.engine.ExecutionContext) SDBExceptionSQL(org.apache.jena.sdb.sql.SDBExceptionSQL) SQLException(java.sql.SQLException) ResultSetJDBC(org.apache.jena.sdb.sql.ResultSetJDBC) SDBRequest(org.apache.jena.sdb.core.SDBRequest)

Example 2 with SDBRequest

use of org.apache.jena.sdb.core.SDBRequest in project jena by apache.

the class QueryEngineSDB method init.

//    @Override
//    protected Op modifyOp(Op op)
//    { 
//        return op ;
//    }
private void init(DatasetGraphSDB dsg, Query query, Binding initialBinding, Context context) {
    if (context == null)
        context = ARQ.getContext().copy();
    // See "DynamicDatasets" -- this could be enabled.
    if (query != null) {
        if (query.hasDatasetDescription())
            throw new SDBException("Queries with dataset descriptions (FROM/FROM NAMED) not supported");
    }
    if (context.isDefined(ARQConstants.sysDatasetDescription))
        throw new SDBException("Queries with dataset descriptions set in the context not supported");
    this.store = dsg.getStore();
    this.request = new SDBRequest(store, query, context);
    this.originalOp = getOp();
    // Enable transformations : use own choice of transformations.
    // e.g. don't place filters
    // Op op = Algebra.optimize(originalOp, context) ;
    Op op = originalOp;
    // Do property functions.
    op = Transformer.transform(new TransformPropertyFunction(context), op);
    op = Transformer.transform(new TransformFilterEquality(), op);
    // Quad it now so it can be passed to Compile.compile
    op = Algebra.toQuadForm(op);
    // Compile to SQL / extract parts to execute as SQL.
    op = SDBCompile.compile(store, op, initialBinding, context, request);
    setOp(op);
}
Also used : Op(org.apache.jena.sparql.algebra.Op) TransformFilterEquality(org.apache.jena.sparql.algebra.optimize.TransformFilterEquality) SDBException(org.apache.jena.sdb.SDBException) SDBRequest(org.apache.jena.sdb.core.SDBRequest) TransformPropertyFunction(org.apache.jena.sparql.algebra.optimize.TransformPropertyFunction)

Aggregations

SDBRequest (org.apache.jena.sdb.core.SDBRequest)2 SQLException (java.sql.SQLException)1 SDBException (org.apache.jena.sdb.SDBException)1 ResultSetJDBC (org.apache.jena.sdb.sql.ResultSetJDBC)1 SDBExceptionSQL (org.apache.jena.sdb.sql.SDBExceptionSQL)1 Op (org.apache.jena.sparql.algebra.Op)1 TransformFilterEquality (org.apache.jena.sparql.algebra.optimize.TransformFilterEquality)1 TransformPropertyFunction (org.apache.jena.sparql.algebra.optimize.TransformPropertyFunction)1 ExecutionContext (org.apache.jena.sparql.engine.ExecutionContext)1 Context (org.apache.jena.sparql.util.Context)1