Search in sources :

Example 56 with SailRepositoryConnection

use of org.openrdf.repository.sail.SailRepositoryConnection in project incubator-rya by apache.

the class RyaMongoDbSailFactoryTest method testCreateMongoDbSail.

@Test
public void testCreateMongoDbSail() throws Exception {
    Sail sail = null;
    SailRepository repo = null;
    SailRepositoryConnection conn = null;
    try {
        sail = RyaSailFactory.getInstance(conf);
        repo = new SailRepository(sail);
        conn = repo.getConnection();
    } finally {
        if (conn != null) {
            conn.close();
        }
        if (repo != null) {
            repo.shutDown();
        }
        if (sail != null) {
            sail.shutDown();
        }
    }
}
Also used : SailRepository(org.openrdf.repository.sail.SailRepository) Sail(org.openrdf.sail.Sail) SailRepositoryConnection(org.openrdf.repository.sail.SailRepositoryConnection) Test(org.junit.Test)

Example 57 with SailRepositoryConnection

use of org.openrdf.repository.sail.SailRepositoryConnection in project incubator-rya by apache.

the class RyaMongoDbSailFactoryTest method testAddStatement.

@Test
public void testAddStatement() throws Exception {
    Sail sail = null;
    SailRepository repo = null;
    SailRepositoryConnection conn = null;
    try {
        sail = RyaSailFactory.getInstance(conf);
        repo = new SailRepository(sail);
        conn = repo.getConnection();
        final ValueFactory vf = conn.getValueFactory();
        final Statement s = vf.createStatement(vf.createURI("u:a"), vf.createURI("u:b"), vf.createURI("u:c"));
        assertFalse(conn.hasStatement(s, false));
        conn.add(s);
        Assert.assertTrue(conn.hasStatement(s, false));
    } finally {
        if (conn != null) {
            conn.close();
        }
        if (repo != null) {
            repo.shutDown();
        }
        if (sail != null) {
            sail.shutDown();
        }
    }
}
Also used : SailRepository(org.openrdf.repository.sail.SailRepository) Sail(org.openrdf.sail.Sail) Statement(org.openrdf.model.Statement) ValueFactory(org.openrdf.model.ValueFactory) SailRepositoryConnection(org.openrdf.repository.sail.SailRepositoryConnection) Test(org.junit.Test)

Example 58 with SailRepositoryConnection

use of org.openrdf.repository.sail.SailRepositoryConnection in project incubator-rya by apache.

the class RyaMongoDbSailFactoryTest method testReuseSail.

@Test
public void testReuseSail() throws Exception {
    Sail sail = null;
    SailRepository repo = null;
    SailRepositoryConnection conn = null;
    try {
        sail = RyaSailFactory.getInstance(conf);
        repo = new SailRepository(sail);
        conn = repo.getConnection();
        final ValueFactory vf = conn.getValueFactory();
        final Statement s = vf.createStatement(vf.createURI("u:a"), vf.createURI("u:b"), vf.createURI("u:c"));
        assertFalse(conn.hasStatement(s, false));
        conn.add(s);
        Assert.assertTrue(conn.hasStatement(s, false));
        conn.remove(s);
        Assert.assertFalse(conn.hasStatement(s, false));
    } finally {
        if (conn != null) {
            conn.close();
        }
        if (repo != null) {
            repo.shutDown();
        }
        if (sail != null) {
            sail.shutDown();
        }
    }
    // Reuse Sail after shutdown
    try {
        sail = RyaSailFactory.getInstance(conf);
        repo = new SailRepository(sail);
        conn = repo.getConnection();
        final ValueFactory vf = conn.getValueFactory();
        final Statement s = vf.createStatement(vf.createURI("u:a"), vf.createURI("u:b"), vf.createURI("u:c"));
        assertFalse(conn.hasStatement(s, false));
        conn.add(s);
        Assert.assertTrue(conn.hasStatement(s, false));
    } finally {
        if (conn != null) {
            conn.close();
        }
        if (repo != null) {
            repo.shutDown();
        }
        if (sail != null) {
            sail.shutDown();
        }
    }
}
Also used : SailRepository(org.openrdf.repository.sail.SailRepository) Sail(org.openrdf.sail.Sail) Statement(org.openrdf.model.Statement) ValueFactory(org.openrdf.model.ValueFactory) SailRepositoryConnection(org.openrdf.repository.sail.SailRepositoryConnection) Test(org.junit.Test)

Aggregations

SailRepositoryConnection (org.openrdf.repository.sail.SailRepositoryConnection)58 SailRepository (org.openrdf.repository.sail.SailRepository)41 Sail (org.openrdf.sail.Sail)39 Test (org.junit.Test)33 BindingSet (org.openrdf.query.BindingSet)23 HashSet (java.util.HashSet)17 MapBindingSet (org.openrdf.query.impl.MapBindingSet)15 TupleQueryResult (org.openrdf.query.TupleQueryResult)13 Statement (org.openrdf.model.Statement)11 LiteralImpl (org.openrdf.model.impl.LiteralImpl)9 RepositoryException (org.openrdf.repository.RepositoryException)9 ArrayList (java.util.ArrayList)8 Connector (org.apache.accumulo.core.client.Connector)8 Configuration (org.apache.hadoop.conf.Configuration)8 PrecomputedJoinStorage (org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage)8 URIImpl (org.openrdf.model.impl.URIImpl)8 TupleQuery (org.openrdf.query.TupleQuery)8 RyaClientException (org.apache.rya.api.client.RyaClientException)7 RyaStatement (org.apache.rya.api.domain.RyaStatement)7 AccumuloPcjStorage (org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPcjStorage)7