Search in sources :

Example 1 with CloseableIterator

use of org.locationtech.geowave.core.store.CloseableIterator in project geowave by locationtech.

the class GeoWaveVisibilityIT method testQuery.

public static void testQuery(final DataStore store, final DataStatisticsStore statsStore, final short internalAdapterId, final String[] auths, final boolean spatial, final int expectedResultCount, final int expectedNonNullFieldCount) {
    try (CloseableIterator<SimpleFeature> it = (CloseableIterator) store.query(QueryBuilder.newBuilder().setAuthorizations(auths).constraints(spatial ? new ExplicitSpatialQuery(new GeometryFactory().toGeometry(new Envelope(-1, 1, -1, 1))) : null).build())) {
        int resultCount = 0;
        int nonNullFieldsCount = 0;
        while (it.hasNext()) {
            final SimpleFeature feature = it.next();
            for (int a = 0; a < feature.getAttributeCount(); a++) {
                if (feature.getAttribute(a) != null) {
                    nonNullFieldsCount++;
                }
            }
            resultCount++;
        }
        Assert.assertEquals("Unexpected result count for " + (spatial ? "spatial query" : "full table scan") + " with auths " + Arrays.toString(auths), expectedResultCount, resultCount);
        Assert.assertEquals("Unexpected non-null field count for " + (spatial ? "spatial query" : "full table scan") + " with auths " + Arrays.toString(auths), expectedNonNullFieldCount, nonNullFieldsCount);
    }
    final Long count = (Long) store.aggregate(AggregationQueryBuilder.newBuilder().count(getType().getTypeName()).setAuthorizations(auths).constraints(spatial ? new ExplicitSpatialQuery(new GeometryFactory().toGeometry(new Envelope(-1, 1, -1, 1))) : null).build());
    Assert.assertEquals("Unexpected aggregation result count for " + (spatial ? "spatial query" : "full table scan") + " with auths " + Arrays.toString(auths), expectedResultCount, count.intValue());
    final CountValue countStat = store.aggregateStatistics(StatisticQueryBuilder.newBuilder(CountStatistic.STATS_TYPE).typeName(getType().getTypeName()).authorizations(auths).build());
    assertNotNull(countStat);
    Assert.assertEquals("Unexpected stats result count for " + (spatial ? "spatial query" : "full table scan") + " with auths " + Arrays.toString(auths), expectedResultCount, countStat.getValue().intValue());
}
Also used : CloseableIterator(org.locationtech.geowave.core.store.CloseableIterator) ExplicitSpatialQuery(org.locationtech.geowave.core.geotime.store.query.ExplicitSpatialQuery) GeometryFactory(org.locationtech.jts.geom.GeometryFactory) DifferingVisibilityCountValue(org.locationtech.geowave.core.store.statistics.index.DifferingVisibilityCountStatistic.DifferingVisibilityCountValue) CountValue(org.locationtech.geowave.core.store.statistics.adapter.CountStatistic.CountValue) Envelope(org.locationtech.jts.geom.Envelope) SimpleFeature(org.opengis.feature.simple.SimpleFeature) Point(org.locationtech.jts.geom.Point)

Example 2 with CloseableIterator

use of org.locationtech.geowave.core.store.CloseableIterator in project geowave by locationtech.

the class AttributesSubsetQueryIT method testClientSideFiltering.

@Test
public void testClientSideFiltering() throws IOException {
    final List<String> attributesSubset = Arrays.asList(CITY_ATTRIBUTE, POPULATION_ATTRIBUTE);
    final CloseableIterator<SimpleFeature> results = (CloseableIterator) dataStore.createDataStore().query(QueryBuilder.newBuilder().addTypeName(dataAdapter.getTypeName()).indexName(TestUtils.DEFAULT_SPATIAL_INDEX.getName()).constraints(spatialQuery).build());
    // query expects to match 3 cities from Texas, which should each contain
    // non-null values for a subset of attributes (city, population) and
    // nulls for the rest
    verifyResults(// performs filtering client side
    new FeatureTranslatingIterator(simpleFeatureType, attributesSubset, results), 3, attributesSubset);
}
Also used : CloseableIterator(org.locationtech.geowave.core.store.CloseableIterator) FeatureTranslatingIterator(org.locationtech.geowave.adapter.vector.util.FeatureTranslatingIterator) SimpleFeature(org.opengis.feature.simple.SimpleFeature) Test(org.junit.Test)

