Search in sources :

Example 11 with AccumuloRyaDAO

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

the class KafkaRyaSubGraphExportIT method loadRyaStatements.

protected String loadRyaStatements(final String sparql, final Collection<RyaStatement> statements) throws Exception {
    requireNonNull(sparql);
    requireNonNull(statements);
    FluoClient client = null;
    try {
        CreateFluoPcj createPcj = new CreateFluoPcj();
        client = new FluoClientImpl(super.getFluoConfiguration());
        String id = createPcj.createPcj(sparql, client).getQueryId();
        AccumuloRyaDAO dao = getRyaDAO();
        dao.add(statements.iterator());
        // Wait for the Fluo application to finish computing the end result.
        super.getMiniFluo().waitForObservers();
        // FluoITHelper.printFluoTable(client);
        return id;
    } finally {
        if (client != null) {
            client.close();
        }
    }
}
Also used : AccumuloRyaDAO(org.apache.rya.accumulo.AccumuloRyaDAO) FluoClient(org.apache.fluo.api.client.FluoClient) FluoClientImpl(org.apache.fluo.core.client.FluoClientImpl) CreateFluoPcj(org.apache.rya.indexing.pcj.fluo.api.CreateFluoPcj)

Example 12 with AccumuloRyaDAO

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

the class AccumuloInstanceDriver method setUpDao.

/**
 * Sets up the {@link AccumuloRyaDAO}.
 * @throws Exception
 */
public void setUpDao() throws Exception {
    // Setup dao
    log.info("Creating " + driverName + " DAO");
    dao = new AccumuloRyaDAO();
    dao.setConnector(connector);
    dao.setConf(config);
    // Flush the tables before initializing the DAO
    for (final String tableName : tableList) {
        connector.tableOperations().flush(tableName, null, null, false);
    }
    dao.init();
}
Also used : AccumuloRyaDAO(org.apache.rya.accumulo.AccumuloRyaDAO)

Example 13 with AccumuloRyaDAO

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

the class AccumuloRyaUtils method setupDao.

/**
 * Sets up a {@link AccumuloRyaDAO} with the specified connector and config.
 * @param connector the {@link Connector}.
 * @param accumuloRdfConfiguration the {@link AccumuloRdfConfiguration}.
 * @return the {@link AccumuloRyaDAO}.
 */
public static AccumuloRyaDAO setupDao(final Connector connector, final AccumuloRdfConfiguration accumuloRdfConfiguration) {
    final AccumuloRyaDAO accumuloRyaDao = new AccumuloRyaDAO();
    accumuloRyaDao.setConnector(connector);
    accumuloRyaDao.setConf(accumuloRdfConfiguration);
    try {
        accumuloRyaDao.init();
    } catch (final RyaDAOException e) {
        log.error("Error initializing DAO", e);
    }
    return accumuloRyaDao;
}
Also used : AccumuloRyaDAO(org.apache.rya.accumulo.AccumuloRyaDAO) RyaDAOException(org.apache.rya.api.persist.RyaDAOException)

Example 14 with AccumuloRyaDAO

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

the class HistoricStreamingVisibilityIT method historicResults.

/**
 * Ensure historic matches are included in the result.
 */
