use of org.apache.jena.sdb.Store in project jena by apache.
the class TestAssembler method create.
private Store create(Model assem) {
// Create a store and format
Dataset ds = DatasetFactory.assemble(assem);
Store store = ((DatasetGraphSDB) ds.asDatasetGraph()).getStore();
store.getTableFormatter().create();
return store;
}
use of org.apache.jena.sdb.Store in project jena by apache.
the class TestAssembler method model_4.
@Test
public void model_4() {
Model assem = FileManager.get().loadModel(dir + "graph-assembler.ttl");
Resource xDft = assem.getResource("http://example/test#graphDft");
Resource xNamed = assem.getResource("http://example/test#graphNamed");
Store store = create(assem);
Model model1 = (Model) Assembler.general.open(xDft);
Model model2 = (Model) Assembler.general.open(xNamed);
// Check they are not connected to the same place in the store
Resource s = model1.createResource();
Property p = model1.createProperty("http://example/p");
Literal o = model1.createLiteral("foo");
model1.add(s, p, o);
assertTrue(model1.contains(s, p, o));
assertTrue(model1.size() == 1);
assertTrue(model2.size() == 0);
assertFalse(model1.isIsomorphicWith(model2));
}
use of org.apache.jena.sdb.Store in project jena by apache.
the class ExModelSDB method main.
public static void main(String... argv) {
Store store = StoreFactory.create("sdb.ttl");
Model model = SDBFactory.connectDefaultModel(store);
StmtIterator sIter = model.listStatements();
for (; sIter.hasNext(); ) {
Statement stmt = sIter.nextStatement();
System.out.println(stmt);
}
sIter.close();
store.close();
}
use of org.apache.jena.sdb.Store in project jena by apache.
the class Ex2 method main.
public static void main(String... argv) {
String queryString = "SELECT * { ?s ?p ?o }";
Query query = QueryFactory.create(queryString);
StoreDesc storeDesc = new StoreDesc(LayoutType.LayoutTripleNodesHash, DatabaseType.Derby);
// Multiple choices for Derby - load the embedded driver
JDBC.loadDriverDerby();
String jdbcURL = "jdbc:derby:DB/SDB2";
// Passing null for user and password causes them to be extracted
// from the environment variables SDB_USER and SDB_PASSWORD
SDBConnection conn = new SDBConnection(jdbcURL, null, null);
// Make store from connection and store description.
Store store = SDBFactory.connectStore(conn, storeDesc);
Dataset ds = DatasetStore.create(store);
QueryExecution qe = QueryExecutionFactory.create(query, ds);
try {
ResultSet rs = qe.execSelect();
ResultSetFormatter.out(rs);
} finally {
qe.close();
}
store.close();
}
use of org.apache.jena.sdb.Store in project jena by apache.
the class Ex1 method main.
public static void main(String... argv) {
String queryString = "SELECT * { ?s ?p ?o }";
Query query = QueryFactory.create(queryString);
Store store = SDBFactory.connectStore("sdb.ttl");
// Must be a DatasetStore to trigger the SDB query engine.
// Creating a graph from the Store, and adding it to a general
// purpose dataset will not necesarily exploit full SQL generation.
// The right answers will be obtained but slowly.
Dataset ds = DatasetStore.create(store);
QueryExecution qe = QueryExecutionFactory.create(query, ds);
try {
ResultSet rs = qe.execSelect();
ResultSetFormatter.out(rs);
} finally {
qe.close();
}
// Close the SDB conenction which also closes the underlying JDBC connection.
store.getConnection().close();
store.close();
}
Aggregations