rdblue commented on code in PR #17322:
URL: https://github.com/apache/iceberg/pull/17322#discussion_r3641573661
##########
core/src/main/java/org/apache/iceberg/TrackedFileAdapters.java:
##########
@@ -174,27 +175,34 @@ public Map<Integer, Long> columnSizes() {
@Override
public Map<Integer, Long> valueCounts() {
- return MetricsUtil.valueCounts(file().contentStats());
+ return statsMap(ContentStatsBackedMap::valueCounts);
}
@Override
public Map<Integer, Long> nullValueCounts() {
- return MetricsUtil.nullValueCounts(file().contentStats());
+ return statsMap(ContentStatsBackedMap::nullValueCounts);
}
@Override
public Map<Integer, Long> nanValueCounts() {
- return MetricsUtil.nanValueCounts(file().contentStats());
+ return statsMap(ContentStatsBackedMap::nanValueCounts);
}
@Override
public Map<Integer, ByteBuffer> lowerBounds() {
- return MetricsUtil.lowerBounds(file().contentStats());
+ return statsMap(ContentStatsBackedMap::lowerBounds);
}
@Override
public Map<Integer, ByteBuffer> upperBounds() {
- return MetricsUtil.upperBounds(file().contentStats());
+ return statsMap(ContentStatsBackedMap::upperBounds);
+ }
+
+ // Presents the wrapped content stats as a legacy per-column stats map
without eagerly
+ // materializing it.
+ private <V> Map<Integer, V> statsMap(Function<ContentStats, Map<Integer,
V>> statsView) {
Review Comment:
I don't understand the value of this function. All it does is check that
`contentStats` is non-null. Rather than a complicated way to save an inline
null check, the stats functions should just return null for null content stats.
You can do that in a single place by updating `isEmpty` to check for a null
content stats.
--
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]