bitflicker64 commented on code in PR #3404:
URL: https://github.com/apache/hugegraph/pull/3404#discussion_r4368819451


##########
hugegraph-store/hg-store-rocksdb/src/main/java/org/apache/hugegraph/rocksdb/access/RocksDBSession.java:
##########
@@ -1080,6 +1080,16 @@ public boolean equals(Object obj) {
             return Bytes.equals(this.name, other.name) &&
                    Bytes.equals(this.value, other.value);
         }
+
+        /**
+         * Hashes the same name and value bytes that equals() compares. A scan 
allocates a new
+         * column per row, so the hash-based union, intersection and 
limit-dedup iterators rely on
+         * byte-equal columns landing on one key.
+         */
+        @Override
+        public int hashCode() {
+            return 31 * Arrays.hashCode(this.name) + 
Arrays.hashCode(this.value);

Review Comment:
   Important: `MapLimitIterator` stores each emitted column in its set and 
passes the same object downstream, so the content hash holds only while nothing 
changes the column afterwards. On an id-only PRIMARY_SCAN (`null_property = 
true`, no property list, condition, order-by or aggregation) with `dedup_option 
= LIMIT_DEDUP`, `ProjectionStage.handle` sets `column.value = new byte[0]` in 
place (`ProjectionStage.java` line 64) before the next `hasNext()`. The stored 
key then no longer equals a later byte-equal row, so the copy is emitted again. 
A probe with the real `MapLimitIterator` over the test's `scanTwice()` rows 
gives 100 rows unchanged and 200 with that reset. Only a gRPC client that sets 
`dedup_option` reaches this today, as the PR notes. Please have 
`ProjectionStage` replace the column 
(`result.setColumn(RocksDBSession.BackendColumn.of(column.name, new byte[0]))`, 
which needs an import) or have `MapLimitIterator` keep a copy, and add a test 
that changes each emitted row before
  reading the next.



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

Reply via email to