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