use of org.threeten.extra.Interval in project geowave by locationtech.
the class GeoWaveStatisticsIT method assertTimeBinning.
private static void assertTimeBinning(final DataStore ds, final TimeRangeStatistic stat, final int expectedCount, final Function<Interval, Duration> expectedDuration, final Interval overallInterval) {
try (CloseableIterator<Pair<ByteArray, Interval>> iterator = ds.getBinnedStatisticValues(stat)) {
int count = 0;
while (iterator.hasNext()) {
final Pair<ByteArray, Interval> binValue = iterator.next();
final Interval binRange = ((TimeRangeFieldValueBinningStrategy) stat.getBinningStrategy()).getInterval(binValue.getKey());
assertEquals(expectedDuration.apply(binValue.getValue()), binRange.toDuration());
assertTrue(binRange.encloses(binValue.getValue()));
assertTrue(overallInterval.encloses(binValue.getValue()));
count++;
}
assertEquals(expectedCount, count);
}
}
use of org.threeten.extra.Interval in project geowave by locationtech.
the class TimeRangeAggregation method aggregate.
@Override
public void aggregate(final DataTypeAdapter<T> adapter, final T entry) {
final Interval env = getInterval(entry);
aggregate(env);
}
use of org.threeten.extra.Interval in project geowave by locationtech.
the class TemporalBetween method evaluate.
@Override
public boolean evaluate(final Map<String, Object> fieldValues) {
final Interval value = TimeUtils.getInterval(valueExpr.evaluateValue(fieldValues));
final Interval lowerBound = TimeUtils.getInterval(lowerBoundExpr.evaluateValue(fieldValues));
final Interval upperBound = TimeUtils.getInterval(upperBoundExpr.evaluateValue(fieldValues));
return evaluate(value, lowerBound, upperBound);
}
use of org.threeten.extra.Interval in project geowave by locationtech.
the class TemporalBetween method evaluate.
@Override
public <T> boolean evaluate(final DataTypeAdapter<T> adapter, final T entry) {
final Interval value = TimeUtils.getInterval(valueExpr.evaluateValue(adapter, entry));
final Interval lowerBound = TimeUtils.getInterval(lowerBoundExpr.evaluateValue(adapter, entry));
final Interval upperBound = TimeUtils.getInterval(upperBoundExpr.evaluateValue(adapter, entry));
return evaluate(value, lowerBound, upperBound);
}
use of org.threeten.extra.Interval in project geowave by locationtech.
the class TemporalBetween method getConstraints.
@SuppressWarnings("unchecked")
@Override
public <V extends Comparable<V>> FilterConstraints<V> getConstraints(final Class<V> constraintClass, final DataStatisticsStore statsStore, final DataTypeAdapter<?> adapter, final AdapterToIndexMapping indexMapping, final Index index, final Set<String> indexedFields) {
if ((valueExpr instanceof FieldValue) && indexedFields.contains(((FieldValue<?>) valueExpr).getFieldName()) && lowerBoundExpr.isLiteral() && upperBoundExpr.isLiteral() && constraintClass.isAssignableFrom(Double.class)) {
final Interval lowerBound = lowerBoundExpr.evaluateValue(null, null);
final Interval upperBound = upperBoundExpr.evaluateValue(null, null);
if ((lowerBound != null) && (upperBound != null)) {
return FilterConstraints.of(adapter, indexMapping, index, ((FieldValue<?>) valueExpr).getFieldName(), (IndexFieldConstraints<V>) NumericFieldConstraints.of((double) lowerBound.getStart().toEpochMilli(), (double) TimeUtils.getIntervalEnd(upperBound).toEpochMilli(), true, false, index.getIndexStrategy() instanceof SimpleNumericIndexStrategy));
}
}
return FilterConstraints.empty();
}
Aggregations