Coverage Report

Created: 2025-05-22 18:31

/root/doris/cloud/src/recycler/util.h
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
#pragma once
19
20
#include <fmt/core.h>
21
#include <gen_cpp/cloud.pb.h>
22
#include <glog/logging.h>
23
24
#include <string>
25
26
namespace doris::cloud {
27
28
// The time unit is the same with BE: us
29
#define SCOPED_BVAR_LATENCY(bvar_item)                     \
30
3
    StopWatch sw;                                          \
31
3
    std::unique_ptr<int, std::function<void(int*)>> defer( \
32
3
            (int*)0x01, [&](int*) { bvar_item << sw.elapsed_us(); });
Unexecuted instantiation: hdfs_accessor.cpp:_ZZN5doris5cloud12HdfsAccessor11delete_fileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEENK3$_0clEPi
Unexecuted instantiation: hdfs_accessor.cpp:_ZZN5doris5cloud12HdfsAccessor8put_fileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_ENK3$_0clEPi
Unexecuted instantiation: hdfs_accessor.cpp:_ZZZN5doris5cloud12HdfsAccessor8put_fileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_ENK3$_1clEPiENKUlSB_E_clESB_
Unexecuted instantiation: hdfs_accessor.cpp:_ZZN5doris5cloud12HdfsAccessor8put_fileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_ENK3$_2clEPi
Unexecuted instantiation: hdfs_accessor.cpp:_ZZN5doris5cloud12HdfsAccessor8put_fileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_ENK3$_3clEPi
Unexecuted instantiation: _ZZN5doris5cloud16HdfsListIterator14list_directoryEPKcENKUlPiE_clES4_
Unexecuted instantiation: hdfs_accessor.cpp:_ZZN5doris5cloud12HdfsAccessor6existsERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEENK3$_0clEPi
Unexecuted instantiation: azure_obj_client.cpp:_ZZZZN5doris5cloud14AzureObjClient10put_objectENS0_20ObjectStoragePathRefESt17basic_string_viewIcSt11char_traitsIcEEENK3$_0clEvENKUlvE_clEvENKUlPiE_clES9_
Unexecuted instantiation: azure_obj_client.cpp:_ZZZN5doris5cloud14AzureObjClient11head_objectENS0_20ObjectStoragePathRefEPNS0_10ObjectMetaEENK3$_0clEvENKUlPiE_clES6_
Unexecuted instantiation: _ZZZN5doris5cloud17AzureListIterator8has_nextEvENKUlvE_clEvENKUlPiE_clES3_
Unexecuted instantiation: azure_obj_client.cpp:_ZZZZN5doris5cloud14AzureObjClient14delete_objectsERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt6vectorIS7_SaIS7_EENS0_16ObjClientOptionsEENK3$_0clEvENKUlvE_clEvENKUlPiE_clESG_
Unexecuted instantiation: azure_obj_client.cpp:_ZZZZN5doris5cloud14AzureObjClient13delete_objectENS0_20ObjectStoragePathRefEENK3$_0clEvENKUlvE_clEvENKUlPiE_clES5_
Unexecuted instantiation: s3_obj_client.cpp:_ZZZZN5doris5cloud11S3ObjClient14delete_objectsERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt6vectorIS7_SaIS7_EENS0_16ObjClientOptionsEENK3$_0clESA_IN3Aws2S35Model16ObjectIdentifierESaISI_EEENKUlvE_clEvENKUlPiE_clESM_
Unexecuted instantiation: s3_obj_client.cpp:_ZZZN5doris5cloud11S3ObjClient10put_objectENS0_20ObjectStoragePathRefESt17basic_string_viewIcSt11char_traitsIcEEENK3$_0clEvENKUlPiE_clES8_
s3_obj_client.cpp:_ZZZN5doris5cloud11S3ObjClient11head_objectENS0_20ObjectStoragePathRefEPNS0_10ObjectMetaEENK3$_0clEvENKUlPiE_clES6_
Line
Count
Source
32
1
            (int*)0x01, [&](int*) { bvar_item << sw.elapsed_us(); });
_ZZZN5doris5cloud17S3ObjListIterator8has_nextEvENKUlvE_clEvENKUlPiE_clES3_
Line
Count
Source
32
2
            (int*)0x01, [&](int*) { bvar_item << sw.elapsed_us(); });
Unexecuted instantiation: s3_obj_client.cpp:_ZZZN5doris5cloud11S3ObjClient13delete_objectENS0_20ObjectStoragePathRefEENK3$_0clEvENKUlPiE_clES4_
33
34
class TxnKv;
35
36
/**
37
 * Get all instances, include DELETED instance
38
 * @return 0 for success, otherwise error
39
 */
40
int get_all_instances(TxnKv* txn_kv, std::vector<InstanceInfoPB>& res);
41
42
/**
43
 *
44
 * @return 0 for success
45
 */
46
int prepare_instance_recycle_job(TxnKv* txn_kv, std::string_view key,
47
                                 const std::string& instance_id, const std::string& ip_port,
48
                                 int64_t interval_ms);
49
50
void finish_instance_recycle_job(TxnKv* txn_kv, std::string_view key,
51
                                 const std::string& instance_id, const std::string& ip_port,
52
                                 bool success, int64_t ctime_ms);
53
54
/**
55
 *
56
 * @return 0 for success, 1 if job should be aborted, negative for other errors
57
 */
58
int lease_instance_recycle_job(TxnKv* txn_kv, std::string_view key, const std::string& instance_id,
59
                               const std::string& ip_port);
60
61
inline std::string segment_path(int64_t tablet_id, const std::string& rowset_id,
62
172k
                                int64_t segment_id) {
63
172k
    return fmt::format("data/{}/{}_{}.dat", tablet_id, rowset_id, segment_id);
64
172k
}
65
66
inline std::string inverted_index_path_v2(int64_t tablet_id, const std::string& rowset_id,
67
5.00k
                                          int64_t segment_id) {
68
5.00k
    return fmt::format("data/{}/{}_{}.idx", tablet_id, rowset_id, segment_id);
69
5.00k
}
70
71
inline std::string inverted_index_path_v1(int64_t tablet_id, const std::string& rowset_id,
72
                                          int64_t segment_id, int64_t index_id,
73
289k
                                          std::string_view index_path_suffix) {
74
289k
    std::string suffix =
75
289k
            index_path_suffix.empty() ? "" : std::string {"@"} + index_path_suffix.data();
76
289k
    return fmt::format("data/{}/{}_{}_{}{}.idx", tablet_id, rowset_id, segment_id, index_id,
77
289k
                       suffix);
78
289k
}
79
80
2.90k
inline std::string rowset_path_prefix(int64_t tablet_id, const std::string& rowset_id) {
81
2.90k
    return fmt::format("data/{}/{}_", tablet_id, rowset_id);
82
2.90k
}
83
84
608
inline std::string tablet_path_prefix(int64_t tablet_id) {
85
608
    return fmt::format("data/{}/", tablet_id);
86
608
}
87
88
int get_tablet_idx(TxnKv* txn_kv, const std::string& instance_id, int64_t tablet_id,
89
                   TabletIndexPB& tablet_idx);
90
91
int get_tablet_meta(TxnKv* txn_kv, const std::string& instance_id, int64_t tablet_id,
92
                    TabletMetaCloudPB& tablet_meta);
93
} // namespace doris::cloud