morningman commented on a change in pull request #1764: Move compare from 
RowCursor to row
URL: https://github.com/apache/incubator-doris/pull/1764#discussion_r322013985
 
 

 ##########
 File path: be/src/olap/row.h
 ##########
 @@ -67,6 +67,41 @@ int compare_row(const LhsRowType& lhs, const RhsRowType& 
rhs) {
     return 0;
 }
 
+// Used to compare row with input scan key. Scan key only contains key columns,
+// row contains all key columns, which is superset of key columns.
+// So we should compare the common prefix columns of lhs and rhs.
+//
+// NOTE: if you are not sure if you can use it, please don't use this function.
+template<typename LhsRowType, typename RhsRowType>
+int compare_row_key(const LhsRowType& lhs, const RhsRowType& rhs) {
+    auto cmp_cids = std::min(lhs.schema()->num_column_ids(), 
rhs.schema()->num_column_ids());
+    for (uint32_t cid = 0; cid < cmp_cids; ++cid) {
+        auto res = lhs.schema()->column(cid)->compare_cell(lhs.cell(cid), 
rhs.cell(cid));
+        if (res != 0) {
+            return res;
+        }
+    }
+    return 0;
+}
+
+// This function is only used to do index compaare, currently it is only used 
in
 
 Review comment:
   ```suggestion
   // This function is only used to do index compare, currently it is only used 
in
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@doris.apache.org
For additional commands, e-mail: dev-h...@doris.apache.org

Reply via email to