RexNode idxRemColCondition = IndexPlanUtils.getLeadingPrefixMap(leadingPrefixMap, idx.getIndexColumns(), infoBuilder, idxCondition); RexNode idxLeadColCondition = IndexPlanUtils.getLeadingColumnsFilter( IndexPlanUtils.getLeadingFilters(leadingPrefixMap, idx.getIndexColumns()), builder);
/** * This method analyzes an index's columns and starting from the first column, checks * which part of the filter condition matches that column. This process continues with * subsequent columns. The goal is to identify the portion of the filter condition that * match the prefix columns. If there are additional conditions that don't match prefix * columns, that condition is set as a remainder condition. * @param indexProps */ public void analyzePrefixMatches(IndexProperties indexProps) { RexNode initCondition = indexCondition.isAlwaysTrue() ? null : indexCondition; Map<LogicalExpression, RexNode> leadingPrefixMap = Maps.newHashMap(); List<LogicalExpression> indexCols = indexProps.getIndexDesc().getIndexColumns(); boolean satisfiesCollation = false; if (indexCols.size() > 0) { if (initCondition != null) { // check filter condition initCondition = IndexPlanUtils.getLeadingPrefixMap(leadingPrefixMap, indexCols, builder, indexCondition); } if (requiredCollation()) { satisfiesCollation = buildAndCheckCollation(indexProps); } } indexProps.setProperties(leadingPrefixMap, satisfiesCollation, initCondition /* the remainder condition for indexed columns */, stats); }
RexNode idxRemColCondition = IndexPlanUtils.getLeadingPrefixMap(leadingPrefixMap, idx.getIndexColumns(), infoBuilder, idxCondition); RexNode idxLeadColCondition = IndexPlanUtils.getLeadingColumnsFilter( IndexPlanUtils.getLeadingFilters(leadingPrefixMap, idx.getIndexColumns()), builder);