aokolnychyi commented on code in PR #8157:
URL: https://github.com/apache/iceberg/pull/8157#discussion_r1275730978


##########
core/src/main/java/org/apache/iceberg/DeleteFileIndex.java:
##########
@@ -123,33 +130,35 @@ DeleteFile[] forEntry(ManifestEntry<DataFile> entry) {
   }
 
   DeleteFile[] forDataFile(long sequenceNumber, DataFile file) {
+    if (isEmpty) {
+      return NO_DELETES;
+    }
+
     Pair<Integer, StructLikeWrapper> partition = partition(file.specId(), 
file.partition());
-    Pair<long[], DeleteFile[]> partitionDeletes = 
sortedDeletesByPartition.get(partition);
+    DeleteFileGroup partitionDeletes = deletesByPartition.get(partition);
+
+    if (globalDeletes == null && partitionDeletes == null) {
+      return NO_DELETES;
+    }
 
-    Stream<DeleteFile> matchingDeletes;
+    Stream<IndexedDeleteFile> matchingDeletes;
     if (partitionDeletes == null) {
-      matchingDeletes = limitBySequenceNumber(sequenceNumber, globalSeqs, 
globalDeletes);
+      matchingDeletes = globalDeletes.limit(sequenceNumber);
     } else if (globalDeletes == null) {
-      matchingDeletes =
-          limitBySequenceNumber(
-              sequenceNumber, partitionDeletes.first(), 
partitionDeletes.second());
+      matchingDeletes = partitionDeletes.limit(sequenceNumber);
     } else {
-      matchingDeletes =
-          Stream.concat(
-              limitBySequenceNumber(sequenceNumber, globalSeqs, globalDeletes),
-              limitBySequenceNumber(
-                  sequenceNumber, partitionDeletes.first(), 
partitionDeletes.second()));
+      Stream<IndexedDeleteFile> matchingGlobalDeletes = 
globalDeletes.limit(sequenceNumber);
+      Stream<IndexedDeleteFile> matchingPartitionDeletes = 
partitionDeletes.limit(sequenceNumber);
+      matchingDeletes = Stream.concat(matchingGlobalDeletes, 
matchingPartitionDeletes);
     }
 
     return matchingDeletes
-        .filter(
-            deleteFile ->
-                canContainDeletesForFile(file, deleteFile, 
specsById.get(file.specId()).schema()))
+        .filter(deleteFile -> canApply(file, deleteFile, 
specsById.get(file.specId()).schema()))
+        .map(IndexedDeleteFile::wrapped)
         .toArray(DeleteFile[]::new);
   }
 
-  private static boolean canContainDeletesForFile(
-      DataFile dataFile, DeleteFile deleteFile, Schema schema) {
+  private static boolean canApply(DataFile dataFile, IndexedDeleteFile 
deleteFile, Schema schema) {

Review Comment:
   I reverted the name.



##########
core/src/main/java/org/apache/iceberg/DeleteFileIndex.java:
##########
@@ -259,19 +258,16 @@ && allNonNull(dataNullCounts, field)) {
   }
 
   private static <T> boolean rangesOverlap(
-      Type.PrimitiveType type,
+      Types.NestedField field,
       ByteBuffer dataLowerBuf,
       ByteBuffer dataUpperBuf,
-      ByteBuffer deleteLowerBuf,
-      ByteBuffer deleteUpperBuf) {
-    Comparator<T> comparator = Comparators.forType(type);
+      T deleteLower,
+      T deleteUpper) {
+    Type.PrimitiveType type = field.type().asPrimitiveType();
+    Comparator<T> cmp = Comparators.forType(type);

Review Comment:
   Renamed to `cmp` to stay on one line.



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