You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "hililiwei (via GitHub)" <gi...@apache.org> on 2023/05/09 03:31:29 UTC

[GitHub] [iceberg] hililiwei commented on a diff in pull request #7493: Flink: add toString, equals, hashCode overrides for RowDataProjection.

hililiwei commented on code in PR #7493:
URL: https://github.com/apache/iceberg/pull/7493#discussion_r1188078049


##########
flink/v1.17/flink/src/main/java/org/apache/iceberg/flink/data/RowDataProjection.java:
##########
@@ -254,4 +258,78 @@ public MapData getMap(int pos) {
   public RowData getRow(int pos, int numFields) {
     return (RowData) getValue(pos);
   }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) {
+      return true;
+    }
+
+    if (!(o instanceof RowDataProjection)) {
+      return false;
+    }
+
+    RowDataProjection that = (RowDataProjection) o;
+    return deepEquals(that);
+  }
+
+  @Override
+  public int hashCode() {
+    int result = Objects.hashCode(getRowKind());
+    for (int pos = 0; pos < getArity(); pos++) {
+      if (!isNullAt(pos)) {
+        // Arrays.deepHashCode handles array object properly
+        result = 31 * result + Arrays.deepHashCode(new Object[] {getValue(pos)});

Review Comment:
   Not so sure, but I prefer the first one.



-- 
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: issues-unsubscribe@iceberg.apache.org

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