Search in sources :

Example 31 with AccumuloRyaDAO

use of org.apache.rya.accumulo.AccumuloRyaDAO in project incubator-rya by apache.

the class EntityTupleSet method getRyaSailConnection.

private RdfCloudTripleStoreConnection getRyaSailConnection() throws AccumuloException, AccumuloSecurityException, SailException {
    RdfCloudTripleStore store = new RdfCloudTripleStore();
    AccumuloRyaDAO crdfdao = new AccumuloRyaDAO();
    crdfdao.setConnector(accCon);
    AccumuloRdfConfiguration acc = new AccumuloRdfConfiguration(conf);
    crdfdao.setConf(acc);
    store.setRyaDAO(crdfdao);
    store.initialize();
    return (RdfCloudTripleStoreConnection) store.getConnection();
}
Also used : RdfCloudTripleStore(org.apache.rya.rdftriplestore.RdfCloudTripleStore) AccumuloRyaDAO(org.apache.rya.accumulo.AccumuloRyaDAO) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration) RdfCloudTripleStoreConnection(org.apache.rya.rdftriplestore.RdfCloudTripleStoreConnection)

Example 32 with AccumuloRyaDAO

use of org.apache.rya.accumulo.AccumuloRyaDAO in project incubator-rya by apache.

the class StatementStoreFactory method getBaseAccumuloStore.

private AccumuloRyaStatementStore getBaseAccumuloStore(final String ryaInstanceName, final InstanceType type, final boolean isParent, final String username, final String password, final String tablePrefix, final String auths, final String zookeepers) throws Exception {
    final AccumuloInstanceDriver aInstance = new AccumuloInstanceDriver(ryaInstanceName + "_driver", type, true, false, isParent, username, password, ryaInstanceName, tablePrefix, auths, zookeepers);
    aInstance.setUp();
    final AccumuloRyaDAO dao = aInstance.getDao();
    return new AccumuloRyaStatementStore(dao, tablePrefix, ryaInstanceName);
}
Also used : AccumuloInstanceDriver(org.apache.rya.export.accumulo.util.AccumuloInstanceDriver) AccumuloRyaDAO(org.apache.rya.accumulo.AccumuloRyaDAO) AccumuloRyaStatementStore(org.apache.rya.export.accumulo.AccumuloRyaStatementStore) TimestampPolicyAccumuloRyaStatementStore(org.apache.rya.export.accumulo.policy.TimestampPolicyAccumuloRyaStatementStore)

Example 33 with AccumuloRyaDAO

use of org.apache.rya.accumulo.AccumuloRyaDAO in project incubator-rya by apache.

the class AccumuloStatementMetadataOptimizerIT method init.

@Before
public void init() throws Exception {
    conf = getConf();
    sail = RyaSailFactory.getInstance(conf);
    repo = new SailRepository(sail);
    conn = repo.getConnection();
    Connector conn = ConfigUtils.getConnector(conf);
    dao = new AccumuloRyaDAO();
    dao.setConnector(conn);
    dao.init();
}
Also used : Connector(org.apache.accumulo.core.client.Connector) AccumuloRyaDAO(org.apache.rya.accumulo.AccumuloRyaDAO) SailRepository(org.openrdf.repository.sail.SailRepository) Before(org.junit.Before)

Example 34 with AccumuloRyaDAO

use of org.apache.rya.accumulo.AccumuloRyaDAO in project incubator-rya by apache.

the class RyaAccumuloSailFactory method getSail.

