yiguolei commented on code in PR #57702: URL: https://github.com/apache/doris/pull/57702#discussion_r2558478975
########## be/src/olap/rowset/segment_v2/external_col_meta_util.cpp: ########## @@ -0,0 +1,204 @@ +// 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 "olap/rowset/segment_v2/external_col_meta_util.h" + +#include <limits> +#include <memory> +#include <utility> +#include <vector> + +#include "io/io_common.h" +#include "olap/rowset/segment_v2/variant/variant_ext_meta_writer.h" +#include "util/coding.h" +#include "util/faststring.h" + +namespace doris::segment_v2 { + +bool ExternalColMetaUtil::parse_external_meta_pointers( + const SegmentFooterPB& footer, ExternalColMetaUtil::ExternalMetaPointers* out) { + out->region_start = footer.col_meta_region_start(); + out->num_columns = footer.num_columns(); + // Validate pointers and basic consistency to ensure external meta is actually present. + if (out->region_start == 0) { + return false; + } + if (out->num_columns == 0) { + return false; + } + if (footer.column_meta_entries_size() != out->num_columns) { + return false; + } + // Compute region_end = region_start + sum(length_i) with overflow guards. + uint64_t region_size = 0; + for (int i = 0; i < footer.column_meta_entries_size(); ++i) { + const auto& entry = footer.column_meta_entries(i); + const uint64_t len = static_cast<uint64_t>(entry.length()); + if (len == 0) { + return false; + } + if (region_size + len < region_size) { + return false; + } // overflow guard + region_size += len; + } + out->region_end = out->region_start + region_size; + if (out->region_end <= out->region_start) { + return false; + } + return true; +} + +bool ExternalColMetaUtil::parse_uid_to_colid_map( Review Comment: 这里也不要返回true or false -- 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]
