Search in sources :

Example 1 with IndexQueryStrategySPI

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;
}
Also used : IndexQueryStrategySPI(org.locationtech.geowave.adapter.vector.index.IndexQueryStrategySPI)

Example 2 with IndexQueryStrategySPI

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());
                }
            };
        }
    });
}
Also used : GeoWavePluginConfig(org.locationtech.geowave.adapter.vector.plugin.GeoWavePluginConfig) SimpleFeatureTypeBuilder(org.geotools.feature.simple.SimpleFeatureTypeBuilder) GeometryFactory(org.locationtech.jts.geom.GeometryFactory) Calendar(java.util.Calendar) Closeable(java.io.Closeable) QueryConstraints(org.locationtech.geowave.core.store.query.constraints.QueryConstraints) Index(org.locationtech.geowave.core.store.api.Index) Point(org.locationtech.jts.geom.Point) IOException(java.io.IOException) AdapterIndexMappingStore(org.locationtech.geowave.core.store.adapter.AdapterIndexMappingStore) Point(org.locationtech.jts.geom.Point) SimpleFeature(org.opengis.feature.simple.SimpleFeature) IndexQueryStrategySPI(org.locationtech.geowave.adapter.vector.index.IndexQueryStrategySPI) DataStatisticsStore(org.locationtech.geowave.core.store.statistics.DataStatisticsStore) Coordinate(org.locationtech.jts.geom.Coordinate) GeoWaveGTDataStore(org.locationtech.geowave.adapter.vector.plugin.GeoWaveGTDataStore) InternalDataAdapter(org.locationtech.geowave.core.store.adapter.InternalDataAdapter) CloseableIteratorWrapper(org.locationtech.geowave.core.store.CloseableIteratorWrapper) FeatureDataAdapter(org.locationtech.geowave.adapter.vector.FeatureDataAdapter) Map(java.util.Map) Writer(org.locationtech.geowave.core.store.api.Writer) SimpleFeatureBuilder(org.geotools.feature.simple.SimpleFeatureBuilder) Before(org.junit.Before)

Aggregations

IndexQueryStrategySPI (org.locationtech.geowave.adapter.vector.index.IndexQueryStrategySPI)2 Closeable (java.io.Closeable)1 IOException (java.io.IOException)1 Calendar (java.util.Calendar)1 Map (java.util.Map)1 SimpleFeatureBuilder (org.geotools.feature.simple.SimpleFeatureBuilder)1 SimpleFeatureTypeBuilder (org.geotools.feature.simple.SimpleFeatureTypeBuilder)1 Before (org.junit.Before)1 FeatureDataAdapter (org.locationtech.geowave.adapter.vector.FeatureDataAdapter)1 GeoWaveGTDataStore (org.locationtech.geowave.adapter.vector.plugin.GeoWaveGTDataStore)1 GeoWavePluginConfig (org.locationtech.geowave.adapter.vector.plugin.GeoWavePluginConfig)1 CloseableIteratorWrapper (org.locationtech.geowave.core.store.CloseableIteratorWrapper)1 AdapterIndexMappingStore (org.locationtech.geowave.core.store.adapter.AdapterIndexMappingStore)1 InternalDataAdapter (org.locationtech.geowave.core.store.adapter.InternalDataAdapter)1 Index (org.locationtech.geowave.core.store.api.Index)1 Writer (org.locationtech.geowave.core.store.api.Writer)1 QueryConstraints (org.locationtech.geowave.core.store.query.constraints.QueryConstraints)1 DataStatisticsStore (org.locationtech.geowave.core.store.statistics.DataStatisticsStore)1 Coordinate (org.locationtech.jts.geom.Coordinate)1 GeometryFactory (org.locationtech.jts.geom.GeometryFactory)1