Search in sources :

Example 1 with BasicNumericDataset

use of org.locationtech.geowave.core.index.numeric.BasicNumericDataset in project geowave by locationtech.

the class HashKeyIndexStrategyTest method testDistribution.

@Test
public void testDistribution() {
    final Map<ByteArray, Long> counts = new HashMap<>();
    int total = 0;
    for (double x = 90; x < 180; x += 0.05) {
        for (double y = 50; y < 90; y += 0.5) {
            final NumericRange dimension1Range = new NumericRange(x, x + 0.002);
            final NumericRange dimension2Range = new NumericRange(y - 0.002, y);
            final MultiDimensionalNumericData sfcIndexedRange = new BasicNumericDataset(new NumericData[] { dimension1Range, dimension2Range });
            for (final byte[] id : hashIdexStrategy.getInsertionPartitionKeys(sfcIndexedRange)) {
                final Long count = counts.get(new ByteArray(id));
                final long nextcount = count == null ? 1 : count + 1;
                counts.put(new ByteArray(id), nextcount);
                total++;
            }
        }
    }
    final double mean = total / counts.size();
    double diff = 0.0;
    for (final Long count : counts.values()) {
        diff += Math.pow(mean - count, 2);
    }
    final double sd = Math.sqrt(diff / counts.size());
    assertTrue(sd < (mean * 0.18));
}
Also used : NumericRange(org.locationtech.geowave.core.index.numeric.NumericRange) MultiDimensionalNumericData(org.locationtech.geowave.core.index.numeric.MultiDimensionalNumericData) HashMap(java.util.HashMap) BasicNumericDataset(org.locationtech.geowave.core.index.numeric.BasicNumericDataset) ByteArray(org.locationtech.geowave.core.index.ByteArray) Test(org.junit.Test)

Example 2 with BasicNumericDataset

use of org.locationtech.geowave.core.index.numeric.BasicNumericDataset in project geowave by locationtech.

the class NumericFieldConstraints method generateNumericData.

private static void generateNumericData(final List<MultiDimensionalIndexData<Double>> results, final int currentDimension, final List<DimensionConstraints<Double>> dimensions, final NumericData[] current) {
    if (currentDimension == dimensions.size()) {
        results.add(new BasicNumericDataset(current));
        return;
    }
    final DimensionConstraints<Double> dimension = dimensions.get(currentDimension);
    final List<FilterRange<Double>> ranges = dimension.getRanges();
    for (int i = 0; i < ranges.size(); i++) {
        final NumericData[] copy = Arrays.copyOf(current, current.length + 1);
        final FilterRange<Double> range = ranges.get(i);
        final Double start = toStartRangeValue(range.getStart());
        final Double end = toEndRangeValue(range.getEnd());
        if (start.equals(end) && range.isStartInclusive() && range.isEndInclusive()) {
            copy[copy.length - 1] = new NumericValue(start);
        } else {
            copy[copy.length - 1] = new NumericRange(toStartRangeValue(range.getStart()), toEndRangeValue(range.getEnd()), range.isStartInclusive(), range.isEndInclusive());
        }
        generateNumericData(results, currentDimension + 1, dimensions, copy);
    }
}
Also used : NumericRange(org.locationtech.geowave.core.index.numeric.NumericRange) BasicNumericDataset(org.locationtech.geowave.core.index.numeric.BasicNumericDataset) NumericData(org.locationtech.geowave.core.index.numeric.NumericData) FilterRange(org.locationtech.geowave.core.store.query.filter.expression.FilterRange) NumericValue(org.locationtech.geowave.core.index.numeric.NumericValue)

Example 3 with BasicNumericDataset

use of org.locationtech.geowave.core.index.numeric.BasicNumericDataset in project geowave by locationtech.

the class SpatialQueryFilter method stripGeometry.

private static StrippedGeometry stripGeometry(final MultiDimensionalNumericData query, final NumericDimensionField<?>[] orderedConstrainedDimensionDefinitions, final NumericDimensionField<?>[] unconstrainedDimensionDefinitions) {
    final Set<String> geometryFieldNames = new HashSet<>();
    final List<NumericData> numericDataPerDimension = new ArrayList<>();
    final List<NumericDimensionField<?>> fields = new ArrayList<>();
    final NumericData[] data = query.getDataPerDimension();
    for (int d = 0; d < orderedConstrainedDimensionDefinitions.length; d++) {
        // the field ID for later filtering
        if (isSpatial(orderedConstrainedDimensionDefinitions[d])) {
            geometryFieldNames.add(orderedConstrainedDimensionDefinitions[d].getFieldName());
        } else {
            numericDataPerDimension.add(data[d]);
            fields.add(orderedConstrainedDimensionDefinitions[d]);
        }
    }
    // results)
    for (int d = 0; d < unconstrainedDimensionDefinitions.length; d++) {
        if (isSpatial(unconstrainedDimensionDefinitions[d])) {
            geometryFieldNames.add(unconstrainedDimensionDefinitions[d].getFieldName());
        }
    }
    return new StrippedGeometry(new BasicNumericDataset(numericDataPerDimension.toArray(new NumericData[numericDataPerDimension.size()])), fields.toArray(new NumericDimensionField<?>[fields.size()]), geometryFieldNames);
}
Also used : NumericDimensionField(org.locationtech.geowave.core.store.dimension.NumericDimensionField) BasicNumericDataset(org.locationtech.geowave.core.index.numeric.BasicNumericDataset) NumericData(org.locationtech.geowave.core.index.numeric.NumericData) MultiDimensionalNumericData(org.locationtech.geowave.core.index.numeric.MultiDimensionalNumericData) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet)

Example 4 with BasicNumericDataset

use of org.locationtech.geowave.core.index.numeric.BasicNumericDataset in project geowave by locationtech.

