Search in sources :

Example 1 with NumericRange

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

the class NumericRangeTest method testNumericRangeValues.

@Test
public void testNumericRangeValues() {
    final NumericRange numericRange = new NumericRange(MINIMUM, MAXIMUM);
    Assert.assertEquals(MINIMUM, numericRange.getMin(), DELTA);
    Assert.assertEquals(MAXIMUM, numericRange.getMax(), DELTA);
    Assert.assertEquals(CENTROID, numericRange.getCentroid(), DELTA);
    Assert.assertTrue(numericRange.isRange());
}
Also used : NumericRange(org.locationtech.geowave.core.index.numeric.NumericRange) Test(org.junit.Test)

Example 2 with NumericRange

use of org.locationtech.geowave.core.index.numeric.NumericRange 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 3 with NumericRange

use of org.locationtech.geowave.core.index.numeric.NumericRange 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 4 with NumericRange

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

the class TemporalBinningStrategy method getDenormalizedRanges.

@Override
public NumericRange getDenormalizedRanges(final BinRange binnedRange) {
    final Calendar startofEpoch = getStartEpoch(binnedRange.getBinId());
    final long startOfEpochMillis = startofEpoch.getTimeInMillis();
    final long minMillis = startOfEpochMillis + (long) binnedRange.getNormalizedMin();
    final long maxMillis = startOfEpochMillis + (long) binnedRange.getNormalizedMax();
    return new NumericRange(minMillis, maxMillis);
}
Also used : NumericRange(org.locationtech.geowave.core.index.numeric.NumericRange) Calendar(java.util.Calendar)

Example 5 with NumericRange

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

the class TemporalBinningStrategyTest method testFeb28ToMarch1NonLeapYear.

@Test
public void testFeb28ToMarch1NonLeapYear() {
    final long time = 47920164930285667L;
    final Calendar startCal = Calendar.getInstance();
    startCal.setTimeInMillis(time);
    startCal.set(Calendar.MONTH, 1);
    startCal.set(Calendar.YEAR, 2015);
    startCal.set(Calendar.DAY_OF_MONTH, 28);
    final Calendar endCal = Calendar.getInstance();
    endCal.setTimeInMillis(time);
    endCal.set(Calendar.MONTH, 2);
    endCal.set(Calendar.YEAR, 2015);
    endCal.set(Calendar.DAY_OF_MONTH, 1);
    // test the day boundaries first - going from feb28 to march 1 should
    // give 2 bins
    TemporalBinningStrategy binStrategy = new TemporalBinningStrategy(Unit.DAY);
    BinRange[] ranges = binStrategy.getNormalizedRanges(new NumericRange(startCal.getTimeInMillis(), endCal.getTimeInMillis()));
    Assert.assertEquals(2, ranges.length);
    // now test the month boundaries - adding a day to feb28 for the end
    // time should give 2 bins
    binStrategy = new TemporalBinningStrategy(Unit.MONTH);
    ranges = binStrategy.getNormalizedRanges(new NumericRange(startCal.getTimeInMillis(), startCal.getTimeInMillis() + (TemporalBinningStrategy.MILLIS_PER_DAY)));
    Assert.assertEquals(2, ranges.length);
}
Also used : NumericRange(org.locationtech.geowave.core.index.numeric.NumericRange) BinRange(org.locationtech.geowave.core.index.dimension.bin.BinRange) Calendar(java.util.Calendar) Test(org.junit.Test)

Aggregations

NumericRange (org.locationtech.geowave.core.index.numeric.NumericRange)37 Test (org.junit.Test)22 BasicNumericDataset (org.locationtech.geowave.core.index.numeric.BasicNumericDataset)15 BinRange (org.locationtech.geowave.core.index.dimension.bin.BinRange)10 MultiDimensionalNumericData (org.locationtech.geowave.core.index.numeric.MultiDimensionalNumericData)10 NumericData (org.locationtech.geowave.core.index.numeric.NumericData)10 Calendar (java.util.Calendar)9 LatitudeDefinition (org.locationtech.geowave.core.geotime.index.dimension.LatitudeDefinition)4 LongitudeDefinition (org.locationtech.geowave.core.geotime.index.dimension.LongitudeDefinition)4 InsertionIds (org.locationtech.geowave.core.index.InsertionIds)4 NumericIndexStrategy (org.locationtech.geowave.core.index.NumericIndexStrategy)3 NumericDimensionDefinition (org.locationtech.geowave.core.index.dimension.NumericDimensionDefinition)3 NumericValue (org.locationtech.geowave.core.index.numeric.NumericValue)3 RangeDecomposition (org.locationtech.geowave.core.index.sfc.RangeDecomposition)3 SFCDimensionDefinition (org.locationtech.geowave.core.index.sfc.SFCDimensionDefinition)3 DataStore (org.locationtech.geowave.core.store.api.DataStore)3 Index (org.locationtech.geowave.core.store.api.Index)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 PersistableStore (org.locationtech.geowave.analytic.store.PersistableStore)2