szehon-ho commented on code in PR #11555:
URL: https://github.com/apache/iceberg/pull/11555#discussion_r1902646277


##########
core/src/main/java/org/apache/iceberg/util/ContentFileUtil.java:
##########
@@ -60,28 +69,63 @@ public static CharSequence referencedDataFile(DeleteFile 
deleteFile) {
       return deleteFile.referencedDataFile();
     }
 
-    int pathId = MetadataColumns.DELETE_FILE_PATH.fieldId();
-    Type pathType = MetadataColumns.DELETE_FILE_PATH.type();
-
     Map<Integer, ByteBuffer> lowerBounds = deleteFile.lowerBounds();
-    ByteBuffer lowerPathBound = lowerBounds != null ? lowerBounds.get(pathId) 
: null;
+    ByteBuffer lowerPathBound = lowerBounds != null ? lowerBounds.get(PATH_ID) 
: null;
     if (lowerPathBound == null) {
       return null;
     }
 
     Map<Integer, ByteBuffer> upperBounds = deleteFile.upperBounds();
-    ByteBuffer upperPathBound = upperBounds != null ? upperBounds.get(pathId) 
: null;
+    ByteBuffer upperPathBound = upperBounds != null ? upperBounds.get(PATH_ID) 
: null;
     if (upperPathBound == null) {
       return null;
     }
 
     if (lowerPathBound.equals(upperPathBound)) {
-      return Conversions.fromByteBuffer(pathType, lowerPathBound);
+      return Conversions.fromByteBuffer(PATH_TYPE, lowerPathBound);
     } else {
       return null;
     }
   }
 
+  /**
+   * Replace file_path reference for a delete file entry
+   *
+   * @param deleteFile delete file whose entry will be replaced
+   * @param sourcePrefix source prefix which will be replaced
+   * @param targetPrefix target prefix which will replace it
+   * @return metrics for the new delete file entry
+   */
+  public static Metrics replacePathBounds(
+      DeleteFile deleteFile, String sourcePrefix, String targetPrefix) {
+    Preconditions.checkArgument(
+        deleteFile.content() == FileContent.POSITION_DELETES,
+        "Only position delete files supported");
+
+    Map<Integer, ByteBuffer> lowerBounds = deleteFile.lowerBounds();
+    ByteBuffer lowerPathBound = lowerBounds != null ? lowerBounds.get(PATH_ID) 
: null;
+    if (lowerPathBound == null) {
+      return metricsWithoutPathBounds(deleteFile);
+    }
+
+    Map<Integer, ByteBuffer> upperBounds = deleteFile.upperBounds();
+    ByteBuffer upperPathBound = upperBounds != null ? upperBounds.get(PATH_ID) 
: null;
+    if (upperPathBound == null) {
+      return metricsWithoutPathBounds(deleteFile);
+    }
+
+    if (lowerPathBound.equals(upperPathBound)) {

Review Comment:
   Another context, I think having the same upper/lower bound is related to 
file-scoped delete files that seems will be the default soon, ref:  
https://lists.apache.org/thread/2mpmdp4ns66gp595c9b3clstgskbslsp hence my 
thought its not worth to copy the metrics for the other case (which doesnt even 
attempt filtering).



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to