aiborodin commented on code in PR #14092:
URL: https://github.com/apache/iceberg/pull/14092#discussion_r2357949215
##########
core/src/main/java/org/apache/iceberg/io/WriteResult.java:
##########
@@ -134,4 +137,35 @@ public WriteResult build() {
return new WriteResult(dataFiles, deleteFiles, referencedDataFiles,
rewrittenDeleteFiles);
}
}
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("dataFiles", dataFiles)
+ .add("deleteFiles", deleteFiles)
+ .add("referencedDataFiles", referencedDataFiles)
+ .add("rewrittenDeleteFiles", rewrittenDeleteFiles)
+ .toString();
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other == null || getClass() != other.getClass()) {
+ return false;
+ }
+ WriteResult that = (WriteResult) other;
+ return Objects.deepEquals(dataFiles, that.dataFiles)
+ && Objects.deepEquals(deleteFiles, that.deleteFiles)
+ && Objects.deepEquals(referencedDataFiles, that.referencedDataFiles)
+ && Objects.deepEquals(rewrittenDeleteFiles, that.rewrittenDeleteFiles);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(
+ Arrays.hashCode(dataFiles),
+ Arrays.hashCode(deleteFiles),
+ Arrays.hashCode(referencedDataFiles),
+ Arrays.hashCode(rewrittenDeleteFiles));
+ }
Review Comment:
> I'm asking because this is in core and potentially affects other engines.
You're right, it's not strictly necessary for the implementation. However,
there have been a few instances in this codebase of decomposing and manually
checking subsets of `WriteResult` or `DataFile`/`DeleteFile` due to a lack of
these methods, so they simplify `DynamicWriteResultAggregator` tests, as well
as `DynamicWriteResult` and `WriteResult` serialisation tests.
I don't see any harm in adding them. Why would other engines rely on no
implementations of equals / hashCode? In this codebase, apart from Flink, it's
only used in Spark in `SparkPositionDeltaWrite` as a simple data class.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]