Coverage Report

Created: 2026-03-14 18:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/exprs/function/dictionary_factory.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 "exprs/function/dictionary_factory.h"
19
20
#include <gen_cpp/DataSinks_types.h>
21
22
#include "runtime/memory/mem_tracker_limiter.h"
23
#include "runtime/thread_context.h"
24
25
namespace doris {
26
27
DictionaryFactory::DictionaryFactory()
28
13
        : _mem_tracker(MemTrackerLimiter::create_shared(MemTrackerLimiter::Type::GLOBAL,
29
13
                                                        "GLOBAL_DICT_FACTORY")) {
30
13
    SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER(_mem_tracker);
31
13
}
32
33
9
DictionaryFactory::~DictionaryFactory() {
34
9
    SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER(_mem_tracker);
35
9
    _dict_id_to_dict_map.clear();
36
9
    _dict_id_to_version_id_map.clear();
37
9
}
38
39
void DictionaryFactory::get_dictionary_status(std::vector<TDictionaryStatus>& result,
40
1.13k
                                              std::vector<int64_t> dict_ids) {
41
1.13k
    std::shared_lock lc(_mutex);
42
1.13k
    if (dict_ids.empty()) { // empty means ALL
43
7.36k
        for (const auto& [dict_id, dict] : _dict_id_to_dict_map) {
44
7.36k
            TDictionaryStatus status;
45
7.36k
            status.__set_dictionary_id(dict_id);
46
7.36k
            status.__set_version_id(_dict_id_to_version_id_map[dict_id]);
47
7.36k
            status.__set_dictionary_memory_size(dict->allocated_bytes());
48
7.36k
            result.emplace_back(std::move(status));
49
7.36k
        }
50
1.10k
    } else {
51
75
        for (auto dict_id : dict_ids) {
52
75
            if (_dict_id_to_dict_map.contains(dict_id)) {
53
46
                TDictionaryStatus status;
54
46
                status.__set_dictionary_id(dict_id);
55
46
                status.__set_version_id(_dict_id_to_version_id_map[dict_id]);
56
46
                status.__set_dictionary_memory_size(
57
46
                        _dict_id_to_dict_map[dict_id]->allocated_bytes());
58
46
                result.emplace_back(std::move(status));
59
46
            }
60
75
        }
61
38
    }
62
1.13k
}
63
64
} // namespace doris