You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "findepi (via GitHub)" <gi...@apache.org> on 2025/12/04 08:24:53 UTC

Re: [PR] API: Reduce 'Scanning table' log verbosity for long list of strings [iceberg]

findepi commented on code in PR #14757:
URL: https://github.com/apache/iceberg/pull/14757#discussion_r2588030043


##########
api/src/main/java/org/apache/iceberg/expressions/ExpressionUtil.java:
##########
@@ -502,19 +500,21 @@ public <T> String predicate(UnboundPredicate<T> pred) {
 
   private static List<String> abbreviateValues(List<String> sanitizedValues) {
     if (sanitizedValues.size() >= LONG_IN_PREDICATE_ABBREVIATION_THRESHOLD) {
-      Set<String> distinctValues = ImmutableSet.copyOf(sanitizedValues);
-      if (distinctValues.size()
-          <= sanitizedValues.size() - LONG_IN_PREDICATE_ABBREVIATION_MIN_GAIN) {
-        List<String> abbreviatedList = Lists.newArrayListWithCapacity(distinctValues.size() + 1);
-        abbreviatedList.addAll(distinctValues);
+      List<String> distinctValues = ImmutableSet.copyOf(sanitizedValues).asList();
+      List<String> abbreviatedList =
+          Lists.newArrayListWithCapacity(LONG_IN_PREDICATE_ABBREVIATION_THRESHOLD + 1);
+      int abbreviatedListSize =
+          Math.min(distinctValues.size(), LONG_IN_PREDICATE_ABBREVIATION_THRESHOLD);

Review Comment:
   - abbreviatedListSize is not the size of the abbreviatedList list, so rename to abbreviationSize
   - initialize the size first, so that the abbreviatedList can be sized as the int + 1
     - for example, if there are only 2 distinct values (hashes), the list should be inited with size 3, not 11



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org