@Override
public Sail getSail(final SailImplConfig config) throws SailConfigException {
    try {
        final RdfCloudTripleStore store = new RdfCloudTripleStore();
        final RyaAccumuloSailConfig cbconfig = (RyaAccumuloSailConfig) config;
        final String instanceName = cbconfig.getInstance();
        final String zooKeepers = cbconfig.getZookeepers();
        Instance i;
        if (cbconfig.isMock()) {
            i = new MockInstance(instanceName);
        } else {
            i = new ZooKeeperInstance(instanceName, zooKeepers);
        }
        final String user = cbconfig.getUser();
        final String pass = cbconfig.getPassword();
        final Connector connector = i.getConnector(user, new PasswordToken(pass));
        final AccumuloRyaDAO crdfdao = new AccumuloRyaDAO();
        crdfdao.setConnector(connector);
        final AccumuloRdfConfiguration conf = cbconfig.toRdfConfiguation();
        ConfigUtils.setIndexers(conf);
        conf.setDisplayQueryPlan(true);
        crdfdao.setConf(conf);
        crdfdao.init();
        store.setRyaDAO(crdfdao);
        return store;
    } catch (RyaDAOException | AccumuloException | AccumuloSecurityException e) {
        throw new SailConfigException(e);
    }
}
Also used : RdfCloudTripleStore(org.apache.rya.rdftriplestore.RdfCloudTripleStore) Connector(org.apache.accumulo.core.client.Connector) AccumuloRyaDAO(org.apache.rya.accumulo.AccumuloRyaDAO) AccumuloException(org.apache.accumulo.core.client.AccumuloException) MockInstance(org.apache.accumulo.core.client.mock.MockInstance) Instance(org.apache.accumulo.core.client.Instance) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) MockInstance(org.apache.accumulo.core.client.mock.MockInstance) RyaDAOException(org.apache.rya.api.persist.RyaDAOException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) SailConfigException(org.openrdf.sail.config.SailConfigException)

Example 35 with AccumuloRyaDAO

use of org.apache.rya.accumulo.AccumuloRyaDAO in project incubator-rya by apache.

the class RulesetCopyIT method testRulesetCopyTool.

