/** * Utility to load statements from a resource */ private void load(final URL n3, final RDFFormat rdfFormat) throws IOException, RDFParseException, RepositoryException { final InputStream in = n3.openConnection().getInputStream(); try { final Reader reader = new InputStreamReader(in); // FIXME: Loads into server directly, should change later to load // view ObjectManager final BigdataSailRepositoryConnection m_cxn = repo.getConnection(); try { m_cxn.setAutoCommit(false); m_cxn.add(reader, "kb", rdfFormat); m_cxn.commit(); } finally { m_cxn.close(); } } finally { in.close(); } }
public BigdataGraphBulkLoad(final BigdataSailRepositoryConnection cxn, final BlueprintsValueFactory factory) { super(factory); this.cxn = cxn; this.cxn.addChangeLog(this); }
public StringBuilder dumpStore() throws Exception { final BigdataSailRepositoryConnection cxn = cxn(); cxn.flush(); return cxn.getTripleStore().dumpStore(); }
final BigdataSailRepository repo = new BigdataSailRepository(sail); cxn = (BigdataSailRepositoryConnection) repo.getConnection(); cxn.setAutoCommit(false); final AbstractTripleStore tripleStore = cxn.getTripleStore(); cxn.addChangeLog(changeLog); cxn.setNamespace("ns", ns); cxn.add(stmt); cxn.commit();// cxn.remove(stmt); cxn.commit();// cxn.remove(stmt); cxn.commit();// cxn.close(); sail.__tearDownUnitTest();
assertEquals(0, cxn.getTripleStore().getStatementCount(true)); " << <x:s> <x:p> \"d\" >> <x:order> \"5\"^^xsd:int . " + "}"; final Update update = cxn.prepareUpdate(QueryLanguage.SPARQL, updateStr); update.execute(); assertEquals(2, cxn.getTripleStore().getStatementCount(true)); final RepositoryResult<Statement> result = cxn.getStatements(s,p,o,true); try { int cnt = 0; final BigdataStatement resultStmt = (BigdataStatement) result.next(); final BigdataBNode bNode = vf.createBNode(resultStmt); assertTrue(cxn.hasStatement(bNode, p1, o1, true)); cnt++; " << <x:s> <x:p> \"d\" >> <x:order> \"5\"^^xsd:int . " + "}"; final BooleanQuery tq = cxn.prepareBooleanQuery(QueryLanguage.SPARQL, selectStr); assertTrue(tq.evaluate()); " << <x:s> <x:p> \"d\" >> <x:order> ?o . " + "}"; final TupleQuery tq = cxn.prepareTupleQuery(QueryLanguage.SPARQL, selectStr); final TupleQueryResult tqr = tq.evaluate(); try {
final BigdataSailRepositoryConnection cxn = (BigdataSailRepositoryConnection) repo.getConnection(); cxn.setAutoCommit(false); final Literal l3 = new LiteralImpl("Martyn"); cxn.setNamespace("ns", ns); cxn.add(mike, RDF.TYPE, person); cxn.add(mike, RDFS.LABEL, l1); cxn.add(bryan, RDF.TYPE, person); cxn.add(bryan, RDFS.COMMENT, l2); cxn.add(martyn, RDF.TYPE, person); cxn.add(martyn, p, l3); cxn.flush();//commit(); cxn.commit();// log.info("\n" + cxn.getTripleStore().dumpStore()); cxn.prepareTupleQuery(QueryLanguage.SPARQL, query); final TupleQueryResult result = tupleQuery.evaluate(); cxn.close();
final BigdataSailRepositoryConnection cxn = (BigdataSailRepositoryConnection) repo.getConnection(); cxn.setAutoCommit(false); Literal _45 = vf.createLiteral(45); cxn.add(A, RDF.TYPE, X); cxn.add(B, RDF.TYPE, X); cxn.add(A, AGE, _25); cxn.add(B, AGE, _45); cxn.flush();//commit(); log.info(cxn.getTripleStore().dumpStore()); cxn.prepareTupleQuery(QueryLanguage.SPARQL, query); TupleQueryResult result = tupleQuery.evaluate(); cxn.close(); sail.__tearDownUnitTest();
public void testSimpleSSSP() throws Exception { final BigdataSail sail = getSail(); sail.initialize(); final BigdataSailRepository repo = new BigdataSailRepository(sail); final BigdataSailRepositoryConnection cxn = repo.getConnection(); cxn.setAutoCommit(false); try { cxn.add(open("sssp.ttl"), "", RDFFormat.TURTLE); cxn.commit(); log.trace("\n" + cxn.getTripleStore().dumpStore()); final String query = IOUtils.toString(open("sssp.rq")); log.trace("\n" + query); final TupleQuery tqr = cxn.prepareTupleQuery(QueryLanguage.SPARQL, query); final TupleQueryResult result = tqr.evaluate(); while (result.hasNext()) { log.trace(result.next()); } result.close(); } finally { cxn.close(); sail.__tearDownUnitTest(); } }
String updateString = readUpdateString(); con.begin(); Update update = con.prepareUpdate(QueryLanguage.SPARQL, updateString, requestFileURL); con.commit(); compareGraphs(Iterations.asList(con.getStatements(null, null, null, true, (Resource)null)), Iterations.asList(erCon.getStatements(null, null, null, true, (Resource)null)), (BigdataSailRepositoryConnection) con); URI contextURI = con.getValueFactory().createURI(namedGraph.replaceAll("\"", "")); compareGraphs(Iterations.asList(con.getStatements(null, null, null, true, contextURI)), Iterations.asList(erCon.getStatements(null, null, null, true, contextURI)), (BigdataSailRepositoryConnection) con); if(con.isActive()) { con.rollback(); con.close(); erCon.close();
final BigdataSailRepositoryConnection cxn = (BigdataSailRepositoryConnection) repo.getConnection(); cxn.setAutoCommit(false); assertEquals(0, cxn.getTripleStore().getNamedGraphCount()); assertFalse(cxn.getContextIDs().hasNext()); cxn.add( a, new URIImpl(FOAF+"name"), graphA ); cxn.add( a, new URIImpl(FOAF+"mbox"), cxn.add( b, new URIImpl(FOAF+"name"), graphB ); cxn.add( b, new URIImpl(FOAF+"mbox"), cxn.flush();//commit();
rdfParser.setValueFactory(conn.getTripleStore() .getValueFactory()); .getSailConnection(), nmodified, defaultContext)); conn.commit(); conn.rollback(); conn.close();
/** * Test whether sparql update results in auto-commit. */ public void testCountCommits() throws Exception { BigdataSailRepositoryConnection cxn = null; final BigdataSail sail = getSail(getProperties()); try { sail.initialize(); final BigdataSailRepository repo = new BigdataSailRepository(sail); cxn = (BigdataSailRepositoryConnection) repo.getConnection(); final CommitCounter counter = new CommitCounter(); cxn.addChangeLog(counter); cxn.prepareUpdate(QueryLanguage.SPARQL, "insert data { <x:s> <x:p> \"foo\" . }").execute(); cxn.prepareUpdate(QueryLanguage.SPARQL, "insert data { <x:s> <x:p> \"bar\" . }").execute(); cxn.commit(); assertTrue(counter.n == 1); } finally { if (cxn != null) cxn.close(); sail.__tearDownUnitTest(); } }
repo.initialize(); final BigdataSailRepositoryConnection cxn = repo.getConnection(); cxn.setAutoCommit(false); URI rdf = vf.createURI(ns+"RDF"); cxn.setNamespace("ns", ns); testValueRoundTrip(cxn.getSailConnection(), mike, likes, rdf); log.info(cxn.getTripleStore().dumpStore()); cxn.close(); if (sail instanceof BigdataSail) ((BigdataSail)sail).__tearDownUnitTest();
} finally { if (cxn != null) { if (!success && !cxn.isReadOnly()) { cxn.rollback(); } catch (Throwable t) { log.error(t, t); cxn.close(); } catch (Throwable t) { log.error(t, t);
private void endTest(BigdataSailRepositoryConnection cxn) throws Exception { cxn.close(); cxn.getTripleStore().close(); IJournal store = ((LocalTripleStore)cxn.getTripleStore()).getIndexManager(); store.shutdownNow(); store.destroy(); }
@Override public Void call() throws Exception { final long begin = System.currentTimeMillis(); BigdataSailRepositoryConnection conn = null; try { conn = getQueryConnection(); // Note: We have to align Sail semantics for Resource... with the // REST API. final boolean found = conn.hasStatement(s, p, o, includeInferred, c == null ? new Resource[0] : c); final long elapsed = System.currentTimeMillis() - begin; buildAndCommitBooleanResponse(resp, found, elapsed); return null; } finally { if (conn != null) { conn.close(); } } }