Coverage Report

Created: 2026-07-14 06:35

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/storage/segment/condition_cache.cpp
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
#include "storage/segment/condition_cache.h"
19
20
#include <memory>
21
22
#include "util/defer_op.h"
23
24
namespace doris::segment_v2 {
25
26
template <typename KeyType>
27
1.70M
bool ConditionCache::lookup(const KeyType& key, ConditionCacheHandle* handle) {
28
1.70M
    auto encoded_key = key.encode();
29
1.70M
    if (encoded_key.empty()) {
30
0
        return false;
31
0
    }
32
1.70M
    auto lru_handle = LRUCachePolicy::lookup(encoded_key);
33
1.70M
    if (!lru_handle) {
34
1.54M
        return false;
35
1.54M
    }
36
159k
    *handle = ConditionCacheHandle(this, lru_handle);
37
159k
    return true;
38
1.70M
}
_ZN5doris10segment_v214ConditionCache6lookupINS1_8CacheKeyEEEbRKT_PNS0_20ConditionCacheHandleE
Line
Count
Source
27
1.67M
bool ConditionCache::lookup(const KeyType& key, ConditionCacheHandle* handle) {
28
1.67M
    auto encoded_key = key.encode();
29
1.67M
    if (encoded_key.empty()) {
30
0
        return false;
31
0
    }
32
1.67M
    auto lru_handle = LRUCachePolicy::lookup(encoded_key);
33
1.67M
    if (!lru_handle) {
34
1.52M
        return false;
35
1.52M
    }
36
155k
    *handle = ConditionCacheHandle(this, lru_handle);
37
155k
    return true;
38
1.67M
}
_ZN5doris10segment_v214ConditionCache6lookupINS1_16ExternalCacheKeyEEEbRKT_PNS0_20ConditionCacheHandleE
Line
Count
Source
27
24.6k
bool ConditionCache::lookup(const KeyType& key, ConditionCacheHandle* handle) {
28
24.6k
    auto encoded_key = key.encode();
29
24.6k
    if (encoded_key.empty()) {
30
0
        return false;
31
0
    }
32
24.6k
    auto lru_handle = LRUCachePolicy::lookup(encoded_key);
33
24.6k
    if (!lru_handle) {
34
20.8k
        return false;
35
20.8k
    }
36
3.84k
    *handle = ConditionCacheHandle(this, lru_handle);
37
3.84k
    return true;
38
24.6k
}
39
40
template <typename KeyType>
41
void ConditionCache::insert(const KeyType& key, std::shared_ptr<std::vector<bool>> result,
42
1.50M
                            int64_t base_granule) {
43
1.50M
    auto encoded_key = key.encode();
44
1.50M
    if (encoded_key.empty()) {
45
0
        return;
46
0
    }
47
1.50M
    std::unique_ptr<ConditionCache::CacheValue> cache_value_ptr =
48
1.50M
            std::make_unique<ConditionCache::CacheValue>();
49
1.50M
    cache_value_ptr->filter_result = result;
50
1.50M
    cache_value_ptr->base_granule = base_granule;
51
52
1.50M
    ConditionCacheHandle(this, LRUCachePolicy::insert(encoded_key, (void*)cache_value_ptr.release(),
53
1.50M
                                                      result->capacity(), result->capacity(),
54
1.50M
                                                      CachePriority::NORMAL));
55
1.50M
}
_ZN5doris10segment_v214ConditionCache6insertINS1_8CacheKeyEEEvRKT_St10shared_ptrISt6vectorIbSaIbEEEl
Line
Count
Source
42
1.50M
                            int64_t base_granule) {
43
1.50M
    auto encoded_key = key.encode();
44
1.50M
    if (encoded_key.empty()) {
45
0
        return;
46
0
    }
47
1.50M
    std::unique_ptr<ConditionCache::CacheValue> cache_value_ptr =
48
1.50M
            std::make_unique<ConditionCache::CacheValue>();
49
1.50M
    cache_value_ptr->filter_result = result;
50
1.50M
    cache_value_ptr->base_granule = base_granule;
51
52
1.50M
    ConditionCacheHandle(this, LRUCachePolicy::insert(encoded_key, (void*)cache_value_ptr.release(),
53
1.50M
                                                      result->capacity(), result->capacity(),
54
1.50M
                                                      CachePriority::NORMAL));
55
1.50M
}
_ZN5doris10segment_v214ConditionCache6insertINS1_16ExternalCacheKeyEEEvRKT_St10shared_ptrISt6vectorIbSaIbEEEl
Line
Count
Source
42
4.35k
                            int64_t base_granule) {
43
4.35k
    auto encoded_key = key.encode();
44
4.35k
    if (encoded_key.empty()) {
45
0
        return;
46
0
    }
47
4.35k
    std::unique_ptr<ConditionCache::CacheValue> cache_value_ptr =
48
4.35k
            std::make_unique<ConditionCache::CacheValue>();
49
4.35k
    cache_value_ptr->filter_result = result;
50
4.35k
    cache_value_ptr->base_granule = base_granule;
51
52
4.35k
    ConditionCacheHandle(this, LRUCachePolicy::insert(encoded_key, (void*)cache_value_ptr.release(),
53
4.35k
                                                      result->capacity(), result->capacity(),
54
4.35k
                                                      CachePriority::NORMAL));
55
4.35k
}
56
57
// Explicit template instantiations
58
template bool ConditionCache::lookup<ConditionCache::CacheKey>(const CacheKey& key,
59
                                                               ConditionCacheHandle* handle);
60
template bool ConditionCache::lookup<ConditionCache::ExternalCacheKey>(
61
        const ExternalCacheKey& key, ConditionCacheHandle* handle);
62
template void ConditionCache::insert<ConditionCache::CacheKey>(
63
        const CacheKey& key, std::shared_ptr<std::vector<bool>> filter_result,
64
        int64_t base_granule);
65
template void ConditionCache::insert<ConditionCache::ExternalCacheKey>(
66
        const ExternalCacheKey& key, std::shared_ptr<std::vector<bool>> filter_result,
67
        int64_t base_granule);
68
69
} // namespace doris::segment_v2