@Test
public void testRulesetCopyTool() throws Exception {
    // Should be copied and are involved in the solution:
    final RyaStatement[] solutionStatements = { statement("test:FullProfessor1", "rdf:type", "test:FullProfessor"), statement("test:GraduateStudent1", "test:advisor", "test:FullProfessor1"), statement("test:FullProfessor1", "test:telephone", literal("123-456-7890")), statement("test:University1", "test:telephone", literal("555")), statement("test:FullProfessor1", "test:worksFor", "test:University1"), statement("test:FullProfessor1", "test:hired", literal("2001-01-01T04:01:02.000Z", XMLSchema.DATETIME)), statement("test:University1", "geo:asWKT", literal("Point(-77.03524 38.889468)", new URIImpl("http://www.opengis.net/ont/geosparql#wktLiteral"))) };
    // These aren't solutions but should be copied:
    final RyaStatement[] copyStatements = { statement("test:FullProfessor2", "rdf:type", "test:FullProfessor"), statement("test:GraduateStudent1", "test:advisor", "test:AssistantProfessor1"), statement("test:GraduateStudent1", "test:telephone", literal("555-123-4567")), statement("test:FullProfessor1", "test:telephone", literal("567-8901")), statement("test:University1", "test:telephone", literal("800-123-4567")) };
    // Should not be copied:
    final RyaStatement[] irrelevantStatements = { statement("test:GraduateStudent2", "test:advisor", "test:FullProfessor1"), statement("test:UndergraduateStudent1", "rdf:type", "test:UndergraduateStudent"), statement("test:UndergraduateStudent2", "rdf:type", "test:UndergraduateStudent"), statement("test:GraduateStudent1", "rdf:type", "test:GraduateStudent"), statement("test:GraduateStudent1", "test:name", literal("GraduateStudent1")), statement("test:UndergraduateStudent2", "test:name", literal("UndergraduateStudent2")), statement("test:Course1", "test:name", literal("Course1")), statement("test:GraduateStudent1", "test:emailAddress", literal("GraduateStudent1@Department0.University0.edu")), statement("test:GraduateStudent1", "test:teachingAssistantOf", "test:Course1"), statement("test:GraduateStudent2", "test:undergraduateDegreeFrom", "test:University1"), statement("test:AssistantProfessor1", "test:teacherOf", "test:Course1"), statement("test:FullProfessor1", "test:telephone", literal("xxx-xxx-xxxx")), statement("test:University1", "test:telephone", literal("0000")), // If inferencing is disabled, these shouldn't matter:
    statement("test:employs", "owl:inverseOf", "test:worksFor"), statement("test:University1", "test:employs", "test:FullProfessor2") };
    final String query = QUERY_PREFIXES + "SELECT * {\n" + "    test:GraduateStudent1 test:advisor ?person .\n" + "    ?person rdf:type test:FullProfessor .\n" + "    ?person test:telephone ?number .\n" + "    ?person test:worksFor ?university .\n" + "    FILTER regex(?number, \"...-...-....\")\n" + "    ?university geo:asWKT ?place .\n" + "    FILTER regex(?number, \"^[0-9]\")\n" + "    ?university test:telephone ?universityNumber\n" + "    FILTER regex(?universityNumber, \"^5\")\n" + // Would be good to test index functions, but indexing is unreliable (see RYA-72):
    "    ?person test:hired ?time .\n" + // + "    FILTER(tempo:after(?time, '2000-01-01T01:01:03-08:00'))\n"
    "}";
    final int parentNamespaceCount = 2;
    int childNamespaceCount = 0;
    parentDao.addNamespace("ns1", "http://www.example.com/ns1#");
    parentDao.addNamespace("ns2", "http://www.example.com/ns2#");
    // Run the test
    final AccumuloRyaDAO childDao = runRulesetCopyTest(solutionStatements, copyStatements, irrelevantStatements, query, 1, false);
    // Verify namespaces were copied
    final CloseableIteration<Namespace, RyaDAOException> nsIter = childDao.iterateNamespace();
    while (nsIter.hasNext()) {
        childNamespaceCount++;
        nsIter.next();
    }
    Assert.assertEquals("Incorrect number of namespaces copied to child:", parentNamespaceCount, childNamespaceCount);
    log.info("DONE");
}
Also used : AccumuloRyaDAO(org.apache.rya.accumulo.AccumuloRyaDAO) RyaStatement(org.apache.rya.api.domain.RyaStatement) RyaDAOException(org.apache.rya.api.persist.RyaDAOException) URIImpl(org.openrdf.model.impl.URIImpl) Namespace(org.openrdf.model.Namespace) Test(org.junit.Test)

Aggregations

AccumuloRyaDAO (org.apache.rya.accumulo.AccumuloRyaDAO)45 AccumuloRdfConfiguration (org.apache.rya.accumulo.AccumuloRdfConfiguration)26 MockInstance (org.apache.accumulo.core.client.mock.MockInstance)21 Connector (org.apache.accumulo.core.client.Connector)18 PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)10 RyaStatement (org.apache.rya.api.domain.RyaStatement)10 RdfCloudTripleStore (org.apache.rya.rdftriplestore.RdfCloudTripleStore)10 Before (org.junit.Before)9 RyaURI (org.apache.rya.api.domain.RyaURI)7 Test (org.junit.Test)7 Instance (org.apache.accumulo.core.client.Instance)6 RyaDAOException (org.apache.rya.api.persist.RyaDAOException)6 RyaSailRepository (org.apache.rya.rdftriplestore.RyaSailRepository)5 ZooKeeperInstance (org.apache.accumulo.core.client.ZooKeeperInstance)4 SecurityOperations (org.apache.accumulo.core.client.admin.SecurityOperations)4 Configuration (org.apache.hadoop.conf.Configuration)4 RyaType (org.apache.rya.api.domain.RyaType)4 ArrayList (java.util.ArrayList)3 Path (org.apache.hadoop.fs.Path)3 SailRepository (org.openrdf.repository.sail.SailRepository)3