the class HilbertSFCTest method testDecomposeQuery_2DSpatialOneIndexFilter.

@Test
public void testDecomposeQuery_2DSpatialOneIndexFilter() {
    final int LATITUDE_BITS = 31;
    final int LONGITUDE_BITS = 31;
    final SFCDimensionDefinition[] SPATIAL_DIMENSIONS = new SFCDimensionDefinition[] { new SFCDimensionDefinition(new LongitudeDefinition(), LONGITUDE_BITS), new SFCDimensionDefinition(new LatitudeDefinition(), LATITUDE_BITS) };
    final SpaceFillingCurve hilbertSFC = SFCFactory.createSpaceFillingCurve(SPATIAL_DIMENSIONS, SFCType.HILBERT);
    // Create a IndexRange object using the x axis
    final NumericRange rangeX = new NumericRange(55, 57);
    // Create a IndexRange object using the y axis
    final NumericRange rangeY = new NumericRange(25, 27);
    final BasicNumericDataset spatialQuery = new BasicNumericDataset(new NumericData[] { rangeX, rangeY });
    final RangeDecomposition rangeDecomposition = hilbertSFC.decomposeRange(spatialQuery, true, 1);
    Assert.assertEquals(1, rangeDecomposition.getRanges().length);
}
Also used : NumericRange(org.locationtech.geowave.core.index.numeric.NumericRange) LatitudeDefinition(org.locationtech.geowave.core.geotime.index.dimension.LatitudeDefinition) BasicNumericDataset(org.locationtech.geowave.core.index.numeric.BasicNumericDataset) SFCDimensionDefinition(org.locationtech.geowave.core.index.sfc.SFCDimensionDefinition) SpaceFillingCurve(org.locationtech.geowave.core.index.sfc.SpaceFillingCurve) RangeDecomposition(org.locationtech.geowave.core.index.sfc.RangeDecomposition) LongitudeDefinition(org.locationtech.geowave.core.geotime.index.dimension.LongitudeDefinition) Test(org.junit.Test)

Example 5 with BasicNumericDataset

use of org.locationtech.geowave.core.index.numeric.BasicNumericDataset in project geowave by locationtech.

the class HilbertSFCTest method testDecomposeQuery_2DSpatialTwentyIndexFilters.

@Test
public void testDecomposeQuery_2DSpatialTwentyIndexFilters() {
    final int LATITUDE_BITS = 31;
    final int LONGITUDE_BITS = 31;
    final SFCDimensionDefinition[] SPATIAL_DIMENSIONS = new SFCDimensionDefinition[] { new SFCDimensionDefinition(new LongitudeDefinition(), LONGITUDE_BITS), new SFCDimensionDefinition(new LatitudeDefinition(), LATITUDE_BITS) };
    final SpaceFillingCurve hilbertSFC = SFCFactory.createSpaceFillingCurve(SPATIAL_DIMENSIONS, SFCType.HILBERT);
    // Create a IndexRange object using the x axis
    final NumericRange rangeX = new NumericRange(10, 57);
    // Create a IndexRange object using the y axis
    final NumericRange rangeY = new NumericRange(25, 50);
    final BasicNumericDataset spatialQuery = new BasicNumericDataset(new NumericData[] { rangeX, rangeY });
    final RangeDecomposition rangeDecomposition = hilbertSFC.decomposeRange(spatialQuery, true, 20);
    Assert.assertEquals(20, rangeDecomposition.getRanges().length);
}
Also used : NumericRange(org.locationtech.geowave.core.index.numeric.NumericRange) LatitudeDefinition(org.locationtech.geowave.core.geotime.index.dimension.LatitudeDefinition) BasicNumericDataset(org.locationtech.geowave.core.index.numeric.BasicNumericDataset) SFCDimensionDefinition(org.locationtech.geowave.core.index.sfc.SFCDimensionDefinition) SpaceFillingCurve(org.locationtech.geowave.core.index.sfc.SpaceFillingCurve) RangeDecomposition(org.locationtech.geowave.core.index.sfc.RangeDecomposition) LongitudeDefinition(org.locationtech.geowave.core.geotime.index.dimension.LongitudeDefinition) Test(org.junit.Test)

Aggregations

BasicNumericDataset (org.locationtech.geowave.core.index.numeric.BasicNumericDataset)21 NumericData (org.locationtech.geowave.core.index.numeric.NumericData)16 MultiDimensionalNumericData (org.locationtech.geowave.core.index.numeric.MultiDimensionalNumericData)15 NumericRange (org.locationtech.geowave.core.index.numeric.NumericRange)15 Test (org.junit.Test)13 InsertionIds (org.locationtech.geowave.core.index.InsertionIds)6 NumericIndexStrategy (org.locationtech.geowave.core.index.NumericIndexStrategy)5 NumericValue (org.locationtech.geowave.core.index.numeric.NumericValue)5 NumericDimensionField (org.locationtech.geowave.core.store.dimension.NumericDimensionField)5 ArrayList (java.util.ArrayList)4 LatitudeDefinition (org.locationtech.geowave.core.geotime.index.dimension.LatitudeDefinition)4 LongitudeDefinition (org.locationtech.geowave.core.geotime.index.dimension.LongitudeDefinition)4 HashMap (java.util.HashMap)3 SFCDimensionDefinition (org.locationtech.geowave.core.index.sfc.SFCDimensionDefinition)3 Index (org.locationtech.geowave.core.store.api.Index)3 BasicQueryByClass (org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass)3 ConstraintData (org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass.ConstraintData)3 ConstraintSet (org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass.ConstraintSet)3 ConstraintsByClass (org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass.ConstraintsByClass)3 Calendar (java.util.Calendar)2