Example 3 with CloseableIterator

use of org.locationtech.geowave.core.store.CloseableIterator in project geowave by locationtech.

the class AbstractGeoWaveBasicVectorIT method testStats.

@SuppressWarnings("unchecked")
protected void testStats(final URL[] inputFiles, final boolean multithreaded, final CoordinateReferenceSystem crs, final Index... indices) {
    // In the multithreaded case, only test min/max and count. Stats will be
    // ingested/ in a different order and will not match.
    final LocalFileIngestPlugin<SimpleFeature> localFileIngest = new GeoToolsVectorDataStoreIngestPlugin(Filter.INCLUDE);
    final Map<String, StatisticsCache> statsCache = new HashMap<>();
    final String[] indexNames = Arrays.stream(indices).map(i -> i.getName()).toArray(i -> new String[i]);
    for (final URL inputFile : inputFiles) {
        LOGGER.warn("Calculating stats from file '" + inputFile.getPath() + "' - this may take several minutes...");
        try (final CloseableIterator<GeoWaveData<SimpleFeature>> dataIterator = localFileIngest.toGeoWaveData(inputFile, indexNames)) {
            final TransientAdapterStore adapterCache = new MemoryAdapterStore(localFileIngest.getDataAdapters());
            while (dataIterator.hasNext()) {
                final GeoWaveData<SimpleFeature> data = dataIterator.next();
                final DataTypeAdapter<SimpleFeature> adapter = data.getAdapter(adapterCache);
                // it should be a statistical data adapter
                if (adapter instanceof DefaultStatisticsProvider) {
                    StatisticsCache cachedValues = statsCache.get(adapter.getTypeName());
                    if (cachedValues == null) {
                        cachedValues = new StatisticsCache(adapter, crs);
                        statsCache.put(adapter.getTypeName(), cachedValues);
                    }
                    cachedValues.entryIngested(data.getValue());
                }
            }
        }
    }
    final DataStatisticsStore statsStore = getDataStorePluginOptions().createDataStatisticsStore();
    final PersistentAdapterStore adapterStore = getDataStorePluginOptions().createAdapterStore();
    final InternalDataAdapter<?>[] adapters = adapterStore.getAdapters();
    for (final InternalDataAdapter<?> internalDataAdapter : adapters) {
        final FeatureDataAdapter adapter = (FeatureDataAdapter) internalDataAdapter.getAdapter();
        final StatisticsCache cachedValue = statsCache.get(adapter.getTypeName());
        Assert.assertNotNull(cachedValue);
        final Set<Entry<Statistic<?>, Map<ByteArray, StatisticValue<?>>>> expectedStats = cachedValue.statsCache.entrySet();
        int statsCount = 0;
        try (CloseableIterator<? extends Statistic<? extends StatisticValue<?>>> statsIterator = statsStore.getDataTypeStatistics(adapter, null, null)) {
            while (statsIterator.hasNext()) {
                statsIterator.next();
                statsCount++;
            }
        }
        try (CloseableIterator<? extends Statistic<? extends StatisticValue<?>>> statsIterator = statsStore.getFieldStatistics(adapter, null, null, null)) {
            while (statsIterator.hasNext()) {
                statsIterator.next();
                statsCount++;
            }
        }
        Assert.assertEquals("The number of stats for data adapter '" + adapter.getTypeName() + "' do not match count expected", expectedStats.size(), statsCount);
        for (final Entry<Statistic<?>, Map<ByteArray, StatisticValue<?>>> expectedStat : expectedStats) {
            for (final Entry<ByteArray, StatisticValue<?>> expectedValues : expectedStat.getValue().entrySet()) {
                StatisticValue<Object> actual;
                if (expectedValues.getKey().equals(StatisticValue.NO_BIN)) {
                    actual = statsStore.getStatisticValue((Statistic<StatisticValue<Object>>) expectedStat.getKey());
                } else {
                    actual = statsStore.getStatisticValue((Statistic<StatisticValue<Object>>) expectedStat.getKey(), expectedValues.getKey());
                }
                assertEquals(expectedValues.getValue().getValue(), actual.getValue());
            }
        }
        // finally check the one stat that is more manually calculated -
        // the bounding box
        StatisticQuery<BoundingBoxValue, Envelope> query = StatisticQueryBuilder.newBuilder(BoundingBoxStatistic.STATS_TYPE).fieldName(adapter.getFeatureType().getGeometryDescriptor().getLocalName()).typeName(adapter.getTypeName()).build();
        BoundingBoxValue bboxStat = getDataStorePluginOptions().createDataStore().aggregateStatistics(query);
        validateBBox(bboxStat.getValue(), cachedValue);
        // now make sure it works without giving field name because there is only one geometry field
        // anyways
        query = StatisticQueryBuilder.newBuilder(BoundingBoxStatistic.STATS_TYPE).typeName(adapter.getTypeName()).build();
        bboxStat = getDataStorePluginOptions().createDataStore().aggregateStatistics(query);
        validateBBox(bboxStat.getValue(), cachedValue);
        final StatisticId<BoundingBoxValue> bboxStatId = FieldStatistic.generateStatisticId(adapter.getTypeName(), BoundingBoxStatistic.STATS_TYPE, adapter.getFeatureType().getGeometryDescriptor().getLocalName(), Statistic.INTERNAL_TAG);
        Assert.assertTrue("Unable to remove individual stat", statsStore.removeStatistic(statsStore.getStatisticById(bboxStatId)));
        Assert.assertNull("Individual stat was not successfully removed", statsStore.getStatisticById(bboxStatId));
    }
}
Also used : FeatureDataAdapter(org.locationtech.geowave.adapter.vector.FeatureDataAdapter) Arrays(java.util.Arrays) GeoWaveData(org.locationtech.geowave.core.store.ingest.GeoWaveData) URL(java.net.URL) Date(java.util.Date) URISyntaxException(java.net.URISyntaxException) CommonIndexAggregation(org.locationtech.geowave.core.store.query.aggregate.CommonIndexAggregation) LoggerFactory(org.slf4j.LoggerFactory) Aggregation(org.locationtech.geowave.core.store.api.Aggregation) MathUtils(org.apache.commons.math.util.MathUtils) TestUtils(org.locationtech.geowave.test.TestUtils) StatisticId(org.locationtech.geowave.core.store.statistics.StatisticId) ByteBuffer(java.nio.ByteBuffer) TimeDescriptors(org.locationtech.geowave.core.geotime.util.TimeDescriptors) TransientAdapterStore(org.locationtech.geowave.core.store.adapter.TransientAdapterStore) StatisticValue(org.locationtech.geowave.core.store.api.StatisticValue) Pair(org.apache.commons.lang3.tuple.Pair) SimpleFeature(org.opengis.feature.simple.SimpleFeature) Map(java.util.Map) Statistic(org.locationtech.geowave.core.store.api.Statistic) Maps(jersey.repackaged.com.google.common.collect.Maps) Persistable(org.locationtech.geowave.core.index.persist.Persistable) InternalDataAdapter(org.locationtech.geowave.core.store.adapter.InternalDataAdapter) FieldStatistic(org.locationtech.geowave.core.store.api.FieldStatistic) StatisticQuery(org.locationtech.geowave.core.store.api.StatisticQuery) Set(java.util.Set) ManualOperationParams(org.locationtech.geowave.core.cli.parser.ManualOperationParams) DimensionalityType(org.locationtech.geowave.test.TestUtils.DimensionalityType) ExpectedResults(org.locationtech.geowave.test.TestUtils.ExpectedResults) ConfigOptions(org.locationtech.geowave.core.cli.operations.config.options.ConfigOptions) List(java.util.List) VectorLocalExportOptions(org.locationtech.geowave.adapter.vector.export.VectorLocalExportOptions) Entry(java.util.Map.Entry) DataIdQuery(org.locationtech.geowave.core.store.query.constraints.DataIdQuery) Geometry(org.locationtech.jts.geom.Geometry) BoundingBoxValue(org.locationtech.geowave.core.geotime.store.statistics.BoundingBoxStatistic.BoundingBoxValue) DefaultStatisticsProvider(org.locationtech.geowave.core.store.statistics.DefaultStatisticsProvider) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) ByteArray(org.locationtech.geowave.core.index.ByteArray) AggregationQuery(org.locationtech.geowave.core.store.api.AggregationQuery) BeforeClass(org.junit.BeforeClass) AddStoreCommand(org.locationtech.geowave.core.store.cli.store.AddStoreCommand) AggregationQueryBuilder(org.locationtech.geowave.core.store.api.AggregationQueryBuilder) SimpleDateFormat(java.text.SimpleDateFormat) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CommonIndexedPersistenceEncoding(org.locationtech.geowave.core.store.data.CommonIndexedPersistenceEncoding) HashSet(java.util.HashSet) DataStatisticsStore(org.locationtech.geowave.core.store.statistics.DataStatisticsStore) LocalFileIngestPlugin(org.locationtech.geowave.core.store.ingest.LocalFileIngestPlugin) Calendar(java.util.Calendar) Lists(com.google.common.collect.Lists) DataTypeAdapter(org.locationtech.geowave.core.store.api.DataTypeAdapter) StatisticQueryBuilder(org.locationtech.geowave.core.store.api.StatisticQueryBuilder) QueryBuilder(org.locationtech.geowave.core.store.api.QueryBuilder) Index(org.locationtech.geowave.core.store.api.Index) StatisticsIngestCallback(org.locationtech.geowave.core.store.statistics.StatisticsIngestCallback) BoundingBoxStatistic(org.locationtech.geowave.core.geotime.store.statistics.BoundingBoxStatistic) GeoWaveRow(org.locationtech.geowave.core.store.entities.GeoWaveRow) GeotoolsFeatureDataAdapter(org.locationtech.geowave.core.geotime.store.GeotoolsFeatureDataAdapter) Logger(org.slf4j.Logger) DataStore(org.locationtech.geowave.core.store.api.DataStore) OptimalCQLQuery(org.locationtech.geowave.core.geotime.store.query.OptimalCQLQuery) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) IngestCallback(org.locationtech.geowave.core.store.callback.IngestCallback) QueryConstraints(org.locationtech.geowave.core.store.query.constraints.QueryConstraints) VectorLocalExportCommand(org.locationtech.geowave.adapter.vector.export.VectorLocalExportCommand) File(java.io.File) PersistentAdapterStore(org.locationtech.geowave.core.store.adapter.PersistentAdapterStore) DataStorePluginOptions(org.locationtech.geowave.core.store.cli.store.DataStorePluginOptions) CloseableIterator(org.locationtech.geowave.core.store.CloseableIterator) InternalGeotoolsFeatureDataAdapter(org.locationtech.geowave.core.geotime.store.InternalGeotoolsFeatureDataAdapter) MemoryAdapterStore(org.locationtech.geowave.core.store.memory.MemoryAdapterStore) Filter(org.opengis.filter.Filter) ZipUtils(org.locationtech.geowave.adapter.raster.util.ZipUtils) Assert(org.junit.Assert) GeoToolsVectorDataStoreIngestPlugin(org.locationtech.geowave.format.geotools.vector.GeoToolsVectorDataStoreIngestPlugin) Envelope(org.locationtech.jts.geom.Envelope) Assert.assertEquals(org.junit.Assert.assertEquals) StatisticValue(org.locationtech.geowave.core.store.api.StatisticValue) HashMap(java.util.HashMap) GeoToolsVectorDataStoreIngestPlugin(org.locationtech.geowave.format.geotools.vector.GeoToolsVectorDataStoreIngestPlugin) DefaultStatisticsProvider(org.locationtech.geowave.core.store.statistics.DefaultStatisticsProvider) BoundingBoxValue(org.locationtech.geowave.core.geotime.store.statistics.BoundingBoxStatistic.BoundingBoxValue) Envelope(org.locationtech.jts.geom.Envelope) URL(java.net.URL) DataStatisticsStore(org.locationtech.geowave.core.store.statistics.DataStatisticsStore) Entry(java.util.Map.Entry) Statistic(org.locationtech.geowave.core.store.api.Statistic) FieldStatistic(org.locationtech.geowave.core.store.api.FieldStatistic) BoundingBoxStatistic(org.locationtech.geowave.core.geotime.store.statistics.BoundingBoxStatistic) InternalDataAdapter(org.locationtech.geowave.core.store.adapter.InternalDataAdapter) ByteArray(org.locationtech.geowave.core.index.ByteArray) TransientAdapterStore(org.locationtech.geowave.core.store.adapter.TransientAdapterStore) MemoryAdapterStore(org.locationtech.geowave.core.store.memory.MemoryAdapterStore) SimpleFeature(org.opengis.feature.simple.SimpleFeature) PersistentAdapterStore(org.locationtech.geowave.core.store.adapter.PersistentAdapterStore) GeoWaveData(org.locationtech.geowave.core.store.ingest.GeoWaveData) FeatureDataAdapter(org.locationtech.geowave.adapter.vector.FeatureDataAdapter) GeotoolsFeatureDataAdapter(org.locationtech.geowave.core.geotime.store.GeotoolsFeatureDataAdapter) InternalGeotoolsFeatureDataAdapter(org.locationtech.geowave.core.geotime.store.InternalGeotoolsFeatureDataAdapter) Map(java.util.Map) HashMap(java.util.HashMap)

