rdblue commented on a change in pull request #3530:
URL: https://github.com/apache/iceberg/pull/3530#discussion_r749630893



##########
File path: core/src/main/java/org/apache/iceberg/deletes/Deletes.java
##########
@@ -261,7 +258,11 @@ public void close() {
 
     @Override
     protected boolean shouldKeep(T posDelete) {
-      return CHARSEQ_COMPARATOR.compare(dataLocation, (CharSequence) 
FILENAME_ACCESSOR.get(posDelete)) == 0;
+      return charSeqEquals(dataLocation, (CharSequence) 
FILENAME_ACCESSOR.get(posDelete));
+    }
+
+    private boolean charSeqEquals(CharSequence s1, CharSequence s2) {
+      return s1 == s2 || (s1.length() == s2.length() && 
s1.toString().contentEquals(s2));

Review comment:
       I think you're right and string comparison checks the hashcode first. 
You can add a simple test for that case as well:
   
   ```java
   if (s1 instanceof String && s2 instanceof String && s1.hashCode() != 
s2.hashCode()) {
     return false;
   }
   ```
   
   You could also test whether s1 is a string and still call `contentEquals`. 
But we should definitely not convert s1 to a string if it is not already.




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