zhiqiang-hhhh commented on code in PR #48924: URL: https://github.com/apache/doris/pull/48924#discussion_r1988887406
########## be/src/olap/segment_footer_cache.h: ########## @@ -0,0 +1,115 @@ +// 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. + +#pragma once + +#include <gen_cpp/segment_v2.pb.h> + +#include <memory> + +#include "common/logging.h" +#include "common/status.h" +#include "olap/metadata_adder.h" +#include "olap/page_cache.h" +#include "runtime/exec_env.h" +#include "runtime/memory/lru_cache_policy.h" +#include "util/once.h" +#include "vec/common/allocator.h" +#include "vec/common/allocator_fwd.h" + +namespace doris { +/* +template <typename TAllocator> +class PageBase : private TAllocator, public LRUCacheValueBase { +public: + PageBase() = default; + PageBase(size_t b, bool use_cache, segment_v2::PageTypePB page_type); + PageBase(const PageBase&) = delete; + PageBase& operator=(const PageBase&) = delete; + ~PageBase() override; + + char* data() { return _data; } + size_t size() { return _size; } + size_t capacity() { return _capacity; } + + void reset_size(size_t n) { + DCHECK(n <= _capacity); + _size = n; + } + +private: + char* _data = nullptr; + // Effective size, smaller than capacity, such as data page remove checksum suffix. + size_t _size = 0; + size_t _capacity = 0; + std::shared_ptr<MemTrackerLimiter> _mem_tracker_by_allocator; +}; +*/ + +class SegmentFooterDataPage : public PageBase<Allocator<false>> { + // Need to implement some virtual methods. Review Comment: > 这么写应该是不够的。 比如说我们没有更新size 这些东东,此时会发现page cache 实际用了很多内存,但是从memtracker 上看用的内存又不多。 得看看page base 里的实现 size 跟 capacity 都更新了的,在 load_and_update 里面 -- 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