Example 4 with CloseableIterator

use of org.locationtech.geowave.core.store.CloseableIterator in project geowave by locationtech.

the class GeoWaveMultiProcessIngestIT method testMultiProcessIngest.

@Test
public void testMultiProcessIngest() throws Exception {
    for (int j = 0; j < 10; j++) {
        final Class<?> clazz = GeoWaveMultiProcessIngestIT.class;
        final String javaHome = System.getProperty("java.home");
        final String javaBin = javaHome + File.separator + "bin" + File.separator + "java";
        final String className = clazz.getName();
        final String jarFile = ClasspathUtils.setupPathingJarClassPath(TEMP_DIR, clazz);
        final Index idx1 = SimpleIngest.createSpatialIndex();
        final Index idx2 = SimpleIngest.createSpatialTemporalIndex();
        final DataStore store = dataStorePluginOptions.createDataStore();
        store.addIndex(idx1);
        store.addIndex(idx2);
        final StringBuilder indexNames = new StringBuilder();
        indexNames.append(idx1.getName()).append(",").append(idx2.getName());
        final Configuration conf = new Configuration();
        conf.set(AbstractMapReduceIngest.INDEX_NAMES_KEY, indexNames.toString());
        for (final MetadataType type : MetadataType.values()) {
            // stats and index metadata writers are created elsewhere
            if (!MetadataType.INDEX.equals(type) && !MetadataType.STATISTIC_VALUES.equals(type)) {
                dataStorePluginOptions.createDataStoreOperations().createMetadataWriter(type).close();
            }
        }
        GeoWaveOutputFormat.addIndex(conf, idx1);
        GeoWaveOutputFormat.addIndex(conf, idx2);
        GeoWaveOutputFormat.setStoreOptions(conf, dataStorePluginOptions);
        Assert.assertTrue(TEMP_DIR.exists() || TEMP_DIR.mkdirs());
        final File configFile = new File(TEMP_DIR, "hadoop-job.conf");
        Assert.assertTrue(!configFile.exists() || configFile.delete());
        Assert.assertTrue(configFile.createNewFile());
        try (DataOutputStream dataOut = new DataOutputStream(new FileOutputStream(configFile))) {
            conf.write(dataOut);
        }
        final List<ProcessBuilder> bldrs = new ArrayList<>();
        for (int i = 0; i < NUM_PROCESSES; i++) {
            final ArrayList<String> argList = new ArrayList<>();
            argList.addAll(Arrays.asList(javaBin, "-cp", jarFile, className, new Integer(i * 10000).toString()));
            final ProcessBuilder builder = new ProcessBuilder(argList);
            builder.directory(TEMP_DIR);
            builder.inheritIO();
            bldrs.add(builder);
        }
        final List<Process> processes = bldrs.stream().map(b -> {
            try {
                return b.start();
            } catch (final IOException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
            return null;
        }).collect(Collectors.toList());
        Assert.assertFalse(processes.stream().anyMatch(Objects::isNull));
        processes.forEach(p -> {
            try {
                p.waitFor();
            } catch (final InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        });
        try (CloseableIterator<Object> it = store.query(QueryBuilder.newBuilder().build())) {
            Assert.assertEquals(2701 * NUM_PROCESSES, Iterators.size(it));
        }
        try (CloseableIterator<SimpleFeature> it = store.query(VectorQueryBuilder.newBuilder().indexName(idx1.getName()).build())) {
            Assert.assertEquals(2701 * NUM_PROCESSES, Iterators.size(it));
        }
        try (CloseableIterator<SimpleFeature> it = store.query(VectorQueryBuilder.newBuilder().indexName(idx2.getName()).build())) {
            Assert.assertEquals(2701 * NUM_PROCESSES, Iterators.size(it));
        }
        try (CloseableIterator<SimpleFeature> it = store.query(VectorQueryBuilder.newBuilder().constraints(VectorQueryBuilder.newBuilder().constraintsFactory().spatialTemporalConstraints().spatialConstraints(GeometryUtils.GEOMETRY_FACTORY.toGeometry(new Envelope(-172, 172, -82, 82))).build()).build())) {
            Assert.assertEquals(2277 * NUM_PROCESSES, Iterators.size(it));
        }
        final long epochTime = 1609459200000L;
        final long startTime = epochTime + TimeUnit.DAYS.toMillis(15);
        final long endTime = epochTime + TimeUnit.DAYS.toMillis(345);
        try (CloseableIterator<SimpleFeature> it = store.query(VectorQueryBuilder.newBuilder().constraints(VectorQueryBuilder.newBuilder().constraintsFactory().spatialTemporalConstraints().spatialConstraints(GeometryUtils.GEOMETRY_FACTORY.toGeometry(new Envelope(-172, 172, -82, 82))).addTimeRange(new Date(startTime), new Date(endTime)).build()).build())) {
            Assert.assertEquals(2178 * NUM_PROCESSES, Iterators.size(it));
        }
        TestUtils.deleteAll(getDataStorePluginOptions());
    }
}
Also used : DataInputStream(java.io.DataInputStream) SimpleFeatureBuilder(org.geotools.feature.simple.SimpleFeatureBuilder) Arrays(java.util.Arrays) GeoWaveStoreType(org.locationtech.geowave.test.annotation.GeoWaveTestStore.GeoWaveStoreType) VectorQueryBuilder(org.locationtech.geowave.core.geotime.store.query.api.VectorQueryBuilder) GeoWaveTestStore(org.locationtech.geowave.test.annotation.GeoWaveTestStore) Date(java.util.Date) ClasspathUtils(org.locationtech.geowave.core.store.util.ClasspathUtils) RunWith(org.junit.runner.RunWith) TestUtils(org.locationtech.geowave.test.TestUtils) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) Iterators(com.google.common.collect.Iterators) ArrayList(java.util.ArrayList) JobContextImpl(org.apache.hadoop.mapreduce.task.JobContextImpl) TransientAdapterStore(org.locationtech.geowave.core.store.adapter.TransientAdapterStore) MetadataType(org.locationtech.geowave.core.store.operations.MetadataType) DataOutputStream(java.io.DataOutputStream) SimpleFeature(org.opengis.feature.simple.SimpleFeature) Configuration(org.apache.hadoop.conf.Configuration) QueryBuilder(org.locationtech.geowave.core.store.api.QueryBuilder) Index(org.locationtech.geowave.core.store.api.Index) GeotoolsFeatureDataAdapter(org.locationtech.geowave.core.geotime.store.GeotoolsFeatureDataAdapter) GeoWaveOutputKey(org.locationtech.geowave.mapreduce.output.GeoWaveOutputKey) DataStore(org.locationtech.geowave.core.store.api.DataStore) AbstractMapReduceIngest(org.locationtech.geowave.core.ingest.hdfs.mapreduce.AbstractMapReduceIngest) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) Test(org.junit.Test) FileInputStream(java.io.FileInputStream) GeometryUtils(org.locationtech.geowave.core.geotime.util.GeometryUtils) Collectors(java.util.stream.Collectors) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException) Objects(java.util.Objects) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) DataStorePluginOptions(org.locationtech.geowave.core.store.cli.store.DataStorePluginOptions) CloseableIterator(org.locationtech.geowave.core.store.CloseableIterator) SimpleIngest(org.locationtech.geowave.examples.ingest.SimpleIngest) GeoWaveITRunner(org.locationtech.geowave.test.GeoWaveITRunner) Assert(org.junit.Assert) GeoWaveOutputFormat(org.locationtech.geowave.mapreduce.output.GeoWaveOutputFormat) Envelope(org.locationtech.jts.geom.Envelope) Configuration(org.apache.hadoop.conf.Configuration) DataOutputStream(java.io.DataOutputStream) ArrayList(java.util.ArrayList) Index(org.locationtech.geowave.core.store.api.Index) Envelope(org.locationtech.jts.geom.Envelope) DataStore(org.locationtech.geowave.core.store.api.DataStore) MetadataType(org.locationtech.geowave.core.store.operations.MetadataType) IOException(java.io.IOException) SimpleFeature(org.opengis.feature.simple.SimpleFeature) Date(java.util.Date) FileOutputStream(java.io.FileOutputStream) File(java.io.File) Test(org.junit.Test)

