yiguolei commented on code in PR #48924: URL: https://github.com/apache/doris/pull/48924#discussion_r1990539196
########## 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: 我觉得你这个传入 void*, 但是get 出来是shared ptr 我不好说哪个好。 你看如果我们直接能传递一个shared ptr 进去,那么1216 行和1222 行就是一行代码。 而且,从用户角度看,他传入的是一个shared ptr,拿出来的也是一个shared ptr,这样也会比较一致。 -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org