zhannngchen commented on code in PR #9858:
URL: https://github.com/apache/doris/pull/9858#discussion_r922951190


##########
be/src/olap/tuple_reader.cpp:
##########
@@ -186,15 +186,24 @@ Status TupleReader::_unique_key_next_row(RowCursor* 
row_cursor, MemPool* mem_poo
         // in UNIQUE_KEY highest version is the final result, there is no need 
to
         // merge the lower versions
         direct_copy_row(row_cursor, *_next_key);
-        // skip the lower version rows;
-        auto res = _collect_iter.next(&_next_key, &_next_delete_flag);
-        if (LIKELY(res.precise_code() != OLAP_ERR_DATA_EOF)) {
-            if (UNLIKELY(!res.ok())) {
-                LOG(WARNING) << "next failed: " << res;
-                return res;
+        while (_next_key) {
+            // skip the lower version rows;
+            auto res = _collect_iter.next(&_next_key, &_next_delete_flag);
+            if (LIKELY(res.precise_code() != OLAP_ERR_DATA_EOF)) {
+                if (UNLIKELY(!res.ok())) {
+                    LOG(WARNING) << "next failed: " << res;
+                    return res;
+                }
+
+                if (!equal_row(_key_cids, *row_cursor, *_next_key)) {

Review Comment:
   @HappenLee Why do we need to merge keys here?
   1. If there are duplicate keys in one rowset, the MergeIterator will merge 
them.
   2. If there are duplicate keys between rowsets, the CollectIterator will 
merge 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: [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