You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by bl...@apache.org on 2021/01/01 23:33:06 UTC

[iceberg] branch master updated: Core: Add equals and hashcode to BaseSnapshot (#2011)

This is an automated email from the ASF dual-hosted git repository.

blue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iceberg.git


The following commit(s) were added to refs/heads/master by this push:
     new 4b1b90d  Core: Add equals and hashcode to BaseSnapshot (#2011)
4b1b90d is described below

commit 4b1b90d7333ea3c9c16a311cd89dfe8d7ac34431
Author: Fokko Driesprong <fo...@apache.org>
AuthorDate: Sat Jan 2 00:32:55 2021 +0100

    Core: Add equals and hashcode to BaseSnapshot (#2011)
---
 .../main/java/org/apache/iceberg/BaseSnapshot.java | 27 ++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/core/src/main/java/org/apache/iceberg/BaseSnapshot.java b/core/src/main/java/org/apache/iceberg/BaseSnapshot.java
index f687730..407b350 100644
--- a/core/src/main/java/org/apache/iceberg/BaseSnapshot.java
+++ b/core/src/main/java/org/apache/iceberg/BaseSnapshot.java
@@ -212,6 +212,33 @@ class BaseSnapshot implements Snapshot {
   }
 
   @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() {
+    return Objects.hashCode(
+      this.snapshotId,
+      this.parentId,
+      this.sequenceNumber,
+      this.timestampMillis
+    );
+  }
+
+  @Override
   public String toString() {
     return MoreObjects.toStringHelper(this)
         .add("id", snapshotId)