morrySnow commented on code in PR #34501: URL: https://github.com/apache/doris/pull/34501#discussion_r1599310861
########## fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/ArrayMatchAnyExpander.java: ########## @@ -61,28 +61,32 @@ public Rule build() { } Plan replace(LogicalFilter<LogicalOlapScan> filter) { - Set<Expression> sets = filter.getConjuncts().stream().map(expr -> { - if (expr instanceof ArrayMatchAny) { - return rewrite((ArrayMatchAny) expr); + Set<Expression> newConjuncts = new HashSet<>(); + boolean isRewritten = false; + for (Expression expr : filter.getConjuncts()) { + if (expr instanceof ArrayMatchAny && expr.children().size() <= 2) { + // if arrayMatchAny.children().size() > 2 means already be rewritten, and should not rewrite again + isRewritten = true; + newConjuncts.add(rewrite((ArrayMatchAny) expr)); } else { - return expr; + newConjuncts.add(expr); } - }).collect(ImmutableSet.toImmutableSet()); - return filter.withConjuncts(sets); + } + if (!isRewritten) { + return null; + } + return filter.withConjuncts(newConjuncts); } private static Expression rewrite(ArrayMatchAny arrayMatchAny) { - if (arrayMatchAny.children().size() > 2) { - return arrayMatchAny; - } // default inverted index ctx String invertedIndexParser = InvertedIndexUtil.INVERTED_INDEX_PARSER_ENGLISH; String invertedIndexParserMode = InvertedIndexUtil.INVERTED_INDEX_PARSER_COARSE_GRANULARITY; List<Literal> keys = Lists.newArrayList(InvertedIndexUtil.INVERTED_INDEX_PARSER_KEY, InvertedIndexUtil.INVERTED_INDEX_PARSER_MODE_KEY).stream() .map(StringLiteral::new).collect(Collectors.toList()); - List<Literal> values = Lists.newArrayList(invertedIndexParser, invertedIndexParserMode).stream() - .map(StringLiteral::new).collect(Collectors.toList()); + List<Literal> values = Lists.newArrayList(new StringLiteral(invertedIndexParser), + new StringLiteral(invertedIndexParserMode)); Review Comment: use `ImmutableList` to avoid deep copy in ctor -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org