yiguolei commented on code in PR #48924:
URL: https://github.com/apache/doris/pull/48924#discussion_r1988821632


##########
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.
+public:
+    using LoadFooterFn = 
std::function<Status(std::shared_ptr<segment_v2::SegmentFooterPB>)>;
+
+    explicit SegmentFooterDataPage(LoadFooterFn load_function) : 
_load_function(load_function) {}
+
+    std::shared_ptr<segment_v2::SegmentFooterPB> load_once() {
+        return _load_once.call([this]() { return this->_load_and_update(); });
+    }
+
+private:
+    DorisCallOnce<std::shared_ptr<segment_v2::SegmentFooterPB>> _load_once;
+    LoadFooterFn _load_function;
+
+    std::shared_ptr<segment_v2::SegmentFooterPB> _load_and_update() {
+        std::shared_ptr<segment_v2::SegmentFooterPB> footer =
+                std::make_shared<segment_v2::SegmentFooterPB>();
+        Status load_status = _load_function(footer);

Review Comment:
   不要这么写。 
   在cloud 上,我们同步的确保只有一个线程去load 可能是不对的,比如他访问s3 
不稳定之类的。反而我们多个线程同时加载,谁成功用谁的,可以避免多个query 之间互相干扰。



-- 
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

Reply via email to