use of org.locationtech.geowave.core.store.query.constraints.SimpleNumericQuery in project geowave by locationtech.
the class SimpleQuerySecondaryIndexIT method testMultipleSecondaryIndices.
// @Test
public void testMultipleSecondaryIndices() {
final DataStore ds = dataStoreOptions.createDataStore();
final SimpleFeatureType sft = SimpleIngest.createPointFeatureType();
final GeotoolsFeatureDataAdapter fda = SimpleIngest.createDataAdapter(sft);
final List<SimpleFeature> features = SimpleIngest.getGriddedFeatures(new SimpleFeatureBuilder(sft), 1234);
final Index latIdx = new CustomNameIndex(new SimpleDoubleIndexStrategy(), new BasicIndexModel(new NumericDimensionField[] { new BasicNumericDimensionField<>("Latitude", Double.class) }), "Lat_IDX");
final Index lonIdx = new CustomNameIndex(new SimpleDoubleIndexStrategy(), new BasicIndexModel(new NumericDimensionField[] { new BasicNumericDimensionField<>("Longitude", Double.class) }), "Lon_IDX");
ds.addType(fda, TestUtils.DEFAULT_SPATIAL_INDEX, latIdx, lonIdx);
int ingestedFeatures = 0;
try (Writer<SimpleFeature> writer = ds.createWriter(fda.getTypeName())) {
for (final SimpleFeature feat : features) {
ingestedFeatures++;
if ((ingestedFeatures % 5) == 0) {
// just write 20 percent of the grid
writer.write(feat);
}
}
}
try (CloseableIterator<SimpleFeature> it = ds.query(VectorQueryBuilder.newBuilder().indexName("Lon_IDX").addTypeName(sft.getTypeName()).constraints(new SimpleNumericQuery(Range.between((double) 0, (double) 0))).build())) {
int count = 0;
while (it.hasNext()) {
it.next();
count++;
}
Assert.assertTrue(count > 1);
}
Assert.assertTrue(ds.delete(VectorQueryBuilder.newBuilder().indexName("Lon_IDX").addTypeName(sft.getTypeName()).constraints(new SimpleNumericQuery(Range.between((double) 0, (double) 0))).build()));
try (CloseableIterator<SimpleFeature> it = ds.query(VectorQueryBuilder.newBuilder().indexName("Lon_IDX").addTypeName(sft.getTypeName()).constraints(new SimpleNumericQuery(Range.between((double) 0, (double) 0))).build())) {
int count = 0;
while (it.hasNext()) {
it.next();
count++;
}
Assert.assertTrue(count == 0);
}
try (CloseableIterator<SimpleFeature> it = ds.query(VectorQueryBuilder.newBuilder().indexName("Lon_IDX").addTypeName(sft.getTypeName()).constraints(new SimpleNumericQuery(Range.between((double) 1, (double) 45))).build())) {
int count = 0;
while (it.hasNext()) {
it.next();
count++;
}
Assert.assertTrue(count > 1);
}
ds.deleteAll();
}
Aggregations