david-mollitor-db opened a new pull request, #58349:
URL: https://github.com/apache/spark/pull/58349

   ### What changes were proposed in this pull request?
   
   `ParquetFilters.makeInPredicate` builds a `java.util.HashSet` for each `IN`
   predicate pushed down to Parquet, then adds exactly `values.length` elements 
to
   it. The sets are created without an initial capacity, so they start at the
   default capacity (16) and rehash as they grow.
   
   This PR pre-sizes each of those 12 sets from the known element count using
   Guava's `Sets.newHashSetWithExpectedSize(values.length)`, so they hold all 
`IN`
   values without rehashing or reallocating the internal bucket array.
   
   The Guava helper is used rather than `new HashSet(values.length)` because
   `java.util.HashSet`'s int constructor treats the argument as bucket capacity,
   not expected size, so the naive form would still rehash once the set passes
   ~75% load. This mirrors the existing `Maps.newHashMapWithExpectedSize` usage 
in
   `sql/catalyst`.
   
   ### Why are the changes needed?
   
   `makeInPredicate` is only reached when the `IN` list size exceeds
   `spark.sql.parquet.pushdown.inFilterThreshold` (default 10); smaller lists 
take
   a per-element equality OR-chain and never build a `HashSet`. So by 
construction
   the set always holds more than the threshold's worth of values, and for 
larger
   `IN` lists (dozens to thousands) the default-capacity set rehashes several 
times
   per pushed-down predicate, allocating and discarding bucket arrays, once per
   Parquet file split scanned. Pre-sizing removes that avoidable work. The 
change
   is capacity-only and behavior-preserving.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No.
   
   ### How was this patch tested?
   
   Existing `ParquetV1FilterSuite`, which covers `IN`/`InSet` predicate 
pushdown,
   passes. The change is capacity-only, so predicate semantics are unchanged.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Opus 4.8
   


-- 
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]

Reply via email to