be/src/storage/rowset/rowset_segment_id.h
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 | | #pragma once |
19 | | |
20 | | #include <glog/logging.h> |
21 | | |
22 | | #include <cstddef> |
23 | | #include <cstdint> |
24 | | #include <vector> |
25 | | |
26 | | namespace doris { |
27 | | |
28 | | struct RowsetSegmentRef { |
29 | | // Position in rowset-level repeated metadata arrays. |
30 | | size_t pos; |
31 | | // Real segment id used in file names, cache keys, delete bitmap keys, and RowLocation. |
32 | | int64_t id; |
33 | | }; |
34 | | |
35 | | template <typename RowsetMetaPB> |
36 | 3 | int64_t rowset_segment_id(const RowsetMetaPB& rowset_meta, int64_t pos) { |
37 | 3 | DCHECK_GE(pos, 0); |
38 | 3 | DCHECK_LT(pos, rowset_meta.num_segments()); |
39 | 3 | if (rowset_meta.segment_ids_size() == 0) { |
40 | 3 | return pos; |
41 | 3 | } |
42 | 3 | DCHECK_EQ(rowset_meta.segment_ids_size(), rowset_meta.num_segments()); |
43 | 0 | return rowset_meta.segment_ids(static_cast<int>(pos)); |
44 | 3 | } Unexecuted instantiation: _ZN5doris17rowset_segment_idINS_16RecycleCacheMetaEEElRKT_l Unexecuted instantiation: _ZN5doris17rowset_segment_idINS_17RowsetMetaCloudPBEEElRKT_l _ZN5doris17rowset_segment_idINS_12RowsetMetaPBEEElRKT_l Line | Count | Source | 36 | 3 | int64_t rowset_segment_id(const RowsetMetaPB& rowset_meta, int64_t pos) { | 37 | 3 | DCHECK_GE(pos, 0); | 38 | 3 | DCHECK_LT(pos, rowset_meta.num_segments()); | 39 | 3 | if (rowset_meta.segment_ids_size() == 0) { | 40 | 3 | return pos; | 41 | 3 | } | 42 | 3 | DCHECK_EQ(rowset_meta.segment_ids_size(), rowset_meta.num_segments()); | 43 | 0 | return rowset_meta.segment_ids(static_cast<int>(pos)); | 44 | 3 | } |
|
45 | | |
46 | | template <typename RowsetMetaPB> |
47 | 0 | std::vector<int64_t> rowset_segment_ids(const RowsetMetaPB& rowset_meta) { |
48 | 0 | DCHECK_GE(rowset_meta.num_segments(), 0); |
49 | 0 | std::vector<int64_t> segment_ids; |
50 | 0 | segment_ids.reserve(static_cast<size_t>(rowset_meta.num_segments())); |
51 | 0 | for (int64_t pos = 0; pos < rowset_meta.num_segments(); ++pos) { |
52 | 0 | segment_ids.push_back(rowset_segment_id(rowset_meta, pos)); |
53 | 0 | } |
54 | 0 | return segment_ids; |
55 | 0 | } |
56 | | |
57 | | } // namespace doris |