Search in sources :

Example 1 with VectorAggregationQueryBuilder

use of org.locationtech.geowave.core.geotime.store.query.api.VectorAggregationQueryBuilder in project geowave by locationtech.

the class BBOXQuery method runQuery.

@Override
protected long runQuery(final GeotoolsFeatureDataAdapter adapter, final String typeName, final String indexName, final DataStore dataStore, final boolean debug, final DataStorePluginOptions pluginOptions) {
    final StopWatch stopWatch = new StopWatch();
    getBoxGeom();
    long count = 0;
    if (useAggregation) {
        final VectorAggregationQueryBuilder<Persistable, Long> bldr = (VectorAggregationQueryBuilder) VectorAggregationQueryBuilder.newBuilder().count(typeName).indexName(indexName);
        final Long countResult = dataStore.aggregate(bldr.constraints(bldr.constraintsFactory().spatialTemporalConstraints().spatialConstraints(geom).build()).build());
        if (countResult != null) {
            count += countResult;
        }
    } else {
        final VectorQueryBuilder bldr = VectorQueryBuilder.newBuilder().addTypeName(typeName).indexName(indexName);
        stopWatch.start();
        try (final CloseableIterator<SimpleFeature> it = dataStore.query(bldr.constraints(bldr.constraintsFactory().spatialTemporalConstraints().spatialConstraints(geom).build()).build())) {
            stopWatch.stop();
            System.out.println("Ran BBOX query in " + stopWatch.toString());
            stopWatch.reset();
            stopWatch.start();
            while (it.hasNext()) {
                if (debug) {
                    System.out.println(it.next());
                } else {
                    it.next();
                }
                count++;
            }
            stopWatch.stop();
            System.out.println("BBOX query results iteration took " + stopWatch.toString());
        }
    }
    return count;
}
Also used : VectorQueryBuilder(org.locationtech.geowave.core.geotime.store.query.api.VectorQueryBuilder) Persistable(org.locationtech.geowave.core.index.persist.Persistable) VectorAggregationQueryBuilder(org.locationtech.geowave.core.geotime.store.query.api.VectorAggregationQueryBuilder) SimpleFeature(org.opengis.feature.simple.SimpleFeature) StopWatch(org.apache.commons.lang3.time.StopWatch)

Example 2 with VectorAggregationQueryBuilder

use of org.locationtech.geowave.core.geotime.store.query.api.VectorAggregationQueryBuilder in project geowave by locationtech.

the class CQLQuery method runQuery.

@Override
protected long runQuery(final GeotoolsFeatureDataAdapter adapter, final String typeName, final String indexName, final DataStore dataStore, final boolean debug, final DataStorePluginOptions pluginOptions) {
    long count = 0;
    if (useAggregation) {
        final VectorAggregationQueryBuilder<Persistable, Long> bldr = (VectorAggregationQueryBuilder) VectorAggregationQueryBuilder.newBuilder().count(typeName).indexName(indexName);
        final Long countResult = dataStore.aggregate(bldr.constraints(bldr.constraintsFactory().cqlConstraints(cqlStr)).build());
        if (countResult != null) {
            count += countResult;
        }
        return count;
    } else {
        final VectorQueryBuilder bldr = VectorQueryBuilder.newBuilder().addTypeName(typeName).indexName(indexName);
        try (final CloseableIterator<SimpleFeature> it = dataStore.query(bldr.constraints(bldr.constraintsFactory().cqlConstraints(cqlStr)).build())) {
            while (it.hasNext()) {
                if (debug) {
                    System.out.println(it.next());
                } else {
                    it.next();
                }
                count++;
            }
        }
        return count;
    }
}
Also used : VectorQueryBuilder(org.locationtech.geowave.core.geotime.store.query.api.VectorQueryBuilder) Persistable(org.locationtech.geowave.core.index.persist.Persistable) VectorAggregationQueryBuilder(org.locationtech.geowave.core.geotime.store.query.api.VectorAggregationQueryBuilder) SimpleFeature(org.opengis.feature.simple.SimpleFeature)

Aggregations

VectorAggregationQueryBuilder (org.locationtech.geowave.core.geotime.store.query.api.VectorAggregationQueryBuilder)2 VectorQueryBuilder (org.locationtech.geowave.core.geotime.store.query.api.VectorQueryBuilder)2 Persistable (org.locationtech.geowave.core.index.persist.Persistable)2 SimpleFeature (org.opengis.feature.simple.SimpleFeature)2 StopWatch (org.apache.commons.lang3.time.StopWatch)1