Search in sources :

Example 76 with DatasetGraph

use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.

the class AbstractStoreConnections method store_5.

@Test
public void store_5() {
    // No transaction. Make sure StoreConnection.release cleans up OK.
    StoreConnection sConn = getStoreConnection();
    Location loc = sConn.getLocation();
    DatasetGraph dsg = sConn.getBaseDataset();
    dsg.add(q);
    assertTrue(dsg.contains(q));
    StoreConnection.release(loc);
    sConn = StoreConnection.make(loc);
    dsg = sConn.getBaseDataset();
    assertTrue(dsg.contains(q));
}
Also used : StoreConnection(org.apache.jena.tdb.StoreConnection) Location(org.apache.jena.tdb.base.file.Location) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Test(org.junit.Test) ConfigTest(org.apache.jena.tdb.ConfigTest) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 77 with DatasetGraph

use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.

the class QueryExecutionBase method execConstructDataset.

@Override
public Dataset execConstructDataset(Dataset dataset) {
    DatasetGraph dsg = dataset.asDatasetGraph();
    try {
        execConstructQuads().forEachRemaining(dsg::add);
        insertPrefixesInto(dataset);
    } finally {
        this.close();
    }
    return dataset;
}
Also used : DatasetGraph(org.apache.jena.sparql.core.DatasetGraph)

Example 78 with DatasetGraph

use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.

the class QueryExecutionBase method init.

private void init() {
    DatasetGraph dsg = (dataset == null) ? null : dataset.asDatasetGraph();
    context = Context.setupContext(context, dsg);
    if (query != null)
        context.put(ARQConstants.sysCurrentQuery, query);
    // NB: Setting timeouts via the context after creating a QueryExecutionBase 
    // will not work. But we can't move it until the point the execution starts because of
    // get and set timeout operations on this object.   
    setAnyTimeouts();
}
Also used : DatasetGraph(org.apache.jena.sparql.core.DatasetGraph)

Example 79 with DatasetGraph

use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.

the class QueryExecutionBase method prepareDataset.

private static DatasetGraph prepareDataset(Dataset dataset, Query query) {
    if (dataset != null)
        return dataset.asDatasetGraph();
    if (!query.hasDatasetDescription())
        //Query.Log.warn(this, "No data for query (no URL, no model)");
        throw new QueryExecException("No dataset description for query");
    String baseURI = query.getBaseURI();
    if (baseURI == null)
        baseURI = IRIResolver.chooseBaseURI().toString();
    DatasetGraph dsg = DatasetUtils.createDatasetGraph(query.getDatasetDescription(), baseURI);
    return dsg;
}
Also used : DatasetGraph(org.apache.jena.sparql.core.DatasetGraph)

Example 80 with DatasetGraph

use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.

the class QueryExecutionBase method getPlan.

public Plan getPlan() {
    if (plan == null) {
        DatasetGraph dsg = prepareDataset(dataset, query);
        Binding inputBinding = null;
        if (initialBinding != null)
            inputBinding = BindingUtils.asBinding(initialBinding);
        if (inputBinding == null)
            inputBinding = BindingRoot.create();
        plan = qeFactory.create(query, dsg, inputBinding, getContext());
    }
    return plan;
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph)

Aggregations

DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)222 Test (org.junit.Test)132 BaseTest (org.apache.jena.atlas.junit.BaseTest)59 Quad (org.apache.jena.sparql.core.Quad)47 Node (org.apache.jena.graph.Node)29 Graph (org.apache.jena.graph.Graph)18 StoreConnection (org.apache.jena.tdb.StoreConnection)17 DatasetGraphTxn (org.apache.jena.tdb.transaction.DatasetGraphTxn)15 Model (org.apache.jena.rdf.model.Model)10 IOException (java.io.IOException)7 Triple (org.apache.jena.graph.Triple)7 Dataset (org.apache.jena.query.Dataset)7 StreamRDF (org.apache.jena.riot.system.StreamRDF)7 ReentrantReadWriteLock (java.util.concurrent.locks.ReentrantReadWriteLock)5 ResultSet (org.apache.jena.query.ResultSet)5 JsonLDWriteContext (org.apache.jena.riot.JsonLDWriteContext)5 Element (org.apache.jena.sparql.syntax.Element)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 RiotException (org.apache.jena.riot.RiotException)4 QueryIterator (org.apache.jena.sparql.engine.QueryIterator)4