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;
}
}
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();
}
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;
}
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;
}
}
Aggregations