Search in sources :

Example 1 with RdfCloudTripleStoreConfiguration

use of org.apache.rya.api.RdfCloudTripleStoreConfiguration in project incubator-rya by apache.

the class AccumuloStatementMetadataOptimizerIT method getConf.

private static RdfCloudTripleStoreConfiguration getConf() {
    RdfCloudTripleStoreConfiguration conf;
    Set<RyaURI> propertySet = new HashSet<RyaURI>(Arrays.asList(new RyaURI("http://createdBy"), new RyaURI("http://createdOn")));
    conf = new AccumuloRdfConfiguration();
    conf.setBoolean(ConfigUtils.USE_MOCK_INSTANCE, true);
    conf.set(RdfCloudTripleStoreConfiguration.CONF_TBL_PREFIX, "rya_");
    conf.set(ConfigUtils.CLOUDBASE_USER, "root");
    conf.set(ConfigUtils.CLOUDBASE_PASSWORD, "");
    conf.set(ConfigUtils.CLOUDBASE_INSTANCE, "instance");
    conf.set(ConfigUtils.CLOUDBASE_AUTHS, "");
    conf.setUseStatementMetadata(true);
    conf.setStatementMetadataProperties(propertySet);
    return conf;
}
Also used : RyaURI(org.apache.rya.api.domain.RyaURI) RdfCloudTripleStoreConfiguration(org.apache.rya.api.RdfCloudTripleStoreConfiguration) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration) HashSet(java.util.HashSet)

Example 2 with RdfCloudTripleStoreConfiguration

use of org.apache.rya.api.RdfCloudTripleStoreConfiguration in project incubator-rya by apache.

the class InfoRyaCommand method doRyaExecute.

@Override
protected Object doRyaExecute() throws Exception {
    System.out.println("******************RYA Configuration******************");
    RdfCloudTripleStoreConfiguration conf = rdfDAO.getConf();
    for (Map.Entry<String, String> next : conf) {
        System.out.println(next.getKey() + ":\t\t" + next.getValue());
    }
    System.out.println("*****************************************************");
    return null;
}
Also used : RdfCloudTripleStoreConfiguration(org.apache.rya.api.RdfCloudTripleStoreConfiguration) Map(java.util.Map)

Example 3 with RdfCloudTripleStoreConfiguration

use of org.apache.rya.api.RdfCloudTripleStoreConfiguration in project incubator-rya by apache.

the class EntityOptimizer method setConf.

@Override
public void setConf(Configuration conf) {
    if (conf instanceof RdfCloudTripleStoreConfiguration) {
        this.conf = (RdfCloudTripleStoreConfiguration) conf;
    } else {
        this.conf = new AccumuloRdfConfiguration(conf);
    }
    if (!isEvalDaoSet) {
        if (this.conf.isUseStats() && this.conf.isUseSelectivity()) {
            try {
                eval = new AccumuloSelectivityEvalDAO(this.conf, ConfigUtils.getConnector(this.conf));
                ((AccumuloSelectivityEvalDAO) eval).setRdfEvalDAO(new ProspectorServiceEvalStatsDAO(ConfigUtils.getConnector(this.conf), this.conf));
                eval.init();
            } catch (final AccumuloException | AccumuloSecurityException e) {
                LOG.warn("A problem was encountered while setting the Configuration for the EntityOptimizer.", e);
            }
            isEvalDaoSet = true;
        } else {
            eval = null;
            isEvalDaoSet = true;
        }
    }
}
Also used : AccumuloException(org.apache.accumulo.core.client.AccumuloException) ProspectorServiceEvalStatsDAO(org.apache.rya.prospector.service.ProspectorServiceEvalStatsDAO) AccumuloSelectivityEvalDAO(org.apache.rya.joinselect.AccumuloSelectivityEvalDAO) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) RdfCloudTripleStoreConfiguration(org.apache.rya.api.RdfCloudTripleStoreConfiguration) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration)

Example 4 with RdfCloudTripleStoreConfiguration

use of org.apache.rya.api.RdfCloudTripleStoreConfiguration in project incubator-rya by apache.

the class AccumuloIndexSetProvider method getIndices.

