Search in sources :

Example 1 with SimpleNumericIndexStrategy

use of org.locationtech.geowave.core.index.simple.SimpleNumericIndexStrategy 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();
}
Also used : SimpleNumericIndexStrategy(org.locationtech.geowave.core.index.simple.SimpleNumericIndexStrategy) FieldValue(org.locationtech.geowave.core.store.query.filter.expression.FieldValue) Interval(org.threeten.extra.Interval)

Example 2 with SimpleNumericIndexStrategy

use of org.locationtech.geowave.core.index.simple.SimpleNumericIndexStrategy in project geowave by locationtech.

the class BinaryTemporalPredicate 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 ((expression1 instanceof FieldValue) && indexedFields.contains(((FieldValue<?>) expression1).getFieldName()) && expression2.isLiteral() && constraintClass.isAssignableFrom(Double.class)) {
        final Double minValue;
        final Double maxValue;
        if (index.getIndexStrategy() instanceof SimpleNumericIndexStrategy) {
            minValue = null;
            maxValue = null;
        } else {
            final TimeRangeValue timeRange = InternalStatisticsHelper.getFieldStatistic(statsStore, TimeRangeStatistic.STATS_TYPE, adapter.getTypeName(), ((FieldValue<?>) expression1).getFieldName());
            if (timeRange != null) {
                minValue = (double) timeRange.getMin();
                maxValue = (double) timeRange.getMax();
            } else {
                // We cannot determine the query range for the binned
                return FilterConstraints.empty();
            }
        }
        String fieldName = ((FieldValue<?>) expression1).getFieldName();
        final boolean partOfRange = isPartOfRange(fieldName, indexMapping);
        final Interval literal = expression2.evaluateValue(null, null);
        if (literal != null) {
            return FilterConstraints.of(adapter, indexMapping, index, fieldName, (IndexFieldConstraints<V>) getConstraints(literal, minValue, maxValue, false, !partOfRange && index.getIndexStrategy() instanceof SimpleNumericIndexStrategy));
        }
    } else if ((expression2 instanceof FieldValue) && indexedFields.contains(((FieldValue<?>) expression2).getFieldName()) && expression1.isLiteral() && constraintClass.isAssignableFrom(Double.class)) {
        final Double minValue;
        final Double maxValue;
        if (index.getIndexStrategy() instanceof SimpleNumericIndexStrategy) {
            minValue = null;
            maxValue = null;
        } else {
            final TimeRangeValue timeRange = InternalStatisticsHelper.getFieldStatistic(statsStore, TimeRangeStatistic.STATS_TYPE, adapter.getTypeName(), ((FieldValue<?>) expression2).getFieldName());
            if (timeRange != null) {
                minValue = (double) timeRange.getMin();
                maxValue = (double) timeRange.getMax();
            } else {
                // We cannot determine the query range for the binned
                return FilterConstraints.empty();
            }
        }
        String fieldName = ((FieldValue<?>) expression2).getFieldName();
        final boolean partOfRange = isPartOfRange(fieldName, indexMapping);
        final Interval literal = expression1.evaluateValue(null, null);
        if (literal != null) {
            return FilterConstraints.of(adapter, indexMapping, index, fieldName, (IndexFieldConstraints<V>) getConstraints(literal, minValue, maxValue, true, !partOfRange && index.getIndexStrategy() instanceof SimpleNumericIndexStrategy));
        }
    }
    return FilterConstraints.empty();
}
Also used : SimpleNumericIndexStrategy(org.locationtech.geowave.core.index.simple.SimpleNumericIndexStrategy) IndexFieldConstraints(org.locationtech.geowave.core.store.query.filter.expression.IndexFieldConstraints) FieldValue(org.locationtech.geowave.core.store.query.filter.expression.FieldValue) TimeRangeValue(org.locationtech.geowave.core.geotime.store.statistics.TimeRangeStatistic.TimeRangeValue) Interval(org.threeten.extra.Interval)

Aggregations

SimpleNumericIndexStrategy (org.locationtech.geowave.core.index.simple.SimpleNumericIndexStrategy)2 FieldValue (org.locationtech.geowave.core.store.query.filter.expression.FieldValue)2 Interval (org.threeten.extra.Interval)2 TimeRangeValue (org.locationtech.geowave.core.geotime.store.statistics.TimeRangeStatistic.TimeRangeValue)1 IndexFieldConstraints (org.locationtech.geowave.core.store.query.filter.expression.IndexFieldConstraints)1