Search in sources :

Example 61 with Sail

use of org.eclipse.rdf4j.sail.Sail in project incubator-rya by apache.

the class MongoIndexerDeleteIT method deleteTest.

@Test
public void deleteTest() throws Exception {
    final Sail sail = GeoRyaSailFactory.getInstance(conf);
    final SailRepositoryConnection conn = new SailRepository(sail).getConnection();
    try {
        populateRya(conn);
        final MongoClient client = conf.getMongoClient();
        // The extra 1 is from the person type defined in freetext
        assertEquals(8, client.getDatabase(conf.getMongoDBName()).getCollection(conf.getTriplesCollectionName()).count());
        assertEquals(4, client.getDatabase(conf.getMongoDBName()).getCollection("ryatest_geo").count());
        assertEquals(1, client.getDatabase(conf.getMongoDBName()).getCollection("ryatest_temporal").count());
        assertEquals(2, client.getDatabase(conf.getMongoDBName()).getCollection("ryatest_freetext").count());
        // free text -- remove one from many
        String delete = // 
        "DELETE DATA \n" + "{\n" + "  <urn:people> <http://www.w3.org/2000/01/rdf-schema#label> \"Alice Palace Hose\" " + "}";
        Update update = conn.prepareUpdate(QueryLanguage.SPARQL, delete);
        update.execute();
        // temporal -- remove one from one
        delete = // 
        "DELETE DATA \n" + "{\n" + "  <foo:time> <Property:atTime> \"0001-02-03T04:05:06Z\" " + "}";
        update = conn.prepareUpdate(QueryLanguage.SPARQL, delete);
        update.execute();
        // geo -- remove many from many
        delete = "PREFIX geo: <http://www.opengis.net/ont/geosparql#>\n" + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/>\n" + // 
        "DELETE \n" + "{\n" + "  <urn:geo> geo:asWKT ?point \n" + "}" + "WHERE { \n" + "  <urn:geo> geo:asWKT ?point .\n" + "  FILTER(geof:sfWithin(?point, \"POLYGON((0 0, 2 0, 2 1, 0 1, 0 0))\"^^geo:wktLiteral))" + "}";
        update = conn.prepareUpdate(QueryLanguage.SPARQL, delete);
        update.execute();
        assertEquals(2, client.getDatabase(conf.getMongoDBName()).getCollection("ryatest_geo").count());
        assertEquals(0, client.getDatabase(conf.getMongoDBName()).getCollection("ryatest_temporal").count());
        assertEquals(1, client.getDatabase(conf.getMongoDBName()).getCollection("ryatest_freetext").count());
        assertEquals(4, client.getDatabase(conf.getMongoDBName()).getCollection(conf.getTriplesCollectionName()).count());
    } finally {
        conn.close();
        sail.shutDown();
    }
}
Also used : MongoClient(com.mongodb.MongoClient) SailRepository(org.eclipse.rdf4j.repository.sail.SailRepository) Sail(org.eclipse.rdf4j.sail.Sail) SailRepositoryConnection(org.eclipse.rdf4j.repository.sail.SailRepositoryConnection) Update(org.eclipse.rdf4j.query.Update) Test(org.junit.Test)

Example 62 with Sail

use of org.eclipse.rdf4j.sail.Sail in project incubator-rya by apache.

the class TriplestoreProvenanceCollectorTest method testCollect.

@Test
public void testCollect() throws ProvenanceCollectionException, RepositoryException, MalformedQueryException, QueryEvaluationException {
    Sail ms = new MemoryStore();
    SailRepository repo = new SailRepository(ms);
    repo.initialize();
    TriplestoreProvenanceCollector coll = new TriplestoreProvenanceCollector(repo, "fakeUser", "SPARQL");
    coll.recordQuery("fakeQuery");
    String queryString = "SELECT ?x ?y WHERE { ?x ?p ?y } ";
    TupleQuery tupleQuery = repo.getConnection().prepareTupleQuery(QueryLanguage.SPARQL, queryString);
    TupleQueryResult result = tupleQuery.evaluate();
    // TODO not asserting on the results.
    assertTrue(result.hasNext());
}
Also used : MemoryStore(org.eclipse.rdf4j.sail.memory.MemoryStore) SailRepository(org.eclipse.rdf4j.repository.sail.SailRepository) Sail(org.eclipse.rdf4j.sail.Sail) TupleQuery(org.eclipse.rdf4j.query.TupleQuery) TupleQueryResult(org.eclipse.rdf4j.query.TupleQueryResult) Test(org.junit.Test)

Example 63 with Sail

use of org.eclipse.rdf4j.sail.Sail in project incubator-rya by apache.

the class PcjIntegrationTestingUtil method getAccumuloNonPcjRepo.

public static SailRepository getAccumuloNonPcjRepo(final String tablePrefix, final String instance) throws AccumuloException, AccumuloSecurityException, RyaDAOException, RepositoryException, InferenceEngineException, NumberFormatException, UnknownHostException, SailException {
    final AccumuloRdfConfiguration nonPcjConf = new AccumuloRdfConfiguration();
    populateAccumuloConfig(instance, tablePrefix, nonPcjConf);
    final Sail nonPcjSail = RyaSailFactory.getInstance(nonPcjConf);
    final SailRepository nonPcjRepo = new SailRepository(nonPcjSail);
    return nonPcjRepo;
}
Also used : SailRepository(org.eclipse.rdf4j.repository.sail.SailRepository) Sail(org.eclipse.rdf4j.sail.Sail) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration)

Example 64 with Sail

