public BigdataGraphBulkLoad(final BigdataSailRepositoryConnection cxn, final BlueprintsValueFactory factory) { super(factory); this.cxn = cxn; this.cxn.addChangeLog(this); }
cxn.addChangeLog(new IChangeLog(){
cxn.addChangeLog(new IChangeLog(){
public BigdataSailRepositoryConnection cxn() throws Exception { /* * Asking for the connection locks the graph to the current thread * until released by commit() or rollback(). */ if (!lock.isHeldByCurrentThread()) { lock.lock(); } if (cxn == null) { cxn = repo.getUnisolatedConnection(); cxn.addChangeLog(BigdataGraphEmbedded.this); } return cxn; }
/** * Return a connection for the namespace. If the task is associated with * either a read/write transaction or an {@link ITx#UNISOLATED} view of the * indices, the connection may be used to read or write on the namespace. * Otherwise the connection will be read-only. * * @return The connection. * * @throws SailException * @throws RepositoryException * @throws DatasetNotFoundException * if the specified namespace does not exist. */ protected BigdataSailRepositoryConnection getConnection() throws SailException, RepositoryException { // Wrap with SAIL. final BigdataSail sail = new BigdataSail(namespace, getIndexManager()); final BigdataSailRepository repo = new BigdataSailRepository(sail); repo.initialize(); final BigdataSailRepositoryConnection conn = repo.getConnection(); conn.setAutoCommit(false); // Setup a change listener. It will notice the #of mutations. conn.addChangeLog(new SailChangeLog()); return conn; }
/** * Return a connection for the namespace. If the task is associated with * either a read/write transaction or an {@link ITx#UNISOLATED} view of the * indices, the connection may be used to read or write on the namespace. * Otherwise the connection will be read-only. * * @return The connection. * * @throws SailException * @throws RepositoryException * @throws DatasetNotFoundException * if the specified namespace does not exist. */ protected BigdataSailRepositoryConnection getConnection() throws SailException, RepositoryException { // Wrap with SAIL. final BigdataSail sail = new BigdataSail(namespace, getIndexManager()); final BigdataSailRepository repo = new BigdataSailRepository(sail); repo.initialize(); final BigdataSailRepositoryConnection conn = repo.getConnection(); conn.setAutoCommit(false); // Setup a change listener. It will notice the #of mutations. conn.addChangeLog(new SailChangeLog()); return conn; }
cxn.addChangeLog(changeLog);
cxn.addChangeLog(changeLog); cxn.addChangeLog(changeLog2);
cxn.addChangeLog(changeLog);
cxn.addChangeLog(changeLog);
cxn.addChangeLog(changeLog);
cxn.addChangeLog(changeLog);
/** * 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(); } }
cxn.addChangeLog(changeLog);
cxn.addChangeLog(changeLog); cxn.addChangeLog(changeLog2);
cxn.addChangeLog(changeLog);
cxn.addChangeLog(changeLog);
cxn.addChangeLog(changeLog);
cxn.addChangeLog(changeLog);
/** * 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(); } }