use of org.apache.jena.query.Dataset in project jena by apache.
the class SpatialDatasetAssembler method open.
// private DatasetAssembler datasetAssembler = new DatasetAssembler() ;
//
// public static Resource getType() { return textDataset ; }
/*
<#spatial_dataset> rdf:type spatial:SpatialDataset ;
spatial:dataset <#dataset> ;
spatial:index <#index> ;
.
*/
@Override
public Dataset open(Assembler a, Resource root, Mode mode) {
Resource dataset = GraphUtils.getResourceValue(root, pDataset);
Resource index = GraphUtils.getResourceValue(root, pIndex);
Dataset ds = (Dataset) a.open(dataset);
SpatialIndex textIndex = (SpatialIndex) a.open(index);
Dataset dst = SpatialDatasetFactory.create(ds, textIndex);
return dst;
}
use of org.apache.jena.query.Dataset in project jena by apache.
the class ExTDB_Txn2 method main.
public static void main(String... argv) {
String directory = "MyDatabases/DB1";
Dataset dataset = TDBFactory.createDataset(directory);
// Start WRITE transaction.
// It's possible to read from the datet inside the write transaction.
// An application can have other Datasets, in the same JVM,
// tied to the same TDB database performing read
// transactions concurrently. If another write transaction
// starts, the call of dataset.begin(WRITE) blocks until
// existing writer finishes.
dataset.begin(ReadWrite.WRITE);
try {
GraphStore graphStore = GraphStoreFactory.create(dataset);
// Do a SPARQL Update.
String sparqlUpdateString = StrUtils.strjoinNL("PREFIX . <http://example/>", "INSERT { :s :p ?now } WHERE { BIND(now() AS ?now) }");
execUpdate(sparqlUpdateString, graphStore);
dataset.commit();
// Or call .abort()
} finally {
// Notify the end of the transaction.
// The transaction was finished at the point .commit or .abort was called.
// .end will force an abort() if no previous call to .commit() or .abort()
// has occurred, so .end() help manage track the state of the transaction.
// .end() can be called multiple times for the same .begin(WRITE)
dataset.end();
}
}
use of org.apache.jena.query.Dataset in project jena by apache.
the class TestSpatialDatasetAssembler method testSimpleDatasetAssembler.
@Test
public void testSimpleDatasetAssembler() {
Dataset dataset = (Dataset) Assembler.general.open(spec1);
assertTrue(dataset.getContext().get(SpatialQuery.spatialIndex) instanceof SpatialIndexLucene);
}
use of org.apache.jena.query.Dataset in project jena by apache.
the class ExTDB1 method main.
public static void main(String... argv) {
// Direct way: Make a TDB-back Jena model in the named directory.
String directory = "MyDatabases/DB1";
Dataset ds = TDBFactory.createDataset(directory);
Model model = ds.getDefaultModel();
// ... do work ...
// Close the dataset.
ds.close();
}
use of org.apache.jena.query.Dataset in project jena by apache.
the class ExTDB2 method main.
public static void main(String... argv) {
String assemblerFile = "Store/tdb-assembler.ttl";
Dataset ds = TDBFactory.assembleDataset(assemblerFile);
// ... do work ...
ds.close();
}
Aggregations