deniskuzZ commented on code in PR #6527:
URL: https://github.com/apache/iceberg/pull/6527#discussion_r1200574398


##########
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:
   i don't see any issues here as nothing extra is done when key exists:
   ````
   default V computeIfAbsent(K key,
               Function<? super K, ? extends V> mappingFunction) {
           Objects.requireNonNull(mappingFunction);
           V v;
           if ((v = get(key)) == null) {
               V newValue;
               if ((newValue = mappingFunction.apply(key)) != null) {
                   put(key, newValue);
                   return newValue;
               }
           }
   
           return v;
       }
   ```` 



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