@Test
public void historicResults() throws Exception {
    // A query that finds people who talk to Eve and work at Chipotle.
    final String sparql = "SELECT ?x " + "WHERE { " + "?x <http://talksTo> <http://Eve>. " + "?x <http://worksAt> <http://Chipotle>." + "}";
    final Connector accumuloConn = super.getAccumuloConnector();
    accumuloConn.securityOperations().changeUserAuthorizations(getUsername(), new Authorizations("U", "V", "W"));
    final AccumuloRyaDAO dao = new AccumuloRyaDAO();
    dao.setConnector(accumuloConn);
    dao.setConf(makeConfig());
    dao.init();
    // Triples that are loaded into Rya before the PCJ is created.
    final ValueFactory vf = new ValueFactoryImpl();
    final Set<RyaStatement> historicTriples = Sets.newHashSet(makeRyaStatement(vf.createStatement(vf.createURI("http://Alice"), vf.createURI("http://talksTo"), vf.createURI("http://Eve")), "U"), makeRyaStatement(vf.createStatement(vf.createURI("http://Bob"), vf.createURI("http://talksTo"), vf.createURI("http://Eve")), "V"), makeRyaStatement(vf.createStatement(vf.createURI("http://Charlie"), vf.createURI("http://talksTo"), vf.createURI("http://Eve")), "W"), makeRyaStatement(vf.createStatement(vf.createURI("http://Eve"), vf.createURI("http://helps"), vf.createURI("http://Kevin")), "U"), makeRyaStatement(vf.createStatement(vf.createURI("http://Bob"), vf.createURI("http://worksAt"), vf.createURI("http://Chipotle")), "W"), makeRyaStatement(vf.createStatement(vf.createURI("http://Charlie"), vf.createURI("http://worksAt"), vf.createURI("http://Chipotle")), "V"), makeRyaStatement(vf.createStatement(vf.createURI("http://Eve"), vf.createURI("http://worksAt"), vf.createURI("http://Chipotle")), "U"), makeRyaStatement(vf.createStatement(vf.createURI("http://David"), vf.createURI("http://worksAt"), vf.createURI("http://Chipotle")), "V"));
    dao.add(historicTriples.iterator());
    dao.flush();
    // The expected results of the SPARQL query once the PCJ has been computed.
    final Set<BindingSet> expected = new HashSet<>();
    MapBindingSet bs = new MapBindingSet();
    bs.addBinding("x", vf.createURI("http://Bob"));
    expected.add(bs);
    bs = new MapBindingSet();
    bs.addBinding("x", vf.createURI("http://Charlie"));
    expected.add(bs);
    // Create the PCJ table.
    final PrecomputedJoinStorage pcjStorage = new AccumuloPcjStorage(accumuloConn, getRyaInstanceName());
    final String pcjId = pcjStorage.createPcj(sparql);
    try (FluoClient fluoClient = FluoFactory.newClient(super.getFluoConfiguration())) {
        new CreateFluoPcj().withRyaIntegration(pcjId, pcjStorage, fluoClient, accumuloConn, getRyaInstanceName());
    }
    // Verify the end results of the query match the expected results.
    super.getMiniFluo().waitForObservers();
    final Set<BindingSet> results = Sets.newHashSet(pcjStorage.listResults(pcjId));
    Assert.assertEquals(expected, results);
}
Also used : Connector(org.apache.accumulo.core.client.Connector) AccumuloRyaDAO(org.apache.rya.accumulo.AccumuloRyaDAO) MapBindingSet(org.openrdf.query.impl.MapBindingSet) BindingSet(org.openrdf.query.BindingSet) Authorizations(org.apache.accumulo.core.security.Authorizations) FluoClient(org.apache.fluo.api.client.FluoClient) AccumuloPcjStorage(org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPcjStorage) ValueFactoryImpl(org.openrdf.model.impl.ValueFactoryImpl) RyaStatement(org.apache.rya.api.domain.RyaStatement) CreateFluoPcj(org.apache.rya.indexing.pcj.fluo.api.CreateFluoPcj) ValueFactory(org.openrdf.model.ValueFactory) PrecomputedJoinStorage(org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage) MapBindingSet(org.openrdf.query.impl.MapBindingSet) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 15 with AccumuloRyaDAO

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

the class StatementPatternStorageTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    connector = new MockInstance(instance).getConnector(user, pwd.getBytes());
    connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX);
    connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX);
    connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX);
    connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX);
    SecurityOperations secOps = connector.securityOperations();
    secOps.createUser(user, pwd.getBytes(), auths);
    secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX, TablePermission.READ);
    secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX, TablePermission.READ);
    secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX, TablePermission.READ);
    secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX, TablePermission.READ);
    conf = new AccumuloRdfConfiguration();
    ryaDAO = new AccumuloRyaDAO();
    ryaDAO.setConnector(connector);
    conf.setTablePrefix(tablePrefix);
    ryaDAO.setConf(conf);
    ryaDAO.init();
}
Also used : AccumuloRyaDAO(org.apache.rya.accumulo.AccumuloRyaDAO) MockInstance(org.apache.accumulo.core.client.mock.MockInstance) SecurityOperations(org.apache.accumulo.core.client.admin.SecurityOperations) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration)

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