Search in sources :

Example 1 with ComparableIdentifiedDataSerializable

use of com.hazelcast.query.impl.ComparableIdentifiedDataSerializable in project hazelcast by hazelcast.

the class IndexResolver method addInfiniteRanges.

/**
 * Adds infinite ranges to filter components, to match the number of index components.
 * <p>
 * For example, for the index on {@code (a, b)} and the expression {@code a=1}, the original filter would be
 * {@code from={a=1}, to={a=1}}.
 * <p>
 * Since the index has two components, we need to add infinite ranges to components that do not have explicit filters.
 * After the method finishes, the filter would be {@code from={a=1, b=NEGATIVE_INFINITY}, to={a=1, b=POSITIVE_INFINITY}}.
 * <p>
 * The combination of ranges also depends on the inclusion. For example, {@code {a>1}} yields {@code NEGATIVE_INFINITY}
 * for {@code b} on the left side, while {@code {a>=1}} yields {@code POSITIVE_INFINITY}.
 *
 * @param fromComponents  expressions for the "from" part
 * @param toComponents    expressions for the "to" part
 * @param componentsCount the number of components in the index
 */
private static void addInfiniteRanges(List<Expression> fromComponents, List<Boolean> fromAllowNulls, boolean fromInclusive, List<Expression> toComponents, List<Boolean> toAllowNulls, boolean toInclusive, int componentsCount) {
    int count = componentsCount - fromComponents.size();
    ComparableIdentifiedDataSerializable leftBound = fromInclusive ? NEGATIVE_INFINITY : POSITIVE_INFINITY;
    ComparableIdentifiedDataSerializable toBound = toInclusive ? POSITIVE_INFINITY : NEGATIVE_INFINITY;
    for (int i = 0; i < count; i++) {
        fromComponents.add(ConstantExpression.create(leftBound, QueryDataType.OBJECT));
        toComponents.add(ConstantExpression.create(toBound, QueryDataType.OBJECT));
        fromAllowNulls.add(false);
        toAllowNulls.add(false);
    }
}
Also used : ComparableIdentifiedDataSerializable(com.hazelcast.query.impl.ComparableIdentifiedDataSerializable)

Aggregations

ComparableIdentifiedDataSerializable (com.hazelcast.query.impl.ComparableIdentifiedDataSerializable)1