mrhhsg commented on code in PR #68125:
URL: https://github.com/apache/doris/pull/68125#discussion_r4227362970


##########
be/src/storage/read_time_hidden_column.cpp:
##########
@@ -0,0 +1,91 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "storage/read_time_hidden_column.h"
+
+#include "common/logging.h"
+#include "core/column/column.h"
+#include "storage/tablet/tablet_schema.h"
+#include "storage/utils.h"
+
+namespace doris {
+
+ReadTimeHiddenColumnType get_read_time_hidden_column_type(const TabletColumn& 
column) {
+    const auto& column_name = column.name();
+    if (column_name == VERSION_COL) {
+        return ReadTimeHiddenColumnType::VERSION;
+    }
+    if (column_name == COMMIT_TSO_COL) {
+        return ReadTimeHiddenColumnType::COMMIT_TSO;
+    }
+    if (column_name == BINLOG_TSO_COL) {
+        return ReadTimeHiddenColumnType::BINLOG_TSO;
+    }
+    return ReadTimeHiddenColumnType::NONE;
+}
+
+ReadTimeHiddenColumnType get_read_time_hidden_column_type(const TabletSchema& 
schema,
+                                                          int32_t 
column_unique_id) {
+    const int32_t column_idx = schema.field_index(column_unique_id);
+    if (column_idx < 0) {
+        return ReadTimeHiddenColumnType::NONE;
+    }
+    return get_read_time_hidden_column_type(schema.column(column_idx));
+}
+
+std::optional<Field> 
get_read_time_hidden_column_value(ReadTimeHiddenColumnType column_type,
+                                                       const Version& version,
+                                                       const TsoRange& 
commit_tso,
+                                                       bool read_row_binlog) {
+    if (version.first != version.second) {

Review Comment:
   Fixed in ee478f4c01c for the reachable VERSION case.
   
   `is_rowset_tidy` (be/src/storage/compaction/compaction.cpp) now refuses a 
single-version rowset when the tablet schema has the hidden VERSION column, so 
on a merge-on-read UNIQUE table the tidy loads take the rewriting compaction, 
which materializes the per-row version via `_replace_version_col_if_needed`; 
rowsets already rewritten into a multi-version rowset still take the link path. 
This keeps the read-side contract of `get_read_time_hidden_column_value` 
(substitute only for single-version rowsets) and the physical values 
consistent, with no storage-format change. DUP/AGG tables have no VERSION 
column and are unaffected; row-binlog tablets only link previously rewritten 
level-2 input, so COMMIT_TSO is not involved.
   
   Coverage:
   - `OrderedDataCompactionTest.test_version_col_singleton_rowset_not_linked`: 
two tidy single-version rowsets with the VERSION column -> 
`handle_ordered_data_compaction()` is false; the same rowsets as 
`[2-3]`/`[4-5]` -> true with a linked `[2-5]` output.
   - `fault_injection_p0/test_ordered_compaction_hidden_version_column`: MOR 
UNIQUE table, four tidy loads; cumulative compaction of `[2-2],[3-3]` and 
`[4-4],[5-5]` rewrites them (`num_segment_rows == [8]` / `[5]`), then base 
compaction links `[0-1],[2-3],[4-5] -> [0-5]` (`num_segment_rows == [8, 5]`, BE 
log `succeed to do ordered data base compaction`) and `__DORIS_VERSION_COL__` 
stays exactly 2/3/4/5 per row after every step (locked in the `.out`). Before 
the fix the first step already linked the loads (`num_segment_rows == [3, 5]`) 
and the linked rows read 0.
   



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