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 | 11 | bool ConditionCache::lookup(const KeyType& key, ConditionCacheHandle* handle) { |
28 | 11 | auto encoded_key = key.encode(); |
29 | 11 | if (encoded_key.empty()) { |
30 | 0 | return false; |
31 | 0 | } |
32 | 11 | auto lru_handle = LRUCachePolicy::lookup(encoded_key); |
33 | 11 | if (!lru_handle) { |
34 | 9 | return false; |
35 | 9 | } |
36 | 2 | *handle = ConditionCacheHandle(this, lru_handle); |
37 | 2 | return true; |
38 | 11 | } Unexecuted instantiation: _ZN5doris10segment_v214ConditionCache6lookupINS1_8CacheKeyEEEbRKT_PNS0_20ConditionCacheHandleE _ZN5doris10segment_v214ConditionCache6lookupINS1_16ExternalCacheKeyEEEbRKT_PNS0_20ConditionCacheHandleE Line | Count | Source | 27 | 11 | bool ConditionCache::lookup(const KeyType& key, ConditionCacheHandle* handle) { | 28 | 11 | auto encoded_key = key.encode(); | 29 | 11 | if (encoded_key.empty()) { | 30 | 0 | return false; | 31 | 0 | } | 32 | 11 | auto lru_handle = LRUCachePolicy::lookup(encoded_key); | 33 | 11 | if (!lru_handle) { | 34 | 9 | return false; | 35 | 9 | } | 36 | 2 | *handle = ConditionCacheHandle(this, lru_handle); | 37 | 2 | return true; | 38 | 11 | } |
|
39 | | |
40 | | template <typename KeyType> |
41 | | void ConditionCache::insert(const KeyType& key, std::shared_ptr<std::vector<bool>> result, |
42 | 2 | int64_t base_granule) { |
43 | 2 | auto encoded_key = key.encode(); |
44 | 2 | if (encoded_key.empty()) { |
45 | 0 | return; |
46 | 0 | } |
47 | 2 | std::unique_ptr<ConditionCache::CacheValue> cache_value_ptr = |
48 | 2 | std::make_unique<ConditionCache::CacheValue>(); |
49 | 2 | cache_value_ptr->filter_result = result; |
50 | 2 | cache_value_ptr->base_granule = base_granule; |
51 | | |
52 | 2 | ConditionCacheHandle(this, LRUCachePolicy::insert(encoded_key, (void*)cache_value_ptr.release(), |
53 | 2 | result->capacity(), result->capacity(), |
54 | 2 | CachePriority::NORMAL)); |
55 | 2 | } Unexecuted instantiation: _ZN5doris10segment_v214ConditionCache6insertINS1_8CacheKeyEEEvRKT_St10shared_ptrISt6vectorIbSaIbEEEl _ZN5doris10segment_v214ConditionCache6insertINS1_16ExternalCacheKeyEEEvRKT_St10shared_ptrISt6vectorIbSaIbEEEl Line | Count | Source | 42 | 2 | int64_t base_granule) { | 43 | 2 | auto encoded_key = key.encode(); | 44 | 2 | if (encoded_key.empty()) { | 45 | 0 | return; | 46 | 0 | } | 47 | 2 | std::unique_ptr<ConditionCache::CacheValue> cache_value_ptr = | 48 | 2 | std::make_unique<ConditionCache::CacheValue>(); | 49 | 2 | cache_value_ptr->filter_result = result; | 50 | 2 | cache_value_ptr->base_granule = base_granule; | 51 | | | 52 | 2 | ConditionCacheHandle(this, LRUCachePolicy::insert(encoded_key, (void*)cache_value_ptr.release(), | 53 | 2 | result->capacity(), result->capacity(), | 54 | 2 | CachePriority::NORMAL)); | 55 | 2 | } |
|
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 |