You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2020/12/31 20:15:19 UTC

[GitHub] [iceberg] rdblue commented on a change in pull request #2011: Add equals and hashcode to BaseSnapshot

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



##########
File path: core/src/main/java/org/apache/iceberg/BaseSnapshot.java
##########
@@ -211,6 +211,32 @@ private void cacheChanges() {
     this.cachedDeletes = deletes.build();
   }
 
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) {
+      return true;
+    }
+    if (o instanceof BaseSnapshot) {
+      BaseSnapshot other = (BaseSnapshot) o;
+      return this.snapshotId == other.snapshotId() &&
+          this.parentId.equals(other.parentId()) &&
+          this.sequenceNumber == other.sequenceNumber() &&
+          this.timestampMillis == other.timestampMillis();
+
+    }
+    return false;
+  }
+
+  @Override
+  public int hashCode() {
+    int hash = 7;
+    hash = 31 * hash + (int) this.snapshotId;
+    hash = 31 * hash + (this.parentId == null ? 0 : this.parentId.hashCode());
+    hash = 31 * hash + (int) sequenceNumber;
+    hash = 31 * hash + (int) timestampMillis;
+    return hash;

Review comment:
       Ca you use `Objects.hash` instead? That's a much more compact implementation that does basically the same thing.




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

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



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