Search in sources :

Example 1 with AccumuloTemporalIndexer

use of org.apache.rya.indexing.accumulo.temporal.AccumuloTemporalIndexer in project incubator-rya by apache.

the class FilterFunctionOptimizer method init.

private synchronized void init() {
    if (!init) {
        if (ConfigUtils.getUseMongo(conf)) {
            StatefulMongoDBRdfConfiguration stateConf = (StatefulMongoDBRdfConfiguration) conf;
            for (final MongoSecondaryIndex indexer : stateConf.getAdditionalIndexers()) {
                if (indexer instanceof FreeTextIndexer) {
                    freeTextIndexer = (FreeTextIndexer) indexer;
                } else if (indexer instanceof TemporalIndexer) {
                    temporalIndexer = (TemporalIndexer) indexer;
                }
            }
        } else {
            freeTextIndexer = new AccumuloFreeTextIndexer();
            freeTextIndexer.setConf(conf);
            temporalIndexer = new AccumuloTemporalIndexer();
            temporalIndexer.setConf(conf);
        }
        init = true;
    }
}
Also used : StatefulMongoDBRdfConfiguration(org.apache.rya.mongodb.StatefulMongoDBRdfConfiguration) AccumuloFreeTextIndexer(org.apache.rya.indexing.accumulo.freetext.AccumuloFreeTextIndexer) AccumuloTemporalIndexer(org.apache.rya.indexing.accumulo.temporal.AccumuloTemporalIndexer) AccumuloTemporalIndexer(org.apache.rya.indexing.accumulo.temporal.AccumuloTemporalIndexer) MongoSecondaryIndex(org.apache.rya.mongodb.MongoSecondaryIndex) AccumuloFreeTextIndexer(org.apache.rya.indexing.accumulo.freetext.AccumuloFreeTextIndexer)

Example 2 with AccumuloTemporalIndexer

use of org.apache.rya.indexing.accumulo.temporal.AccumuloTemporalIndexer in project incubator-rya by apache.

the class RyaOutputFormatTest method testTemporalIndexing.

@Test
public void testTemporalIndexing() throws Exception {
    final TemporalInstant[] instants = { new TemporalInstantRfc3339(2015, 12, 30, 12, 00, 01), new TemporalInstantRfc3339(2015, 12, 30, 12, 00, 02), new TemporalInstantRfc3339(2015, 12, 30, 12, 00, 03), new TemporalInstantRfc3339(2015, 12, 30, 12, 00, 03) };
    final Statement[] statements = new Statement[instants.length];
    RyaOutputFormat.setCoreTablesEnabled(job, false);
    RyaOutputFormat.setFreeTextEnabled(job, false);
    RyaOutputFormat.setTemporalEnabled(job, true);
    RyaOutputFormat.setEntityEnabled(job, false);
    final ValueFactory vf = new ValueFactoryImpl();
    for (int i = 0; i < instants.length; i++) {
        final RyaType time = RdfToRyaConversions.convertLiteral(vf.createLiteral(instants[i].toString()));
        final RyaStatement input = RyaStatement.builder().setSubject(new RyaURI(GRAPH + ":s")).setPredicate(new RyaURI(GRAPH + ":p")).setObject(time).build();
        write(input);
        statements[i] = RyaToRdfConversions.convertStatement(input);
    }
    final AccumuloTemporalIndexer temporal = new AccumuloTemporalIndexer();
    temporal.setConf(conf);
    Connector connector = ConfigUtils.getConnector(conf);
    MultiTableBatchWriter mtbw = connector.createMultiTableBatchWriter(new BatchWriterConfig());
    temporal.setConnector(connector);
    temporal.setMultiTableBatchWriter(mtbw);
    temporal.init();
    final Set<Statement> empty = new HashSet<>();
    final Set<Statement> head = new HashSet<>();
    final Set<Statement> tail = new HashSet<>();
    head.add(statements[0]);
    tail.add(statements[2]);
    tail.add(statements[3]);
    Assert.assertEquals(empty, getSet(temporal.queryInstantBeforeInstant(instants[0], new StatementConstraints())));
    Assert.assertEquals(empty, getSet(temporal.queryInstantAfterInstant(instants[3], new StatementConstraints())));
    Assert.assertEquals(head, getSet(temporal.queryInstantBeforeInstant(instants[1], new StatementConstraints())));
    Assert.assertEquals(tail, getSet(temporal.queryInstantAfterInstant(instants[1], new StatementConstraints())));
    temporal.close();
}
Also used : Connector(org.apache.accumulo.core.client.Connector) MultiTableBatchWriter(org.apache.accumulo.core.client.MultiTableBatchWriter) Statement(org.openrdf.model.Statement) RyaStatement(org.apache.rya.api.domain.RyaStatement) TemporalInstantRfc3339(org.apache.rya.indexing.TemporalInstantRfc3339) ValueFactoryImpl(org.openrdf.model.impl.ValueFactoryImpl) RyaStatement(org.apache.rya.api.domain.RyaStatement) ValueFactory(org.openrdf.model.ValueFactory) TemporalInstant(org.apache.rya.indexing.TemporalInstant) RyaType(org.apache.rya.api.domain.RyaType) RyaURI(org.apache.rya.api.domain.RyaURI) StatementConstraints(org.apache.rya.indexing.StatementConstraints) AccumuloTemporalIndexer(org.apache.rya.indexing.accumulo.temporal.AccumuloTemporalIndexer) BatchWriterConfig(org.apache.accumulo.core.client.BatchWriterConfig) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 3 with AccumuloTemporalIndexer

