/** * 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; }
private IIndexManager getIndexManager() { final BigdataSailRepository repo = (BigdataSailRepository) this.getRepository(); final IIndexManager indexMgr = repo.getSail().getIndexManager(); return indexMgr; }
public void testBufferCapacity() throws Exception { final BigdataSail sail = getSail(); final BigdataSailRepository repo = new BigdataSailRepository(sail); repo.initialize(); try { // This configuration exceeds StatementBuffer capacity executeQuery(repo, Integer.valueOf(BigdataSail.Options.DEFAULT_BUFFER_CAPACITY) * 5, 1); } finally { repo.shutDown(); sail.__tearDownUnitTest(); } }
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 ; }
BigdataSailRepository repo = new BigdataSailRepository(sail); try { repo.initialize(); final RepositoryConnection conn = repo.getConnection(); conn.setAutoCommit(false); try { repo.shutDown();
/** * Create a Blueprints wrapper around a {@link BigdataSail} instance with * a non-standard {@link BlueprintsValueFactory} implementation. */ public BigdataGraphEmbedded(final BigdataSail sail, final BlueprintsValueFactory factory, final Properties props) { this(new BigdataSailRepository(sail), factory, props); }
final BigdataSailRepository bigdataRepo = new BigdataSailRepository(sail); final RepositoryConnection cxn = bigdataRepo.getConnection(); try { cxn.setAutoCommit(false); final BigdataSailRepositoryConnection cxn = bigdataRepo.getReadOnlyConnection(); try {
/** * 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; }
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(); } }
protected void setUp() throws Exception { // instantiate a sail and a Sesame repository m_sail = new BigdataSail(getProperties()); m_repo = new BigdataSailRepository(m_sail); m_repo.initialize(); m_vf = m_sail.getValueFactory(); // Note: This uses a mock endpoint URL. om = new ObjectManager("http://localhost" + BigdataStatics.getContextPath() + "/sparql", m_repo); }
repo = new BigdataSailRepository(sail); repo.initialize(); m_indexManager = repo.getSail().getIndexManager(); m_server = NanoSparqlServer.newInstance(0/* port */, m_indexManager, initParams);
try { sail.initialize(); final BigdataSailRepository repo = new BigdataSailRepository(sail); final RepositoryConnection tx1 = repo.getReadWriteConnection(); tx1.setAutoCommit(false); final RepositoryConnection tx2 = repo.getReadWriteConnection(); tx2.setAutoCommit(false); RepositoryConnection view = repo.getReadOnlyConnection();
/** * Return a read-only connection. * * @throws RepositoryException */ private BigdataSailRepositoryConnection getQueryConnection() throws RepositoryException { final BigdataSailRepositoryConnection c = m_repo .getReadOnlyConnection(); return c; }
final Repository repo = new BigdataSailRepository(sail); // create a Sesame repository cxn = ((BigdataSailRepository) repo).getReadOnlyConnection(); } else { cxn = repo.getConnection();
private void doTicket473Commit(final BigdataSail sail) throws Exception { final BigdataSailRepository repo = new BigdataSailRepository(sail); final BigdataSailRepositoryConnection conn = (BigdataSailRepositoryConnection) repo .getUnisolatedConnection(); conn.setAutoCommit(false);
/** * Return an updatable connection. * * @throws RepositoryException */ private BigdataSailRepositoryConnection getConnection() throws RepositoryException { final BigdataSailRepositoryConnection c = m_repo.getConnection(); c.setAutoCommit(false); return c; }
super(endpoint, (BigdataValueFactory) cxn.getValueFactory()); this.readOnly = !cxn.isWritable(); .getSail().getIndexManager());
@Override public void shutdown() { try { try { if (autocommitOnShutdown) { /* * Auto-commit on close. */ commit(); } } finally { repo.shutDown(); } } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException(e); } }
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; }