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());
}
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));
}
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);
}
}
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);
}
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);
}
Aggregations