use of org.apache.rya.indexing.accumulo.temporal.AccumuloTemporalIndexer in project incubator-rya by apache.

the class RyaOutputFormat method getTemporalIndexer.

private static TemporalIndexer getTemporalIndexer(final Configuration conf) throws IOException {
    if (!conf.getBoolean(ENABLE_TEMPORAL, true)) {
        return null;
    }
    final AccumuloTemporalIndexer temporal = new AccumuloTemporalIndexer();
    temporal.setConf(conf);
    Connector connector;
    try {
        connector = ConfigUtils.getConnector(conf);
    } catch (AccumuloException | AccumuloSecurityException e) {
        throw new IOException("Error when attempting to create a connection for writing the temporal index.", e);
    }
    final MultiTableBatchWriter mtbw = connector.createMultiTableBatchWriter(new BatchWriterConfig());
    temporal.setConnector(connector);
    temporal.setMultiTableBatchWriter(mtbw);
    temporal.init();
    return temporal;
}
Also used : Connector(org.apache.accumulo.core.client.Connector) AccumuloException(org.apache.accumulo.core.client.AccumuloException) MultiTableBatchWriter(org.apache.accumulo.core.client.MultiTableBatchWriter) AccumuloTemporalIndexer(org.apache.rya.indexing.accumulo.temporal.AccumuloTemporalIndexer) BatchWriterConfig(org.apache.accumulo.core.client.BatchWriterConfig) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) IOException(java.io.IOException)

Example 4 with AccumuloTemporalIndexer

use of org.apache.rya.indexing.accumulo.temporal.AccumuloTemporalIndexer in project incubator-rya by apache.

the class GeoEnabledFilterFunctionOptimizer method init.

/**
 * Load instances of the selected indexers.  This is tricky because some (geomesa vs geowave) have incompatible dependencies (geotools versions).
 */
private synchronized void init() {
    if (!init) {
        if (ConfigUtils.getUseMongo(conf)) {
            // create a new MongoGeoIndexer() without having it at compile time.
            StatefulMongoDBRdfConfiguration stateConf = (StatefulMongoDBRdfConfiguration) conf;
            for (final MongoSecondaryIndex indexer : stateConf.getAdditionalIndexers()) {
                if (indexer instanceof FreeTextIndexer) {
                    freeTextIndexer = (FreeTextIndexer) indexer;
                } else if (indexer instanceof TemporalIndexer) {
                    temporalIndexer = (TemporalIndexer) indexer;
                } else if (indexer instanceof GeoIndexer) {
                    geoIndexer = (GeoIndexer) indexer;
                }
            }
        } else {
            GeoIndexerType geoIndexerType = OptionalConfigUtils.getGeoIndexerType(conf);
            if (geoIndexerType == GeoIndexerType.UNSPECIFIED) {
                geoIndexer = instantiate(GeoIndexerType.GEO_MESA.getGeoIndexerClassString(), GeoIndexer.class);
            } else {
                geoIndexer = instantiate(geoIndexerType.getGeoIndexerClassString(), GeoIndexer.class);
            }
            geoIndexer.setConf(conf);
            freeTextIndexer = new AccumuloFreeTextIndexer();
            freeTextIndexer.setConf(conf);
            temporalIndexer = new AccumuloTemporalIndexer();
            temporalIndexer.setConf(conf);
        }
        init = true;
    }
}
Also used : StatefulMongoDBRdfConfiguration(org.apache.rya.mongodb.StatefulMongoDBRdfConfiguration) AccumuloFreeTextIndexer(org.apache.rya.indexing.accumulo.freetext.AccumuloFreeTextIndexer) AccumuloTemporalIndexer(org.apache.rya.indexing.accumulo.temporal.AccumuloTemporalIndexer) AccumuloTemporalIndexer(org.apache.rya.indexing.accumulo.temporal.AccumuloTemporalIndexer) MongoSecondaryIndex(org.apache.rya.mongodb.MongoSecondaryIndex) AccumuloFreeTextIndexer(org.apache.rya.indexing.accumulo.freetext.AccumuloFreeTextIndexer)

Aggregations

AccumuloTemporalIndexer (org.apache.rya.indexing.accumulo.temporal.AccumuloTemporalIndexer)4 BatchWriterConfig (org.apache.accumulo.core.client.BatchWriterConfig)2 Connector (org.apache.accumulo.core.client.Connector)2 MultiTableBatchWriter (org.apache.accumulo.core.client.MultiTableBatchWriter)2 AccumuloFreeTextIndexer (org.apache.rya.indexing.accumulo.freetext.AccumuloFreeTextIndexer)2 MongoSecondaryIndex (org.apache.rya.mongodb.MongoSecondaryIndex)2 StatefulMongoDBRdfConfiguration (org.apache.rya.mongodb.StatefulMongoDBRdfConfiguration)2 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 AccumuloException (org.apache.accumulo.core.client.AccumuloException)1 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)1 RyaStatement (org.apache.rya.api.domain.RyaStatement)1 RyaType (org.apache.rya.api.domain.RyaType)1 RyaURI (org.apache.rya.api.domain.RyaURI)1 StatementConstraints (org.apache.rya.indexing.StatementConstraints)1 TemporalInstant (org.apache.rya.indexing.TemporalInstant)1 TemporalInstantRfc3339 (org.apache.rya.indexing.TemporalInstantRfc3339)1 Test (org.junit.Test)1 Statement (org.openrdf.model.Statement)1 ValueFactory (org.openrdf.model.ValueFactory)1