yiguolei commented on code in PR #48924:
URL: https://github.com/apache/doris/pull/48924#discussion_r1990706522
##########
be/src/olap/rowset/segment_v2/segment.cpp:
##########
@@ -1185,4 +1188,58 @@ Status Segment::seek_and_read_by_rowid(const
TabletSchema& schema, SlotDescripto
return Status::OK();
}
+Status Segment::_get_segment_footer(std::shared_ptr<SegmentFooterPB>&
footer_pb) {
+ std::shared_ptr<SegmentFooterPB> footer_pb_shared = _footer_pb.lock();
+ if (footer_pb_shared != nullptr) {
+ footer_pb = footer_pb_shared;
+ return Status::OK();
+ }
+
+ VLOG_DEBUG << fmt::format("Segment footer of {}:{}:{} is missing, try to
load it",
+ _file_reader->path().native(),
_file_reader->size(),
+ _file_reader->size() - 12);
+
+ StoragePageCache* segment_footer_cache =
ExecEnv::GetInstance()->get_storage_page_cache();
+ DCHECK(segment_footer_cache != nullptr);
+
+ auto cache_key = get_segment_footer_cache_key();
+
+ PageCacheHandle cache_handle;
+
+ if (segment_footer_cache->lookup(cache_key, &cache_handle,
segment_v2::PageTypePB::DATA_PAGE)) {
+ VLOG_DEBUG << fmt::format("Segment footer of {}:{}:{} is found in
cache",
+ _file_reader->path().native(),
_file_reader->size(),
+ _file_reader->size() - 12);
+ SemgnetFooterPBPage* ptr = cache_handle.as<SemgnetFooterPBPage*>();
+ footer_pb_shared = ptr->data();
+ } else {
+ footer_pb_shared = std::make_shared<SegmentFooterPB>();
+ RETURN_IF_ERROR(_parse_footer(footer_pb_shared));
+
+ auto footer_pb_page = std::make_unique<SemgnetFooterPBPage>(
+ footer_pb_shared->ByteSizeLong(), true,
segment_v2::PageTypePB::DATA_PAGE);
+
+ footer_pb_page->set_data(footer_pb_shared);
+
+ segment_footer_cache->insert(cache_key, (void*)(footer_pb_page.get()),
Review Comment:
insert(param1, std::shared_ptr<T> param2)
--
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]