Example 5 with CloseableIterator

use of org.locationtech.geowave.core.store.CloseableIterator in project geowave by locationtech.

the class CentroidManagerGeoWave method getRawCentroids.

@SuppressWarnings("unchecked")
protected CloseableIterator<T> getRawCentroids(final String batchId, final String groupID) throws IOException {
    final FilterFactoryImpl factory = new FilterFactoryImpl();
    final Expression expB1 = factory.property(ClusterFeatureAttribute.BATCH_ID.attrName());
    final Expression expB2 = factory.literal(batchId);
    final Filter batchIdFilter = factory.equal(expB1, expB2, false);
    Filter finalFilter = batchIdFilter;
    if (groupID != null) {
        final Expression exp1 = factory.property(ClusterFeatureAttribute.GROUP_ID.attrName());
        final Expression exp2 = factory.literal(groupID);
        // ignore levels for group IDS
        finalFilter = factory.and(factory.equal(exp1, exp2, false), batchIdFilter);
    } else if (level > 0) {
        final Expression exp1 = factory.property(ClusterFeatureAttribute.ZOOM_LEVEL.attrName());
        final Expression exp2 = factory.literal(level);
        finalFilter = factory.and(factory.equal(exp1, exp2, false), batchIdFilter);
    }
    final VectorQueryBuilder bldr = VectorQueryBuilder.newBuilder().addTypeName(adapter.getTypeName()).indexName(index.getName());
    return (CloseableIterator<T>) dataStore.query(bldr.constraints(bldr.constraintsFactory().filterConstraints(finalFilter)).build());
}
Also used : VectorQueryBuilder(org.locationtech.geowave.core.geotime.store.query.api.VectorQueryBuilder) CloseableIterator(org.locationtech.geowave.core.store.CloseableIterator) Expression(org.opengis.filter.expression.Expression) Filter(org.opengis.filter.Filter) FilterFactoryImpl(org.geotools.filter.FilterFactoryImpl)

