This is an automated email from the ASF dual-hosted git repository.
hello-stephen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 78a3920d17f [fix](be) Reuse segment magic constants in meta tool
(#66897)
78a3920d17f is described below
commit 78a3920d17f704939edbd0a0abed094381c47984
Author: Dongyang Li <[email protected]>
AuthorDate: Tue Aug 18 19:59:40 2026 +0800
[fix](be) Reuse segment magic constants in meta tool (#66897)
PR #66789 centralized the segment footer magic constants in
`storage/segment/common.h`, but `meta_tool.cpp` still declared the same
names locally in its segment read and write paths. When
`BUILD_META_TOOL=ON`, Clang reports four `-Wshadow` diagnostics and the
ASAN build fails because warnings are treated as errors.
This change includes the defining header explicitly and reuses
`doris::segment_v2::k_segment_magic` and `k_segment_magic_length` in
both paths.
---
be/src/tools/meta_tool.cpp | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/be/src/tools/meta_tool.cpp b/be/src/tools/meta_tool.cpp
index 18bc27c1d83..99970f8a938 100644
--- a/be/src/tools/meta_tool.cpp
+++ b/be/src/tools/meta_tool.cpp
@@ -53,6 +53,7 @@
#include "storage/olap_common.h"
#include "storage/options.h"
#include "storage/segment/column_reader.h"
+#include "storage/segment/common.h"
#include "storage/segment/encoding_info.h"
#include "storage/segment/page_pointer.h"
#include "storage/storage_engine.h"
@@ -288,9 +289,8 @@ Status get_segment_footer(doris::io::FileReader*
file_reader, SegmentFooterPB* f
RETURN_IF_ERROR(file_reader->read_at(file_size - 12, slice, &bytes_read));
// validate magic number
- const char* k_segment_magic = "D0R1";
- const uint32_t k_segment_magic_length = 4;
- if (memcmp(fixed_buf + 8, k_segment_magic, k_segment_magic_length) != 0) {
+ if (memcmp(fixed_buf + 8, doris::segment_v2::k_segment_magic,
+ doris::segment_v2::k_segment_magic_length) != 0) {
return Status::Corruption("Bad segment file {}: magic number not
match", file_name);
}
@@ -1034,9 +1034,8 @@ void gen_empty_segment() {
footer_slices.push_back(Slice(footer_checksum_buf, 4));
// Magic number (4 bytes): "D0R1"
- const char* k_segment_magic = "D0R1";
- const uint32_t k_segment_magic_length = 4;
- footer_slices.push_back(Slice(k_segment_magic, k_segment_magic_length));
+ footer_slices.push_back(
+ Slice(doris::segment_v2::k_segment_magic,
doris::segment_v2::k_segment_magic_length));
// Write index page first, then footer
for (const auto& slice : index_body) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]