sandynz commented on a change in pull request #14676:
URL: https://github.com/apache/shardingsphere/pull/14676#discussion_r781174422



##########
File path: 
shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/spi/check/consistency/DataMatchSingleTableDataCalculator.java
##########
@@ -124,5 +125,39 @@ public void init() {
         private final int recordCount;
         
         private final Collection<Collection<Object>> records;

Review comment:
       Could we extract `Collection<Object>` into another class that includes 
special `equals` and `hashCode` impl to simplify `CalculatedResult`, and also 
add unit test for this new class.

##########
File path: 
shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/spi/check/consistency/DataMatchSingleTableDataCalculator.java
##########
@@ -124,5 +125,39 @@ public void init() {
         private final int recordCount;
         
         private final Collection<Collection<Object>> records;
+    
+        @Override
+        public boolean equals(final Object o) {
+            if (this == o) {
+                return true;
+            }
+            if (!(o instanceof CalculatedResult)) {
+                return false;
+            }
+        
+            final CalculatedResult that = (CalculatedResult) o;
+    
+            boolean equalsFirst = new EqualsBuilder().append(getRecordCount(), 
that.getRecordCount()).append(getMaxUniqueKeyValue(), 
that.getMaxUniqueKeyValue()).isEquals();
+            if (!equalsFirst) {
+                return false;
+            }
+            Iterator<Collection<Object>> thisIterator = 
this.records.iterator();
+            Iterator<Collection<Object>> thatIterator = 
that.records.iterator();
+            while (thisIterator.hasNext() && thatIterator.hasNext()) {
+                Iterator<Object> thisNextIterator = 
thisIterator.next().iterator();
+                Iterator<Object> thatNextIterator = 
thatIterator.next().iterator();
+                while (thisNextIterator.hasNext() && 
thatNextIterator.hasNext()) {

Review comment:
       It's better to verify `Collection<Object>`'s size, in case of they're 
different.




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


Reply via email to