use of com.hazelcast.sql.impl.exec.scan.index.IndexFilterValue in project hazelcast by hazelcast.
the class IndexResolver method fillNonTerminalComponents.
/**
* Given the list of column filters, flatten their expressions and allow-null flags.
* <p>
* The operation is performed for all filters except for the last one, because treatment of the last filter might differ
* depending on the total number of components in the index.
*
* @param filters column filters
* @param components expressions that would form the final filter
* @param allowNulls allow-null collection relevant to components
*/
private static void fillNonTerminalComponents(List<IndexFilter> filters, List<Expression> components, List<Boolean> allowNulls) {
for (int i = 0; i < filters.size() - 1; i++) {
IndexEqualsFilter filter0 = (IndexEqualsFilter) filters.get(i);
IndexFilterValue value = filter0.getValue();
assert value.getComponents().size() == 1;
components.add(value.getComponents().get(0));
allowNulls.add(value.getAllowNulls().get(0));
}
assert components.size() == filters.size() - 1;
assert allowNulls.size() == filters.size() - 1;
}
use of com.hazelcast.sql.impl.exec.scan.index.IndexFilterValue in project hazelcast by hazelcast.
the class IndexResolver method prepareSingleColumnCandidateIsNull.
/**
* Try creating a candidate filter for the "IS NULL" expression.
* <p>
* Returns the filter EQUALS(null) with "allowNulls-true".
*
* @param exp original expression, e.g. {col IS NULL}
* @param operand operand, e.g. {col}; CAST must be unwrapped before the method is invoked
* @return candidate or {@code null}
*/
private static IndexComponentCandidate prepareSingleColumnCandidateIsNull(RexNode exp, RexNode operand) {
if (operand.getKind() != SqlKind.INPUT_REF) {
// The operand is not a column, e.g. {'literal' IS NULL}, index cannot be used
return null;
}
int columnIndex = ((RexInputRef) operand).getIndex();
QueryDataType type = HazelcastTypeUtils.toHazelcastType(operand.getType());
// Create a value with "allowNulls=true"
IndexFilterValue filterValue = new IndexFilterValue(singletonList(ConstantExpression.create(null, type)), singletonList(true));
IndexFilter filter = new IndexEqualsFilter(filterValue);
return new IndexComponentCandidate(exp, columnIndex, filter);
}
Aggregations