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/30 14:32:48 UTC

[GitHub] [iceberg] Fokko opened a new pull request #2011: Add equals and hashcode to BaseSnapshot

Fokko opened a new pull request #2011:
URL: https://github.com/apache/iceberg/pull/2011


   ```
   ```


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


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

Posted by GitBox <gi...@apache.org>.
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


[GitHub] [iceberg] rdblue merged pull request #2011: Add equals and hashcode to BaseSnapshot

Posted by GitBox <gi...@apache.org>.
rdblue merged pull request #2011:
URL: https://github.com/apache/iceberg/pull/2011


   


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


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

Posted by GitBox <gi...@apache.org>.
rdblue commented on a change in pull request #2011:
URL: https://github.com/apache/iceberg/pull/2011#discussion_r550684950



##########
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() &&

Review comment:
       Shouldn't this also include the the table  that was loaded? Or is it enough that id and parent id are almost certainly unique?




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


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

Posted by GitBox <gi...@apache.org>.
rdblue commented on pull request #2011:
URL: https://github.com/apache/iceberg/pull/2011#issuecomment-753404024


   The Javadoc failure was fixed in #2018 so I'm going to merge this.


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


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

Posted by GitBox <gi...@apache.org>.
Fokko commented on a change in pull request #2011:
URL: https://github.com/apache/iceberg/pull/2011#discussion_r550764983



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

Review comment:
       Thanks for letting me know, I've updated the style.

##########
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:
       Sure!

##########
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() &&

Review comment:
       I had the same thought. For the Beam use-case, this is sufficient. If you want to split out a single stream into multiple tables, then you would do a key-by on the destination table. The comparisons will be made within the table, therefore the sequenceNumber will make this unique. I'm happy to also add the table that was loaded, but this isn't in the class right now.




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


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

Posted by GitBox <gi...@apache.org>.
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:
       Can 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


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

Posted by GitBox <gi...@apache.org>.
rdblue commented on a change in pull request #2011:
URL: https://github.com/apache/iceberg/pull/2011#discussion_r550810287



##########
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() &&

Review comment:
       I think it's okay for now, but it is an open question what makes two snapshots equal. Being careful here and including more fields as you do is pretty reasonable.




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


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

Posted by GitBox <gi...@apache.org>.
rdblue commented on a change in pull request #2011:
URL: https://github.com/apache/iceberg/pull/2011#discussion_r550684832



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

Review comment:
       Style nits: we like to separate control flow blocks with a blank line, and avoid a blank line before the end of a block or method.




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