Coverage Report

Created: 2026-03-15 17:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/storage/tablet/tablet_schema_cache.h
Line
Count
Source
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
#pragma once
19
20
#include "runtime/exec_env.h"
21
#include "runtime/memory/lru_cache_policy.h"
22
#include "storage/tablet/tablet_fwd.h"
23
24
namespace doris {
25
26
class TabletSchemaCache : public LRUCachePolicy {
27
public:
28
    using LRUCachePolicy::insert;
29
30
    TabletSchemaCache(size_t capacity)
31
1
            : LRUCachePolicy(CachePolicy::CacheType::TABLET_SCHEMA_CACHE, capacity,
32
1
                             LRUCacheType::NUMBER, config::tablet_schema_cache_recycle_interval,
33
1
                             /*num_shards*/ 32,
34
1
                             /*element_count_capacity*/ 0, /*enable_prune*/ true,
35
1
                             /*is_lru_k*/ false) {}
36
37
1
    static TabletSchemaCache* create_global_schema_cache(size_t capacity) {
38
1
        auto* res = new TabletSchemaCache(capacity);
39
1
        return res;
40
1
    }
41
42
13.9k
    static TabletSchemaCache* instance() {
43
13.9k
        return ExecEnv::GetInstance()->get_tablet_schema_cache();
44
13.9k
    }
45
46
    std::pair<Cache::Handle*, TabletSchemaSPtr> insert(const std::string& key);
47
48
    void release(Cache::Handle*);
49
50
private:
51
    class CacheValue : public LRUCacheValueBase {
52
    public:
53
        ~CacheValue() override;
54
55
        TabletSchemaSPtr tablet_schema;
56
    };
57
};
58
59
} // namespace doris