stevenzwu opened a new pull request, #17322:
URL: https://github.com/apache/iceberg/pull/17322

   ## What
   
   Add `ContentStatsBackedMap`, a lazy read-only `Map<Integer, V>` view over a 
`ContentStats` that projects a single metric (value/null/NaN counts, or 
lower/upper bounds) from a column's `FieldStats` on demand. 
`TrackedFileAdapters` now presents the five legacy `ContentFile` stat maps 
through `ContentStatsBackedMap.forKind(...)`, replacing the eager `MetricsUtil` 
converters that materialized a fresh map per metric for every manifest entry.
   
   - `forKind` restores the eager converters' null-when-empty contract — it 
returns `null` when no column tracks the metric — via an allocation-free, 
short-circuiting scan. Point reads (`get`/`containsKey`) allocate no map, boxed 
value, or bound buffer; the entry set is materialized (and cached) only when 
the whole map is iterated.
   - `FieldStats` gains `hasNullCount()` / `hasNaNCount()` so the presence of a 
primitive-`long` count is explicit. `FieldStatsStruct` takes the two counts as 
boxed `Long`, so `null` uniformly signals an untracked count across every 
construction path, and the count getters `checkState` rather than unbox a null.
   - Removes the now-unused 
`MetricsUtil.valueCounts/nullValueCounts/nanValueCounts/lowerBounds/upperBounds(ContentStats)`
 converters.
   
   ## Why
   
   The eager converters allocated a `LinkedHashMap` (plus boxed counts and 
decoded bound buffers) per metric for every manifest entry read. The lazy view 
avoids that on the hot point-read path and preserves the legacy 
`null`-when-empty semantics that scan planning relies on.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


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