use of org.locationtech.geowave.core.index.simple.SimpleDoubleIndexStrategy in project geowave by locationtech.
the class NumericAttributeIndexProvider method buildIndex.
@Override
public AttributeIndex buildIndex(final String indexName, final DataTypeAdapter<?> adapter, final FieldDescriptor<?> fieldDescriptor) {
final Class<?> bindingClass = fieldDescriptor.bindingClass();
final String fieldName = fieldDescriptor.fieldName();
final NumericIndexStrategy indexStrategy;
final CommonIndexModel indexModel;
if (Byte.class.isAssignableFrom(bindingClass)) {
indexStrategy = new SimpleByteIndexStrategy();
indexModel = new BasicIndexModel(new NumericDimensionField[] { new BasicNumericDimensionField<>(fieldName, Byte.class) });
} else if (Short.class.isAssignableFrom(bindingClass)) {
indexStrategy = new SimpleShortIndexStrategy();
indexModel = new BasicIndexModel(new NumericDimensionField[] { new BasicNumericDimensionField<>(fieldName, Short.class) });
} else if (Integer.class.isAssignableFrom(bindingClass)) {
indexStrategy = new SimpleIntegerIndexStrategy();
indexModel = new BasicIndexModel(new NumericDimensionField[] { new BasicNumericDimensionField<>(fieldName, Integer.class) });
} else if (Long.class.isAssignableFrom(bindingClass)) {
indexStrategy = new SimpleLongIndexStrategy();
indexModel = new BasicIndexModel(new NumericDimensionField[] { new BasicNumericDimensionField<>(fieldName, Long.class) });
} else if (Float.class.isAssignableFrom(bindingClass)) {
indexStrategy = new SimpleFloatIndexStrategy();
indexModel = new BasicIndexModel(new NumericDimensionField[] { new BasicNumericDimensionField<>(fieldName, Float.class) });
} else if (Double.class.isAssignableFrom(bindingClass)) {
indexStrategy = new SimpleDoubleIndexStrategy();
indexModel = new BasicIndexModel(new NumericDimensionField[] { new BasicNumericDimensionField<>(fieldName, Double.class) });
} else {
throw new ParameterException("Unsupported numeric attribute index class: " + bindingClass.getName());
}
return new AttributeIndexImpl(indexStrategy, indexModel, indexName, fieldName);
}
use of org.locationtech.geowave.core.index.simple.SimpleDoubleIndexStrategy 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