Search in sources :

Example 1 with IndexFieldConstraints

use of org.locationtech.geowave.core.store.query.filter.expression.IndexFieldConstraints 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

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