Search in sources :

Example 1 with GraphTDB

use of org.apache.jena.tdb2.store.GraphTDB in project jena by apache.

the class StageGeneratorDirectTDB method execute.

@Override
public QueryIterator execute(BasicPattern pattern, QueryIterator input, ExecutionContext execCxt) {
    // --- In case this isn't for TDB2
    Graph g = execCxt.getActiveGraph();
    if (g instanceof GraphViewSwitchable) {
        GraphViewSwitchable gvs = (GraphViewSwitchable) g;
        g = gvs.getBaseGraph();
    }
    if (!(g instanceof GraphTDB))
        // Not us - bounce up the StageGenerator chain
        return above.execute(pattern, input, execCxt);
    GraphTDB graph = (GraphTDB) g;
    Predicate<Tuple<NodeId>> filter = QC2.getFilter(execCxt.getContext());
    return PatternMatchTDB2.execute(graph, pattern, input, filter, execCxt);
}
Also used : Graph(org.apache.jena.graph.Graph) GraphViewSwitchable(org.apache.jena.tdb2.store.GraphViewSwitchable) GraphTDB(org.apache.jena.tdb2.store.GraphTDB) Tuple(org.apache.jena.atlas.lib.tuple.Tuple)

Example 2 with GraphTDB

use of org.apache.jena.tdb2.store.GraphTDB in project jena by apache.

the class OpExecutorTDB2 method execute.

@Override
protected QueryIterator execute(OpFilter opFilter, QueryIterator input) {
    if (!isForTDB)
        return super.execute(opFilter, input);
    // (filter (bgp ...))
    if (OpBGP.isBGP(opFilter.getSubOp())) {
        // Still may be a TDB graph in a non-TDB dataset (e.g. a named model)
        GraphTDB graph = (GraphTDB) execCxt.getActiveGraph();
        OpBGP opBGP = (OpBGP) opFilter.getSubOp();
        return executeBGP(graph, opBGP, input, opFilter.getExprs(), execCxt);
    }
    // (filter (quadpattern ...))
    if (opFilter.getSubOp() instanceof OpQuadPattern) {
        OpQuadPattern quadPattern = (OpQuadPattern) opFilter.getSubOp();
        DatasetGraphTDB ds = (DatasetGraphTDB) execCxt.getDataset();
        return optimizeExecuteQuads(ds, input, quadPattern.getGraphNode(), quadPattern.getBasicPattern(), opFilter.getExprs(), execCxt);
    }
    // (filter (anything else))
    return super.execute(opFilter, input);
}
Also used : GraphTDB(org.apache.jena.tdb2.store.GraphTDB) DatasetGraphTDB(org.apache.jena.tdb2.store.DatasetGraphTDB) DatasetGraphTDB(org.apache.jena.tdb2.store.DatasetGraphTDB)

Aggregations

GraphTDB (org.apache.jena.tdb2.store.GraphTDB)2 Tuple (org.apache.jena.atlas.lib.tuple.Tuple)1 Graph (org.apache.jena.graph.Graph)1 DatasetGraphTDB (org.apache.jena.tdb2.store.DatasetGraphTDB)1 GraphViewSwitchable (org.apache.jena.tdb2.store.GraphViewSwitchable)1