yiguolei commented on code in PR #57702:
URL: https://github.com/apache/doris/pull/57702#discussion_r2544267001


##########
be/src/olap/rowset/segment_v2/segment.cpp:
##########
@@ -681,15 +692,39 @@ Status 
Segment::_create_column_meta_once(OlapReaderStatistics* stats) {
 }
 
 Status Segment::_create_column_meta(const SegmentFooterPB& footer) {
-    // unique_id -> idx in footer.columns()
-    uint32_t ordinal = 0;
-    for (const auto& column_meta : footer.columns()) {
-        // no need to create column reader for variant's subcolumn
-        if (column_meta.unique_id() == -1) {
-            ordinal++;
-            continue;
+    // Build uid -> col_id mapping used to locate per-column meta.
+    // Priority:
+    // 1) uid2colid blob in footer.file_meta_datas (external meta mode, raw 
uid array)
+    // 2) fallback: scan footer.columns() (old or mixed format)
+    // 3) both missing -> treat as no columns resolvable in this segment 
(return NOT_FOUND on lookup)
+    _column_uid_to_footer_ordinal.clear();
+    // Decide path by footer version: V3 and above uses externalized 
ColumnMeta region
+    const bool use_external_meta = footer.version() >= 
kSegmentFooterVersionV3_ExtColMeta;
+    // 1) Prefer uid->col_id blob (external meta mode). If corrupted or 
missing, fall back.
+    ExternalColMetaUtil::ExternalMetaPointers ptrs;
+    bool loaded = false;
+    if (use_external_meta) {
+        loaded = ExternalColMetaUtil::parse_external_meta_pointers(footer, 
&ptrs) &&
+                 ExternalColMetaUtil::parse_uid_to_colid_map(footer, ptrs,
+                                                             
&_column_uid_to_footer_ordinal);
+    }
+    // 2) Fallback: inline footer columns (old or mixed format)
+    if (!loaded && footer.columns_size() > 0) {
+        uint32_t ordinal = 0;
+        for (const auto& column_meta : footer.columns()) {
+            if (column_meta.unique_id() == -1) {
+                ordinal++;
+                continue;
+            }
+            _column_uid_to_footer_ordinal.try_emplace(column_meta.unique_id(), 
ordinal++);
         }
-        _column_uid_to_footer_ordinal.try_emplace(column_meta.unique_id(), 
ordinal++);
+        loaded = true;
+    }
+    // 3) If still not loaded, warn once to aid troubleshooting (damaged 
mapping and empty inline columns).
+    if (!loaded) {
+        LOG(WARNING) << "segment external meta mapping missing or corrupted 
and no inline columns; "
+                        "uid->col_id cannot be resolved. path="

Review Comment:
   此时,为什么不直接报错?



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