rdblue commented on code in PR #6527:
URL: https://github.com/apache/iceberg/pull/6527#discussion_r1199818762
##########
core/src/main/java/org/apache/iceberg/deletes/Deletes.java:
##########
@@ -142,6 +147,52 @@ public static PositionDeleteIndex
toPositionIndex(CloseableIterable<Long> posDel
}
}
+ public static <T extends StructLike> Map<String, PositionDeleteIndex>
toPositionIndexMap(
+ CharSequenceSet dataLocations, List<CloseableIterable<T>> deleteFiles) {
+ DataFileFilter<T> locationFilter = new DataFileFilter<>(dataLocations);
+ List<CloseableIterable<Pair<String, Long>>> positions =
+ Lists.transform(
+ deleteFiles,
+ deletes ->
+ CloseableIterable.transform(
+ locationFilter.filter(deletes),
+ row ->
+ Pair.of(
+ (String) FILENAME_ACCESSOR.get(row),
+ (Long) POSITION_ACCESSOR.get(row))));
+
+ try (CloseableIterable<Pair<String, Long>> deletes =
CloseableIterable.concat(positions)) {
+ Map<String, PositionDeleteIndex> positionDeleteIndex = Maps.newHashMap();
+ deletes.forEach(
+ entry ->
+ positionDeleteIndex
+ .computeIfAbsent(entry.first(), f -> new
BitmapPositionDeleteIndex())
Review Comment:
Instead of using `computeIfAbsent` on every row, this should pre-populate
the map using `dataLocations`, since those are all known.
--
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]