use of org.apache.jena.query.Dataset in project jena by apache.
the class TestDatasetGraphInMemoryBasic method prefixesAreManaged.
@Test
public void prefixesAreManaged() {
final Node graphName = createURI("http://example/g");
final DatasetGraph dsg = emptyDataset();
dsg.addGraph(graphName, createGraphMem());
final Dataset dataset = DatasetFactory.wrap(dsg);
Model model = dataset.getNamedModel(graphName.getURI());
final String testPrefix = "example";
final String testURI = "http://example/";
model.setNsPrefix(testPrefix, testURI);
assertEquals(testURI, model.getNsPrefixURI(testPrefix));
model.close();
model = dataset.getNamedModel(graphName.getURI());
final String nsURI = dataset.getNamedModel(graphName.getURI()).getNsPrefixURI(testPrefix);
assertNotNull(nsURI);
assertEquals(testURI, nsURI);
}
use of org.apache.jena.query.Dataset in project jena by apache.
the class AbstractTestDataset method dataset_01.
@Test
public void dataset_01() {
Dataset ds = createDataset();
assertNotNull(ds.getDefaultModel());
assertNotNull(ds.asDatasetGraph());
}
use of org.apache.jena.query.Dataset in project jena by apache.
the class AbstractTestDataset method dataset_03.
@Test
public void dataset_03() {
Dataset ds = createDataset();
ds.setDefaultModel(model2);
assertTrue(model2.isIsomorphicWith(ds.getDefaultModel()));
}
use of org.apache.jena.query.Dataset in project jena by apache.
the class AbstractTestDataset method dataset_04.
@Test
public void dataset_04() {
String graphName = "http://example/";
Dataset ds = createDataset();
ds.addNamedModel(graphName, model1);
assertTrue(ds.containsNamedModel(graphName));
List<String> x = Iter.toList(ds.listNames());
assertEquals(1, x.size());
assertEquals(graphName, x.get(0));
assertFalse(model1.isIsomorphicWith(ds.getDefaultModel()));
Model m = ds.getNamedModel(graphName);
assertNotNull(m);
assertTrue(model1.isIsomorphicWith(m));
ds.removeNamedModel(graphName);
// Not getNamedModel and test for null as some datasets are "auto graph creating"
assertFalse(ds.containsNamedModel(graphName));
}
use of org.apache.jena.query.Dataset in project jena by apache.
the class sse_query method exec.
@Override
protected void exec() {
Op op = modAlgebra.getOp();
if (op == null) {
System.err.println("No query expression to execute");
throw new TerminationException(9);
}
Dataset dataset = modDataset.getDataset();
// Check there is a dataset.
if (dataset == null)
dataset = DatasetFactory.createGeneral();
modTime.startTimer();
DatasetGraph dsg = dataset.asDatasetGraph();
if (printOp || printPlan) {
if (printOp) {
divider();
IndentedWriter out = new IndentedWriter(System.out, true);
op.output(out);
out.flush();
}
if (printPlan) {
QueryIterator qIter = Algebra.exec(op, dsg);
Plan plan = new PlanOp(op, null, qIter);
divider();
IndentedWriter out = new IndentedWriter(System.out, false);
plan.output(out);
out.flush();
}
//return ;
}
// Do not optimize. Execute as-is.
QueryExecUtils.execute(op, dsg, modResults.getResultsFormat());
long time = modTime.endTimer();
if (modTime.timingEnabled())
System.out.println("Time: " + modTime.timeStr(time));
}
Aggregations