/** * Return an updatable connection. * * @throws RepositoryException */ private BigdataSailRepositoryConnection getConnection() throws RepositoryException { final BigdataSailRepositoryConnection c = m_repo.getConnection(); c.setAutoCommit(false); return c; }
/** * Return an updatable connection. * * @throws RepositoryException */ private BigdataSailRepositoryConnection getConnection() throws RepositoryException { final BigdataSailRepositoryConnection c = m_repo.getConnection(); c.setAutoCommit(false); return c; }
private RepositoryConnection getRepositoryConnection ( final BigdataSail sail ) throws RepositoryException { final BigdataSailRepository repo = new BigdataSailRepository ( sail ) ; final BigdataSailRepositoryConnection cxn = ( BigdataSailRepositoryConnection )repo.getConnection () ; cxn.setAutoCommit ( false ) ; return cxn ; }
private BigdataSailRepositoryConnection prepareTest(final String namespace, final boolean inlineTextLiterals, final boolean inlineXSDDatatypeLiterals, final boolean textIndexDatatypeLiterals) throws Exception { final Properties properties = getProperties(); { properties.setProperty(com.bigdata.rdf.sail.BigdataSail.Options.NAMESPACE, namespace); properties.setProperty("com.bigdata.namespace."+namespace+".lex."+Options.INLINE_TEXT_LITERALS, Boolean.toString(inlineTextLiterals)); if (inlineTextLiterals) { properties.setProperty("com.bigdata.namespace."+namespace+".lex."+Options.MAX_INLINE_TEXT_LENGTH, Integer.toString(45)); } properties.setProperty("com.bigdata.namespace."+namespace+".lex."+Options.INLINE_XSD_DATATYPE_LITERALS, Boolean.toString(inlineXSDDatatypeLiterals)); properties.setProperty("com.bigdata.namespace."+namespace+".lex."+Options.TEXT_INDEX_DATATYPE_LITERALS, Boolean.toString(textIndexDatatypeLiterals)); properties.setProperty("com.bigdata.namespace."+namespace+".lex."+Options.STORE_BLANK_NODES, Boolean.toString(true)); } final BigdataSail sail = getSail(properties); sail.initialize(); final BigdataSailRepository repo = new BigdataSailRepository(sail); return (BigdataSailRepositoryConnection) repo.getConnection(); }
/** * 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(); } }
/** * Utility to load statements from a resource */ @Override public 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(); } }
private void executeUpdate(final BigdataSailRepository repo, final String update) throws UpdateExecutionException, RepositoryException, MalformedQueryException { final BigdataSailRepositoryConnection conn = repo.getConnection(); try { Update preparedUpdate = conn.prepareUpdate(QueryLanguage.SPARQL, update); preparedUpdate.execute(); // no exception should occur on execution, overwise test will fail } finally { conn.close(); } }
/** * Utility to load statements from a resource */ @Override public 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(); } }
/** * 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(); } }
private BigdataSailRepositoryConnection prepareTest(final String namespace, final boolean inlineTextLiterals, final boolean inlineXSDDatatypeLiterals, final boolean textIndexDatatypeLiterals) throws Exception { final Properties properties = getProperties(); { properties.setProperty(com.bigdata.rdf.sail.BigdataSail.Options.NAMESPACE, namespace); properties.setProperty("com.bigdata.namespace."+namespace+".lex."+Options.INLINE_TEXT_LITERALS, Boolean.toString(inlineTextLiterals)); if (inlineTextLiterals) { properties.setProperty("com.bigdata.namespace."+namespace+".lex."+Options.MAX_INLINE_TEXT_LENGTH, Integer.toString(45)); } properties.setProperty("com.bigdata.namespace."+namespace+".lex."+Options.INLINE_XSD_DATATYPE_LITERALS, Boolean.toString(inlineXSDDatatypeLiterals)); properties.setProperty("com.bigdata.namespace."+namespace+".lex."+Options.TEXT_INDEX_DATATYPE_LITERALS, Boolean.toString(textIndexDatatypeLiterals)); properties.setProperty("com.bigdata.namespace."+namespace+".lex."+Options.STORE_BLANK_NODES, Boolean.toString(true)); } final BigdataSail sail = getSail(properties); sail.initialize(); final BigdataSailRepository repo = new BigdataSailRepository(sail); return (BigdataSailRepositoryConnection) repo.getConnection(); }
private RepositoryConnection getRepositoryConnection ( final BigdataSail sail ) throws RepositoryException { final BigdataSailRepository repo = new BigdataSailRepository ( sail ) ; final BigdataSailRepositoryConnection cxn = ( BigdataSailRepositoryConnection )repo.getConnection () ; cxn.setAutoCommit ( false ) ; return cxn ; }
private void executeQuery(final BigdataSailRepository repo) throws UpdateExecutionException, RepositoryException, MalformedQueryException { try { repo.initialize(); final BigdataSailRepositoryConnection conn = repo.getConnection(); try { String update = "insert {" + "<http://dbpedia.org/resource/Jules_Verne> <http://dbpedia.org/property/period> \"\"^^<http://www.w3.org/2001/XMLSchema#int>\r\n" + "} where {}"; Update preparedUpdate = conn.prepareUpdate(QueryLanguage.SPARQL, update); preparedUpdate.execute(); // no exception should occur on execution, overwise test will fail } finally { conn.close(); } } finally { repo.shutDown(); } }
private void executeUpdate(final BigdataSailRepository repo, final String update) throws UpdateExecutionException, RepositoryException, MalformedQueryException { final BigdataSailRepositoryConnection conn = repo.getConnection(); try { Update preparedUpdate = conn.prepareUpdate(QueryLanguage.SPARQL, update); preparedUpdate.execute(); // no exception should occur on execution, overwise test will fail } finally { conn.close(); } }
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(); } }
/** * This version uses the namespace and timestamp provided by the caller. * * @param namespace * @param timestamp * @return * @throws RepositoryException * @throws DatasetNotFoundException */ protected BigdataSailRepositoryConnection getQueryConnection( final String namespace, final long timestamp) throws RepositoryException { // Wrap with SAIL. final BigdataSail sail = new BigdataSail(namespace, getIndexManager()); final BigdataSailRepository repo = new BigdataSailRepository(sail); repo.initialize(); if (TimestampUtility.isReadOnly(timestamp)) { return (BigdataSailRepositoryConnection) repo.getReadOnlyConnection(timestamp); } // Read-write connection. final BigdataSailRepositoryConnection conn = repo.getConnection(); conn.setAutoCommit(false); return conn; }
final BigdataSailRepository repo = new BigdataSailRepository(sail); repo.initialize(); final BigdataSailRepositoryConnection cxn = repo.getConnection(); cxn.setAutoCommit(false);
private void executeQuery(final BigdataSailRepository repo) throws UpdateExecutionException, RepositoryException, MalformedQueryException { try { repo.initialize(); final BigdataSailRepositoryConnection conn = repo.getConnection(); try { String update = "insert {" + "<http://dbpedia.org/resource/Jules_Verne> <http://dbpedia.org/property/period> \"\"^^<http://www.w3.org/2001/XMLSchema#int>\r\n" + "} where {}"; Update preparedUpdate = conn.prepareUpdate(QueryLanguage.SPARQL, update); preparedUpdate.execute(); // no exception should occur on execution, overwise test will fail } finally { conn.close(); } } finally { repo.shutDown(); } }
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(); } }
final BigdataSailRepository repo = new BigdataSailRepository(sail); repo.initialize(); final BigdataSailRepositoryConnection cxn = repo.getConnection(); cxn.setAutoCommit(false);
/** * 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(); } }