Coverage Report

Created: 2024-11-21 18:14

/root/doris/be/src/olap/schema_cache.cpp
Line
Count
Source (jump to first uncovered line)
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 "olap/schema_cache.h"
19
20
#include <butil/logging.h>
21
#include <fmt/core.h>
22
#include <gen_cpp/Descriptors_types.h>
23
#include <glog/logging.h>
24
25
#include <memory>
26
#include <mutex>
27
#include <vector>
28
29
#include "common/config.h"
30
#include "olap/schema.h"
31
#include "olap/tablet.h"
32
#include "olap/tablet_schema.h"
33
#include "util/defer_op.h"
34
#include "util/time.h"
35
36
namespace doris {
37
38
0
SchemaCache* SchemaCache::instance() {
39
0
    return ExecEnv::GetInstance()->schema_cache();
40
0
}
41
42
// format: tabletId-unique_id1-uniqueid2...-version-type
43
std::string SchemaCache::get_schema_key(int64_t tablet_id, const std::vector<TColumn>& columns,
44
0
                                        int32_t version) {
45
0
    if (columns.empty() || columns[0].col_unique_id < 0) {
46
0
        return "";
47
0
    }
48
0
    std::string key = fmt::format("{}-", tablet_id);
49
0
    std::for_each(columns.begin(), columns.end(), [&](const TColumn& col) {
50
0
        key.append(fmt::format("{}", col.col_unique_id));
51
0
        key.append("-");
52
0
    });
53
0
    key.append(fmt::format("{}", version));
54
0
    return key;
55
0
}
56
57
} // namespace doris