Search in sources :

Example 1 with BasicNumericDimensionField

use of org.locationtech.geowave.core.store.dimension.BasicNumericDimensionField 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);
}
Also used : BasicNumericDimensionField(org.locationtech.geowave.core.store.dimension.BasicNumericDimensionField) NumericDimensionField(org.locationtech.geowave.core.store.dimension.NumericDimensionField) BasicNumericDimensionField(org.locationtech.geowave.core.store.dimension.BasicNumericDimensionField) SimpleLongIndexStrategy(org.locationtech.geowave.core.index.simple.SimpleLongIndexStrategy) SimpleShortIndexStrategy(org.locationtech.geowave.core.index.simple.SimpleShortIndexStrategy) SimpleDoubleIndexStrategy(org.locationtech.geowave.core.index.simple.SimpleDoubleIndexStrategy) SimpleFloatIndexStrategy(org.locationtech.geowave.core.index.simple.SimpleFloatIndexStrategy) ParameterException(com.beust.jcommander.ParameterException) SimpleIntegerIndexStrategy(org.locationtech.geowave.core.index.simple.SimpleIntegerIndexStrategy) SimpleByteIndexStrategy(org.locationtech.geowave.core.index.simple.SimpleByteIndexStrategy) NumericIndexStrategy(org.locationtech.geowave.core.index.NumericIndexStrategy)

Example 2 with BasicNumericDimensionField

use of org.locationtech.geowave.core.store.dimension.BasicNumericDimensionField in project geowave by locationtech.

the class TemporalDimensionalityTypeProvider method createIndexFromOptions.

public static Index createIndexFromOptions(final TemporalOptions options) {
    if (!options.noTimeRanges) {
        final NumericDimensionDefinition[] dimensions = TEMPORAL_DIMENSIONS;
        final NumericDimensionField<?>[] fields = TEMPORAL_FIELDS;
        dimensions[dimensions.length - 1] = new TimeDefinition(options.periodicity);
        fields[dimensions.length - 1] = new TimeField(options.periodicity);
        final BasicIndexModel indexModel = new BasicIndexModel(fields);
        final String combinedArrayID = DEFAULT_TEMPORAL_ID_STR + "_" + options.periodicity;
        return new CustomNameIndex(XZHierarchicalIndexFactory.createFullIncrementalTieredStrategy(dimensions, new int[] { 63 }, SFCType.HILBERT, options.maxDuplicates), indexModel, combinedArrayID);
    }
    final BasicIndexModel indexModel = new BasicIndexModel(new NumericDimensionField[] { new BasicNumericDimensionField<>(TimeField.DEFAULT_FIELD_ID, Long.class) });
    return new CustomNameIndex(new SimpleTimeIndexStrategy(), indexModel, DEFAULT_TEMPORAL_ID_STR);
}
Also used : BasicNumericDimensionField(org.locationtech.geowave.core.store.dimension.BasicNumericDimensionField) NumericDimensionField(org.locationtech.geowave.core.store.dimension.NumericDimensionField) TimeField(org.locationtech.geowave.core.geotime.store.dimension.TimeField) NumericDimensionDefinition(org.locationtech.geowave.core.index.dimension.NumericDimensionDefinition) BasicIndexModel(org.locationtech.geowave.core.store.index.BasicIndexModel) TimeDefinition(org.locationtech.geowave.core.geotime.index.dimension.TimeDefinition) SimpleTimeDefinition(org.locationtech.geowave.core.geotime.index.dimension.SimpleTimeDefinition) CustomNameIndex(org.locationtech.geowave.core.store.index.CustomNameIndex) SimpleTimeIndexStrategy(org.locationtech.geowave.core.geotime.index.dimension.SimpleTimeIndexStrategy)

Example 3 with BasicNumericDimensionField

use of org.locationtech.geowave.core.store.dimension.BasicNumericDimensionField 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();
}
Also used : BasicNumericDimensionField(org.locationtech.geowave.core.store.dimension.BasicNumericDimensionField) NumericDimensionField(org.locationtech.geowave.core.store.dimension.NumericDimensionField) BasicNumericDimensionField(org.locationtech.geowave.core.store.dimension.BasicNumericDimensionField) CustomNameIndex(org.locationtech.geowave.core.store.index.CustomNameIndex) Index(org.locationtech.geowave.core.store.api.Index) SimpleFeature(org.opengis.feature.simple.SimpleFeature) CustomNameIndex(org.locationtech.geowave.core.store.index.CustomNameIndex) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) GeotoolsFeatureDataAdapter(org.locationtech.geowave.core.geotime.store.GeotoolsFeatureDataAdapter) DataStore(org.locationtech.geowave.core.store.api.DataStore) SimpleDoubleIndexStrategy(org.locationtech.geowave.core.index.simple.SimpleDoubleIndexStrategy) BasicIndexModel(org.locationtech.geowave.core.store.index.BasicIndexModel) SimpleNumericQuery(org.locationtech.geowave.core.store.query.constraints.SimpleNumericQuery) SimpleFeatureBuilder(org.geotools.feature.simple.SimpleFeatureBuilder)

Aggregations

BasicNumericDimensionField (org.locationtech.geowave.core.store.dimension.BasicNumericDimensionField)3 NumericDimensionField (org.locationtech.geowave.core.store.dimension.NumericDimensionField)3 SimpleDoubleIndexStrategy (org.locationtech.geowave.core.index.simple.SimpleDoubleIndexStrategy)2 BasicIndexModel (org.locationtech.geowave.core.store.index.BasicIndexModel)2 CustomNameIndex (org.locationtech.geowave.core.store.index.CustomNameIndex)2 ParameterException (com.beust.jcommander.ParameterException)1 SimpleFeatureBuilder (org.geotools.feature.simple.SimpleFeatureBuilder)1 SimpleTimeDefinition (org.locationtech.geowave.core.geotime.index.dimension.SimpleTimeDefinition)1 SimpleTimeIndexStrategy (org.locationtech.geowave.core.geotime.index.dimension.SimpleTimeIndexStrategy)1 TimeDefinition (org.locationtech.geowave.core.geotime.index.dimension.TimeDefinition)1 GeotoolsFeatureDataAdapter (org.locationtech.geowave.core.geotime.store.GeotoolsFeatureDataAdapter)1 TimeField (org.locationtech.geowave.core.geotime.store.dimension.TimeField)1 NumericIndexStrategy (org.locationtech.geowave.core.index.NumericIndexStrategy)1 NumericDimensionDefinition (org.locationtech.geowave.core.index.dimension.NumericDimensionDefinition)1 SimpleByteIndexStrategy (org.locationtech.geowave.core.index.simple.SimpleByteIndexStrategy)1 SimpleFloatIndexStrategy (org.locationtech.geowave.core.index.simple.SimpleFloatIndexStrategy)1 SimpleIntegerIndexStrategy (org.locationtech.geowave.core.index.simple.SimpleIntegerIndexStrategy)1 SimpleLongIndexStrategy (org.locationtech.geowave.core.index.simple.SimpleLongIndexStrategy)1 SimpleShortIndexStrategy (org.locationtech.geowave.core.index.simple.SimpleShortIndexStrategy)1 DataStore (org.locationtech.geowave.core.store.api.DataStore)1