Search in sources :

Example 1 with GraphViewSwitchable

use of org.apache.jena.tdb2.store.GraphViewSwitchable 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 GraphViewSwitchable

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

the class TestTDBAssembler method testGraph.

private static void testGraph(String assemblerFile, boolean named) {
    Object thing = null;
    try {
        thing = AssemblerUtils.build(assemblerFile, VocabTDB2.tGraphTDB);
    } catch (AssemblerException e) {
        e.getCause().printStackTrace(System.err);
        throw e;
    }
    assertTrue(thing instanceof Model);
    Graph graph = ((Model) thing).getGraph();
    assertTrue(graph instanceof GraphViewSwitchable);
    DatasetGraphSwitchable dsg = ((GraphViewSwitchable) graph).getDataset();
    if (dsg != null)
        dsg.close();
}
Also used : Graph(org.apache.jena.graph.Graph) GraphViewSwitchable(org.apache.jena.tdb2.store.GraphViewSwitchable) AssemblerException(org.apache.jena.assembler.exceptions.AssemblerException) Model(org.apache.jena.rdf.model.Model) DatasetGraphSwitchable(org.apache.jena.tdb2.store.DatasetGraphSwitchable)

Example 3 with GraphViewSwitchable

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

the class TestTDBAssembler method createGraphEmbed.

@Test
public void createGraphEmbed() {
    String f = dirAssem + "/tdb-graph-embed.ttl";
    Object thing = null;
    try {
        thing = AssemblerUtils.build(f, JA.Model);
    } catch (AssemblerException e) {
        e.getCause().printStackTrace(System.err);
        throw e;
    }
    assertTrue(thing instanceof Model);
    Graph graph = ((Model) thing).getGraph();
    assertTrue(graph instanceof GraphViewSwitchable);
    DatasetGraphSwitchable ds = ((GraphViewSwitchable) graph).getDataset();
    if (ds != null)
        ds.close();
}
Also used : Graph(org.apache.jena.graph.Graph) GraphViewSwitchable(org.apache.jena.tdb2.store.GraphViewSwitchable) AssemblerException(org.apache.jena.assembler.exceptions.AssemblerException) Model(org.apache.jena.rdf.model.Model) DatasetGraphSwitchable(org.apache.jena.tdb2.store.DatasetGraphSwitchable) Test(org.junit.Test) ConfigTest(org.apache.jena.tdb2.ConfigTest)

Aggregations

Graph (org.apache.jena.graph.Graph)3 GraphViewSwitchable (org.apache.jena.tdb2.store.GraphViewSwitchable)3 AssemblerException (org.apache.jena.assembler.exceptions.AssemblerException)2 Model (org.apache.jena.rdf.model.Model)2 DatasetGraphSwitchable (org.apache.jena.tdb2.store.DatasetGraphSwitchable)2 Tuple (org.apache.jena.atlas.lib.tuple.Tuple)1 ConfigTest (org.apache.jena.tdb2.ConfigTest)1 GraphTDB (org.apache.jena.tdb2.store.GraphTDB)1 Test (org.junit.Test)1