difin commented on code in PR #5393: URL: https://github.com/apache/hive/pull/5393#discussion_r1736927467
########## iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/IcebergTableUtil.java: ########## @@ -511,6 +511,24 @@ public static Map<PartitionData, Integer> getPartitionInfo(Table icebergTable, M return result; } + public static long getPartitionHash(Table icebergTable, String partitionPath) throws SemanticException, IOException { + PartitionsTable partitionsTable = (PartitionsTable) MetadataTableUtils + .createMetadataTableInstance(icebergTable, MetadataTableType.PARTITIONS); + Map<String, Long> partitionsMap = Maps.newLinkedHashMap(); + try (CloseableIterable<FileScanTask> fileScanTasks = partitionsTable.newScan().planFiles()) { + fileScanTasks.forEach(task -> + CloseableIterable.transform(task.asDataTask().rows(), row -> { + StructProjection data = row.get(IcebergTableUtil.PART_IDX, StructProjection.class); + Integer specId = row.get(IcebergTableUtil.SPEC_IDX, Integer.class); + PartitionData partitionData = IcebergTableUtil.toPartitionData(data, + Partitioning.partitionType(icebergTable), icebergTable.specs().get(specId).partitionType()); + String path = icebergTable.specs().get(specId).partitionToPath(partitionData); + return Maps.immutableEntry(path, IcebergAcidUtil.computeHash(data)); + }).forEach(entry -> partitionsMap.put(entry.getKey(), entry.getValue()))); + } + return partitionsMap.get(partitionPath); Review Comment: Refactored to get rid of the Map. -- 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: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org