Aggregations

CloseableIterator (org.locationtech.geowave.core.store.CloseableIterator)49 IOException (java.io.IOException)24 Arrays (java.util.Arrays)22 List (java.util.List)22 ArrayList (java.util.ArrayList)21 CloseableIteratorWrapper (org.locationtech.geowave.core.store.CloseableIteratorWrapper)21 Iterators (com.google.common.collect.Iterators)19 Iterator (java.util.Iterator)17 GeoWaveRow (org.locationtech.geowave.core.store.entities.GeoWaveRow)17 Closeable (java.io.Closeable)15 Pair (org.apache.commons.lang3.tuple.Pair)15 Logger (org.slf4j.Logger)15 LoggerFactory (org.slf4j.LoggerFactory)15 ByteArray (org.locationtech.geowave.core.index.ByteArray)14 Index (org.locationtech.geowave.core.store.api.Index)14 Collections (java.util.Collections)13 ArrayUtils (org.apache.commons.lang3.ArrayUtils)13 GeoWaveRowIteratorTransformer (org.locationtech.geowave.core.store.entities.GeoWaveRowIteratorTransformer)13 MetadataReader (org.locationtech.geowave.core.store.operations.MetadataReader)13 MetadataType (org.locationtech.geowave.core.store.operations.MetadataType)13