@Override
protected List<ExternalTupleSet> getIndices() throws PcjIndexSetException {
    requireNonNull(conf);
    try {
        final String tablePrefix = requireNonNull(conf.get(RdfCloudTripleStoreConfiguration.CONF_TBL_PREFIX));
        final Connector conn = requireNonNull(ConfigUtils.getConnector(conf));
        List<String> tables = null;
        if (conf instanceof RdfCloudTripleStoreConfiguration) {
            tables = ((RdfCloudTripleStoreConfiguration) conf).getPcjTables();
        }
        // this maps associates pcj table name with pcj sparql query
        final Map<String, String> indexTables = Maps.newLinkedHashMap();
        try (final PrecomputedJoinStorage storage = new AccumuloPcjStorage(conn, tablePrefix)) {
            final PcjTableNameFactory pcjFactory = new PcjTableNameFactory();
            final boolean tablesProvided = tables != null && !tables.isEmpty();
            if (tablesProvided) {
                // if tables provided, associate table name with sparql
                for (final String table : tables) {
                    indexTables.put(table, storage.getPcjMetadata(pcjFactory.getPcjId(table)).getSparql());
                }
            } else if (hasRyaDetails(tablePrefix, conn)) {
                // If this is a newer install of Rya, and it has PCJ Details, then
                // use those.
                final List<String> ids = storage.listPcjs();
                for (final String id : ids) {
                    indexTables.put(pcjFactory.makeTableName(tablePrefix, id), storage.getPcjMetadata(id).getSparql());
                }
            } else {
                // Otherwise figure it out by scanning tables.
                final PcjTables pcjTables = new PcjTables();
                for (final String table : conn.tableOperations().list()) {
                    if (table.startsWith(tablePrefix + "INDEX")) {
                        indexTables.put(table, pcjTables.getPcjMetadata(conn, table).getSparql());
                    }
                }
            }
        }
        // use table name sparql map (indexTables) to create {@link
        // AccumuloIndexSet}
        final List<ExternalTupleSet> index = Lists.newArrayList();
        if (indexTables.isEmpty()) {
            log.info("No Index found");
        } else {
            for (final String table : indexTables.keySet()) {
                final String indexSparqlString = indexTables.get(table);
                index.add(new AccumuloIndexSet(indexSparqlString, conf, table));
            }
        }
        return index;
    } catch (final PCJStorageException | AccumuloException | AccumuloSecurityException | MalformedQueryException | SailException | QueryEvaluationException | TableNotFoundException e) {
        throw new PcjIndexSetException("Failed to retrieve the indicies.", e);
    }
}
Also used : Connector(org.apache.accumulo.core.client.Connector) AccumuloException(org.apache.accumulo.core.client.AccumuloException) AccumuloPcjStorage(org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPcjStorage) AccumuloIndexSet(org.apache.rya.indexing.external.tupleSet.AccumuloIndexSet) PcjTableNameFactory(org.apache.rya.indexing.pcj.storage.accumulo.PcjTableNameFactory) SailException(org.openrdf.sail.SailException) ExternalTupleSet(org.apache.rya.indexing.external.tupleSet.ExternalTupleSet) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) QueryEvaluationException(org.openrdf.query.QueryEvaluationException) PrecomputedJoinStorage(org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage) MalformedQueryException(org.openrdf.query.MalformedQueryException) List(java.util.List) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) PcjTables(org.apache.rya.indexing.pcj.storage.accumulo.PcjTables) PCJStorageException(org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage.PCJStorageException) RdfCloudTripleStoreConfiguration(org.apache.rya.api.RdfCloudTripleStoreConfiguration)

Example 5 with RdfCloudTripleStoreConfiguration

use of org.apache.rya.api.RdfCloudTripleStoreConfiguration in project incubator-rya by apache.

the class ConfigUtils method createBatchScanner.

public static BatchScanner createBatchScanner(final String tablename, final Configuration conf) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
    final Connector connector = ConfigUtils.getConnector(conf);
    final Authorizations auths = ConfigUtils.getAuthorizations(conf);
    Integer numThreads = null;
    if (conf instanceof RdfCloudTripleStoreConfiguration) {
        numThreads = ((RdfCloudTripleStoreConfiguration) conf).getNumThreads();
    } else {
        numThreads = conf.getInt(RdfCloudTripleStoreConfiguration.CONF_NUM_THREADS, 2);
    }
    return connector.createBatchScanner(tablename, auths, numThreads);
}
Also used : Connector(org.apache.accumulo.core.client.Connector) Authorizations(org.apache.accumulo.core.security.Authorizations) RdfCloudTripleStoreConfiguration(org.apache.rya.api.RdfCloudTripleStoreConfiguration)

Aggregations

RdfCloudTripleStoreConfiguration (org.apache.rya.api.RdfCloudTripleStoreConfiguration)20 Test (org.junit.Test)10 Map (java.util.Map)9 Text (org.apache.hadoop.io.Text)9 AccumuloSelectivityEvalDAO (org.apache.rya.joinselect.AccumuloSelectivityEvalDAO)9 ProspectorServiceEvalStatsDAO (org.apache.rya.prospector.service.ProspectorServiceEvalStatsDAO)9 ArrayList (java.util.ArrayList)8 BatchWriter (org.apache.accumulo.core.client.BatchWriter)8 Mutation (org.apache.accumulo.core.data.Mutation)8 Value (org.apache.accumulo.core.data.Value)8 Authorizations (org.apache.accumulo.core.security.Authorizations)8 TupleExpr (org.openrdf.query.algebra.TupleExpr)8 Scanner (org.apache.accumulo.core.client.Scanner)7 Range (org.apache.accumulo.core.data.Range)7 Key (org.apache.accumulo.core.data.Key)6 QueryJoinSelectOptimizer (org.apache.rya.rdftriplestore.evaluation.QueryJoinSelectOptimizer)6 RdfCloudTripleStoreSelectivityEvaluationStatistics (org.apache.rya.rdftriplestore.evaluation.RdfCloudTripleStoreSelectivityEvaluationStatistics)6 AccumuloRdfConfiguration (org.apache.rya.accumulo.AccumuloRdfConfiguration)5 RyaURI (org.apache.rya.api.domain.RyaURI)4 HashSet (java.util.HashSet)3