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

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

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


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

Review Comment:
   do we need to check `o == null`?
   Inside `deepEquals`,  `other.getRowKind()` may fail if `other == null`



##########
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:
   curious, when calculating hashcode, do we need to take Map/List as a special case? Will `Arrays.deepHashCode` be able to handle that?  
   Or it's because `This projection will not project the nested children types of repeated types like lists and
      maps`, so we can ignore them?



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