simhadri-g commented on code in PR #4431:
URL: https://github.com/apache/hive/pull/4431#discussion_r1267241531
##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergStorageHandler.java:
##########
@@ -457,17 +462,20 @@ public List<ColumnStatisticsObj>
getColStatistics(org.apache.hadoop.hive.ql.meta
Table table = IcebergTableUtil.getTable(conf, hmsTable.getTTable());
String statsPath = getStatsPath(table).toString();
LOG.info("Using stats from puffin file at: {}", statsPath);
+ return readColStats(table, statsPath).equals(null) ? null :
readColStats(table, statsPath).getStatsObj();
+ }
+
+ private ColumnStatistics readColStats(Table table, String statsPath) {
try (PuffinReader reader =
Puffin.read(table.io().newInputFile(statsPath)).build()) {
List<BlobMetadata> blobMetadata = reader.fileMetadata().blobs();
- Map<BlobMetadata, List<ColumnStatistics>> collect =
-
Streams.stream(reader.readAll(blobMetadata)).collect(Collectors.toMap(Pair::first,
- blobMetadataByteBufferPair -> SerializationUtils.deserialize(
-
ByteBuffers.toByteArray(blobMetadataByteBufferPair.second()))));
- return collect.get(blobMetadata.get(0)).get(0).getStatsObj();
+ Map<BlobMetadata, List<ColumnStatistics>> collect =
Streams.stream(reader.readAll(blobMetadata)).collect(
+ Collectors.toMap(Pair::first, blobMetadataByteBufferPair ->
SerializationUtils.deserialize(
+ ByteBuffers.toByteArray(blobMetadataByteBufferPair.second()))));
+ return collect.get(blobMetadata.get(0)).get(0);
Review Comment:
We first get the blob metadata:
This is a List that will contain all the blobs. Currently we are writing all
stats to only one blob. Therefore we get the blobmetadata at index 0;
Next using this blobmetadata info as key , we get the the array list.
Currently its just one element in this list.

Map<BlobMetadata, List<ColumnStatistics>>
--
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]