Search in sources :

Example 16 with AccumuloRyaDAO

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

the class SparqlQueryPigEngine method init.

public void init() throws Exception {
    Preconditions.checkNotNull(sparqlToPigTransformVisitor, "Sparql To Pig Transform Visitor must not be null");
    logger.info("Initializing Sparql Query Pig Engine");
    if (hadoopDir != null) {
        // set hadoop dir property
        System.setProperty("HADOOPDIR", hadoopDir);
    }
    if (pigServer == null) {
        pigServer = new PigServer(execType);
    }
    if (inference || stats) {
        final String instance = sparqlToPigTransformVisitor.getInstance();
        final String zoo = sparqlToPigTransformVisitor.getZk();
        final String user = sparqlToPigTransformVisitor.getUser();
        final String pass = sparqlToPigTransformVisitor.getPassword();
        final Connector connector = new ZooKeeperInstance(instance, zoo).getConnector(user, new PasswordToken(pass.getBytes(StandardCharsets.UTF_8)));
        final String tablePrefix = sparqlToPigTransformVisitor.getTablePrefix();
        conf.setTablePrefix(tablePrefix);
        if (inference) {
            logger.info("Using inference");
            inferenceEngine = new InferenceEngine();
            ryaDAO = new AccumuloRyaDAO();
            ryaDAO.setConf(conf);
            ryaDAO.setConnector(connector);
            ryaDAO.init();
            inferenceEngine.setRyaDAO(ryaDAO);
            inferenceEngine.setConf(conf);
            inferenceEngine.setSchedule(false);
            inferenceEngine.init();
        }
        if (stats) {
            logger.info("Using stats");
            rdfEvalStatsDAO = new AccumuloRdfEvalStatsDAO();
            rdfEvalStatsDAO.setConf(conf);
            rdfEvalStatsDAO.setConnector(connector);
            // rdfEvalStatsDAO.setEvalTable(tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX);
            rdfEvalStatsDAO.init();
            rdfCloudTripleStoreEvaluationStatistics = new RdfCloudTripleStoreEvaluationStatistics<AccumuloRdfConfiguration>(conf, rdfEvalStatsDAO);
        }
    }
}
Also used : Connector(org.apache.accumulo.core.client.Connector) AccumuloRyaDAO(org.apache.rya.accumulo.AccumuloRyaDAO) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) InferenceEngine(org.apache.rya.rdftriplestore.inference.InferenceEngine) PigServer(org.apache.pig.PigServer) AccumuloRdfEvalStatsDAO(org.apache.rya.accumulo.AccumuloRdfEvalStatsDAO) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance)

Example 17 with AccumuloRyaDAO

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

the class InferenceIT method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    dao = new AccumuloRyaDAO();
    connector = new MockInstance().getConnector("", new PasswordToken(""));
    dao.setConnector(connector);
    conf = new AccumuloRdfConfiguration();
    conf.setInfer(true);
    dao.setConf(conf);
    dao.init();
    store = new RdfCloudTripleStore();
    store.setConf(conf);
    store.setRyaDAO(dao);
    inferenceEngine = new InferenceEngine();
    inferenceEngine.setRyaDAO(dao);
    store.setInferenceEngine(inferenceEngine);
    inferenceEngine.refreshGraph();
    store.initialize();
    repository = new SailRepository(store);
    conn = repository.getConnection();
    solutions = new LinkedList<>();
    resultHandler = new TupleQueryResultHandler() {

        @Override
        public void endQueryResult() throws TupleQueryResultHandlerException {
        }

        @Override
        public void handleBoolean(final boolean value) throws QueryResultHandlerException {
        }

        @Override
        public void handleLinks(final List<String> linkUrls) throws QueryResultHandlerException {
        }

        @Override
        public void handleSolution(final BindingSet bindingSet) throws TupleQueryResultHandlerException {
            if (bindingSet != null && bindingSet.iterator().hasNext()) {
                solutions.add(bindingSet);
            }
        }

        @Override
        public void startQueryResult(final List<String> bindingNames) throws TupleQueryResultHandlerException {
            solutions.clear();
        }
    };
}
Also used : AccumuloRyaDAO(org.apache.rya.accumulo.AccumuloRyaDAO) RdfCloudTripleStore(org.apache.rya.rdftriplestore.RdfCloudTripleStore) BindingSet(org.openrdf.query.BindingSet) ListBindingSet(org.openrdf.query.impl.ListBindingSet) TupleQueryResultHandlerException(org.openrdf.query.TupleQueryResultHandlerException) SailRepository(org.openrdf.repository.sail.SailRepository) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) MockInstance(org.apache.accumulo.core.client.mock.MockInstance) TupleQueryResultHandler(org.openrdf.query.TupleQueryResultHandler) QueryResultHandlerException(org.openrdf.query.QueryResultHandlerException) TupleQueryResultHandlerException(org.openrdf.query.TupleQueryResultHandlerException)

Example 18 with AccumuloRyaDAO

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

the class HashJoinTest method init.

@Before
public void init() throws Exception {
    dao = new AccumuloRyaDAO();
    connector = new MockInstance().getConnector("", "");
    dao.setConnector(connector);
    dao.setConf(conf);
    dao.init();
}
Also used : AccumuloRyaDAO(org.apache.rya.accumulo.AccumuloRyaDAO) MockInstance(org.apache.accumulo.core.client.mock.MockInstance) Before(org.junit.Before)

Example 19 with AccumuloRyaDAO

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

the class TestUtils method verify.

public static void verify(Connector connector, AccumuloRdfConfiguration conf, RyaStatement... ryaStatements) throws RyaDAOException, IOException {
    AccumuloRyaDAO dao = new AccumuloRyaDAO();
    dao.setConnector(connector);
    dao.setConf(conf);
    dao.init();
    AccumuloRyaQueryEngine engine = dao.getQueryEngine();
    for (RyaStatement ryaStatement : ryaStatements) {
        verify(ryaStatement, engine);
    }
    dao.destroy();
}
Also used : AccumuloRyaDAO(org.apache.rya.accumulo.AccumuloRyaDAO) AccumuloRyaQueryEngine(org.apache.rya.accumulo.query.AccumuloRyaQueryEngine) RyaStatement(org.apache.rya.api.domain.RyaStatement)

Example 20 with AccumuloRyaDAO

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

the class GeoRyaSailFactory method getAccumuloDAO.

private static AccumuloRyaDAO getAccumuloDAO(final AccumuloRdfConfiguration config) throws AccumuloException, AccumuloSecurityException, RyaDAOException {
    final Connector connector = ConfigUtils.getConnector(config);
    final AccumuloRyaDAO dao = new AccumuloRyaDAO();
    dao.setConnector(connector);
    OptionalConfigUtils.setIndexers(config);
    config.setDisplayQueryPlan(true);
    dao.setConf(config);
    dao.init();
    return dao;
}
Also used : Connector(org.apache.accumulo.core.client.Connector) AccumuloRyaDAO(org.apache.rya.accumulo.AccumuloRyaDAO)

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