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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]