use of org.locationtech.geowave.adapter.vector.index.IndexQueryStrategySPI in project geowave by locationtech.
the class GeoWavePluginConfig method getIndexQueryStrategy.
public static IndexQueryStrategySPI getIndexQueryStrategy(final Map<String, ?> params) throws GeoWavePluginException {
final Object param = params.get(QUERY_INDEX_STRATEGY_KEY);
final String strategy = ((param == null) || param.toString().trim().isEmpty()) ? DEFAULT_QUERY_INDEX_STRATEGY : param.toString();
final Iterator<IndexQueryStrategySPI> it = getInxexQueryStrategyList();
while (it.hasNext()) {
final IndexQueryStrategySPI spi = it.next();
if (spi.toString().equals(strategy)) {
return spi;
}
}
// This would only get hit if the default query index strategy is removed from the spi registry.
return null;
}
use of org.locationtech.geowave.adapter.vector.index.IndexQueryStrategySPI in project geowave by locationtech.
the class SpatialTemporalQueryIT method initSpatialTemporalTestData.
@Before
public void initSpatialTemporalTestData() throws IOException, GeoWavePluginException {
dataStore = dataStoreOptions.createDataStore();
SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
builder.setName("simpletimestamp");
builder.add("geo", Point.class);
builder.add("timestamp", Date.class);
timeStampAdapter = new FeatureDataAdapter(builder.buildFeatureType());
builder = new SimpleFeatureTypeBuilder();
builder.setName("simpletimerange");
builder.add("geo", Point.class);
builder.add("startTime", Date.class);
builder.add("endTime", Date.class);
timeRangeAdapter = new FeatureDataAdapter(builder.buildFeatureType());
Calendar cal = getInitialDayCalendar();
final GeometryFactory geomFactory = new GeometryFactory();
final SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(timeStampAdapter.getFeatureType());
final SimpleFeatureBuilder featureTimeRangeBuilder = new SimpleFeatureBuilder(timeRangeAdapter.getFeatureType());
dataStore.addType(timeStampAdapter, YEAR_INDEX, MONTH_INDEX, DAY_INDEX);
final Writer timeWriters = dataStore.createWriter(timeStampAdapter.getTypeName());
// time ranges for days isn't tested so we don't have to deal with
// ingesting into the day index, the multi-year test case (requiring
// 1000+ partitions)
dataStore.addType(timeRangeAdapter, YEAR_INDEX, MONTH_INDEX);
final Writer rangeWriters = dataStore.createWriter(timeRangeAdapter.getTypeName());
try {
for (int day = cal.getActualMinimum(Calendar.DAY_OF_MONTH); day <= cal.getActualMaximum(Calendar.DAY_OF_MONTH); day++) {
final double ptVal = ((((day + 1.0) - cal.getActualMinimum(Calendar.DAY_OF_MONTH)) / ((cal.getActualMaximum(Calendar.DAY_OF_MONTH) - cal.getActualMinimum(Calendar.DAY_OF_MONTH)) + 2.0)) * 2) - 1;
cal.set(Calendar.DAY_OF_MONTH, day);
final Point pt = geomFactory.createPoint(new Coordinate(ptVal, ptVal));
featureBuilder.add(pt);
featureBuilder.add(cal.getTime());
final SimpleFeature feature = featureBuilder.buildFeature("day:" + day);
timeWriters.write(feature);
}
cal = getInitialMonthCalendar();
for (int month = cal.getActualMinimum(Calendar.MONTH); month <= cal.getActualMaximum(Calendar.MONTH); month++) {
cal.set(Calendar.MONTH, month);
final double ptVal = ((((month + 1.0) - cal.getActualMinimum(Calendar.MONTH)) / ((cal.getActualMaximum(Calendar.MONTH) - cal.getActualMinimum(Calendar.MONTH)) + 2.0)) * 2) - 1;
final Point pt = geomFactory.createPoint(new Coordinate(ptVal, ptVal));
featureBuilder.add(pt);
featureBuilder.add(cal.getTime());
final SimpleFeature feature = featureBuilder.buildFeature("month:" + month);
timeWriters.write(feature);
}
ingestTimeRangeData(cal, rangeWriters, featureTimeRangeBuilder, cal.getActualMinimum(Calendar.MONTH), cal.getActualMaximum(Calendar.MONTH), Calendar.MONTH, "month");
cal = getInitialYearCalendar();
for (int year = MULTI_YEAR_MIN; year <= MULTI_YEAR_MAX; year++) {
final double ptVal = ((((year + 1.0) - MULTI_YEAR_MIN) / ((MULTI_YEAR_MAX - MULTI_YEAR_MIN) + 2.0)) * 2) - 1;
cal.set(Calendar.YEAR, year);
final Point pt = geomFactory.createPoint(new Coordinate(ptVal, ptVal));
featureBuilder.add(pt);
featureBuilder.add(cal.getTime());
final SimpleFeature feature = featureBuilder.buildFeature("year:" + year);
timeWriters.write(feature);
}
ingestTimeRangeData(cal, rangeWriters, featureTimeRangeBuilder, MULTI_YEAR_MIN, MULTI_YEAR_MAX, Calendar.YEAR, "year");
Point pt = geomFactory.createPoint(new Coordinate(-50, -50));
featureBuilder.add(pt);
featureBuilder.add(cal.getTime());
SimpleFeature feature = featureBuilder.buildFeature("outlier1timestamp");
timeWriters.write(feature);
pt = geomFactory.createPoint(new Coordinate(50, 50));
featureBuilder.add(pt);
featureBuilder.add(cal.getTime());
feature = featureBuilder.buildFeature("outlier2timestamp");
timeWriters.write(feature);
pt = geomFactory.createPoint(new Coordinate(-50, -50));
featureTimeRangeBuilder.add(pt);
featureTimeRangeBuilder.add(cal.getTime());
cal.roll(Calendar.MINUTE, 5);
featureTimeRangeBuilder.add(cal.getTime());
feature = featureTimeRangeBuilder.buildFeature("outlier1timerange");
rangeWriters.write(feature);
pt = geomFactory.createPoint(new Coordinate(50, 50));
featureTimeRangeBuilder.add(pt);
featureTimeRangeBuilder.add(cal.getTime());
cal.roll(Calendar.MINUTE, 5);
featureTimeRangeBuilder.add(cal.getTime());
feature = featureTimeRangeBuilder.buildFeature("outlier2timerange");
rangeWriters.write(feature);
// Ingest data for duplicate deletion, should not overlap time
// ranges from other tests
ingestTimeRangeDataForDuplicateDeletion(cal, rangeWriters, featureTimeRangeBuilder, DUPLICATE_DELETION_YEAR_MIN, DUPLICATE_DELETION_YEAR_MAX, Calendar.YEAR, "ranged_year");
} finally {
timeWriters.close();
rangeWriters.close();
}
geowaveGtDataStore = new GeoWaveGTDataStore(new GeoWavePluginConfig(dataStoreOptions) {
@Override
public IndexQueryStrategySPI getIndexQueryStrategy() {
return new IndexQueryStrategySPI() {
@Override
public boolean requiresStats() {
return false;
}
@Override
public CloseableIterator<Index> getIndices(final DataStatisticsStore statisticsStore, final AdapterIndexMappingStore mappingStore, final QueryConstraints query, final Index[] indices, final InternalDataAdapter<?> adapter, final Map<QueryHint, Object> hints) {
return new CloseableIteratorWrapper<>(new Closeable() {
@Override
public void close() throws IOException {
}
}, Collections.singleton(currentGeotoolsIndex).iterator());
}
};
}
});
}
Aggregations