use of org.eclipse.rdf4j.sail.Sail in project incubator-rya by apache.

the class FluoITBase method setupRya.

/**
 * Sets up a Rya instance.
 */
protected RyaSailRepository setupRya() throws AccumuloException, AccumuloSecurityException, RepositoryException, RyaDAOException, NumberFormatException, UnknownHostException, InferenceEngineException, AlreadyInitializedException, RyaDetailsRepositoryException, DuplicateInstanceNameException, RyaClientException, SailException {
    checkNotNull(instanceName);
    checkNotNull(zookeepers);
    // Setup Rya configuration values.
    final AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration();
    conf.setTablePrefix(getRyaInstanceName());
    conf.setDisplayQueryPlan(true);
    conf.setBoolean(ConfigUtils.USE_MOCK_INSTANCE, false);
    conf.set(ConfigUtils.CLOUDBASE_USER, clusterInstance.getUsername());
    conf.set(ConfigUtils.CLOUDBASE_PASSWORD, clusterInstance.getPassword());
    conf.set(ConfigUtils.CLOUDBASE_INSTANCE, clusterInstance.getInstanceName());
    conf.set(ConfigUtils.CLOUDBASE_ZOOKEEPERS, clusterInstance.getZookeepers());
    conf.set(ConfigUtils.USE_PCJ, "true");
    conf.set(ConfigUtils.FLUO_APP_NAME, getRyaInstanceName());
    conf.set(ConfigUtils.PCJ_STORAGE_TYPE, PrecomputedJoinIndexerConfig.PrecomputedJoinStorageType.ACCUMULO.toString());
    conf.set(ConfigUtils.PCJ_UPDATER_TYPE, PrecomputedJoinIndexerConfig.PrecomputedJoinUpdaterType.FLUO.toString());
    conf.set(ConfigUtils.CLOUDBASE_AUTHS, "");
    // Install the test instance of Rya.
    final Install install = new AccumuloInstall(createConnectionDetails(), accumuloConn);
    final InstallConfiguration installConfig = InstallConfiguration.builder().setEnableTableHashPrefix(true).setEnableEntityCentricIndex(true).setEnableFreeTextIndex(true).setEnableTemporalIndex(true).setEnablePcjIndex(true).setEnableGeoIndex(true).setFluoPcjAppName(getRyaInstanceName()).build();
    install.install(getRyaInstanceName(), installConfig);
    // Connect to the instance of Rya that was just installed.
    final Sail sail = RyaSailFactory.getInstance(conf);
    final RyaSailRepository ryaRepo = new RyaSailRepository(sail);
    return ryaRepo;
}
Also used : AccumuloInstall(org.apache.rya.api.client.accumulo.AccumuloInstall) Sail(org.eclipse.rdf4j.sail.Sail) RyaSailRepository(org.apache.rya.rdftriplestore.RyaSailRepository) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration) AccumuloInstall(org.apache.rya.api.client.accumulo.AccumuloInstall) Install(org.apache.rya.api.client.Install) InstallConfiguration(org.apache.rya.api.client.Install.InstallConfiguration)

Example 65 with Sail

use of org.eclipse.rdf4j.sail.Sail in project Commons by denkbares.

the class ConfigurableFreeSailRepositoryFactory method getRepository.

@Override
public Repository getRepository(RepositoryImplConfig config) throws RepositoryConfigException {
    MonitorRepositoryConfig monitorConfig = (MonitorRepositoryConfig) config;
    overridePlugins(monitorConfig);
    try {
        Sail sail = createSail(monitorConfig.getSailImplConfig());
        return new SailRepository(sail);
    } catch (SailConfigException e) {
        throw new RepositoryConfigException(e.getMessage(), e);
    }
}
Also used : SailRepository(org.eclipse.rdf4j.repository.sail.SailRepository) Sail(org.eclipse.rdf4j.sail.Sail) RepositoryConfigException(org.eclipse.rdf4j.repository.config.RepositoryConfigException) SailConfigException(org.eclipse.rdf4j.sail.config.SailConfigException) MonitorRepositoryConfig(com.ontotext.trree.monitorRepository.MonitorRepositoryConfig)

Aggregations

Sail (org.eclipse.rdf4j.sail.Sail)68 SailRepository (org.eclipse.rdf4j.repository.sail.SailRepository)49 SailRepositoryConnection (org.eclipse.rdf4j.repository.sail.SailRepositoryConnection)37 Test (org.junit.Test)33 AccumuloRdfConfiguration (org.apache.rya.accumulo.AccumuloRdfConfiguration)15 BindingSet (org.eclipse.rdf4j.query.BindingSet)13 TupleQueryResult (org.eclipse.rdf4j.query.TupleQueryResult)13 SailException (org.eclipse.rdf4j.sail.SailException)13 HashSet (java.util.HashSet)11 ValueFactory (org.eclipse.rdf4j.model.ValueFactory)11 SailConnection (org.eclipse.rdf4j.sail.SailConnection)11 RyaClient (org.apache.rya.api.client.RyaClient)9 ArrayList (java.util.ArrayList)8 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)8 Configuration (org.apache.hadoop.conf.Configuration)8 RyaClientException (org.apache.rya.api.client.RyaClientException)8 MongoDBRdfConfiguration (org.apache.rya.mongodb.MongoDBRdfConfiguration)7 RyaSailRepository (org.apache.rya.rdftriplestore.RyaSailRepository)7 MapBindingSet (org.eclipse.rdf4j.query.impl.MapBindingSet)7 RepositoryException (org.eclipse.rdf4j.repository.RepositoryException)7