Coverage Report

Created: 2026-03-18 09:47

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
3
bool ConditionCache::lookup(const KeyType& key, ConditionCacheHandle* handle) {
28
3
    auto encoded_key = key.encode();
29
3
    if (encoded_key.empty()) {
30
0
        return false;
31
0
    }
32
3
    auto lru_handle = LRUCachePolicy::lookup(encoded_key);
33
3
    if (!lru_handle) {
34
2
        return false;
35
2
    }
36
1
    *handle = ConditionCacheHandle(this, lru_handle);
37
1
    return true;
38
3
}
Unexecuted instantiation: _ZN5doris10segment_v214ConditionCache6lookupINS1_8CacheKeyEEEbRKT_PNS0_20ConditionCacheHandleE
_ZN5doris10segment_v214ConditionCache6lookupINS1_16ExternalCacheKeyEEEbRKT_PNS0_20ConditionCacheHandleE
Line
Count
Source
27
3
bool ConditionCache::lookup(const KeyType& key, ConditionCacheHandle* handle) {
28
3
    auto encoded_key = key.encode();
29
3
    if (encoded_key.empty()) {
30
0
        return false;
31
0
    }
32
3
    auto lru_handle = LRUCachePolicy::lookup(encoded_key);
33
3
    if (!lru_handle) {
34
2
        return false;
35
2
    }
36
1
    *handle = ConditionCacheHandle(this, lru_handle);
37
1
    return true;
38
3
}
39
40
template <typename KeyType>
41
1
void ConditionCache::insert(const KeyType& key, std::shared_ptr<std::vector<bool>> result) {
42
1
    auto encoded_key = key.encode();
43
1
    if (encoded_key.empty()) {
44
0
        return;
45
0
    }
46
1
    std::unique_ptr<ConditionCache::CacheValue> cache_value_ptr =
47
1
            std::make_unique<ConditionCache::CacheValue>();
48
1
    cache_value_ptr->filter_result = result;
49
50
1
    ConditionCacheHandle(this, LRUCachePolicy::insert(encoded_key, (void*)cache_value_ptr.release(),
51
1
                                                      result->capacity(), result->capacity(),
52
1
                                                      CachePriority::NORMAL));
53
1
}
Unexecuted instantiation: _ZN5doris10segment_v214ConditionCache6insertINS1_8CacheKeyEEEvRKT_St10shared_ptrISt6vectorIbSaIbEEE
_ZN5doris10segment_v214ConditionCache6insertINS1_16ExternalCacheKeyEEEvRKT_St10shared_ptrISt6vectorIbSaIbEEE
Line
Count
Source
41
1
void ConditionCache::insert(const KeyType& key, std::shared_ptr<std::vector<bool>> result) {
42
1
    auto encoded_key = key.encode();
43
1
    if (encoded_key.empty()) {
44
0
        return;
45
0
    }
46
1
    std::unique_ptr<ConditionCache::CacheValue> cache_value_ptr =
47
1
            std::make_unique<ConditionCache::CacheValue>();
48
1
    cache_value_ptr->filter_result = result;
49
50
1
    ConditionCacheHandle(this, LRUCachePolicy::insert(encoded_key, (void*)cache_value_ptr.release(),
51
1
                                                      result->capacity(), result->capacity(),
52
1
                                                      CachePriority::NORMAL));
53
1
}
54
55
// Explicit template instantiations
56
template bool ConditionCache::lookup<ConditionCache::CacheKey>(const CacheKey& key,
57
                                                               ConditionCacheHandle* handle);
58
template bool ConditionCache::lookup<ConditionCache::ExternalCacheKey>(
59
        const ExternalCacheKey& key, ConditionCacheHandle* handle);
60
template void ConditionCache::insert<ConditionCache::CacheKey>(
61
        const CacheKey& key, std::shared_ptr<std::vector<bool>> filter_result);
62
template void ConditionCache::insert<ConditionCache::ExternalCacheKey>(
63
        const ExternalCacheKey& key, std::shared_ptr<std::vector<bool>> filter_result);
64
65
} // namespace doris::segment_v2