xref: /aosp_15_r20/external/perfetto/src/trace_processor/db/column.cc (revision 6dbdd20afdafa5e3ca9b8809fa73465d530080dc)
1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #include "src/trace_processor/db/column.h"
17 
18 #include <cstdint>
19 #include <limits>
20 
21 #include "column/types.h"
22 #include "column_storage.h"
23 #include "column_storage_overlay.h"
24 #include "perfetto/base/logging.h"
25 #include "src/trace_processor/db/table.h"
26 
27 namespace perfetto::trace_processor {
28 
ColumnLegacy(const ColumnLegacy & column,uint32_t col_idx,uint32_t overlay_idx,const char * name)29 ColumnLegacy::ColumnLegacy(const ColumnLegacy& column,
30                            uint32_t col_idx,
31                            uint32_t overlay_idx,
32                            const char* name)
33     : ColumnLegacy(name ? name : column.name_,
34                    column.type_,
35                    column.flags_ & ~kNoCrossTableInheritFlags,
36                    col_idx,
37                    overlay_idx,
38                    column.storage_) {}
39 
ColumnLegacy(const char * name,ColumnType type,uint32_t flags,uint32_t index_in_table,uint32_t overlay_index,ColumnStorageBase * st)40 ColumnLegacy::ColumnLegacy(const char* name,
41                            ColumnType type,
42                            uint32_t flags,
43                            uint32_t index_in_table,
44                            uint32_t overlay_index,
45                            ColumnStorageBase* st)
46     : type_(type),
47       storage_(st),
48       name_(name),
49       flags_(flags),
50       index_in_table_(index_in_table),
51       overlay_index_(overlay_index) {}
52 
DummyColumn(const char * name,uint32_t col_idx_in_table)53 ColumnLegacy ColumnLegacy::DummyColumn(const char* name,
54                                        uint32_t col_idx_in_table) {
55   return {name,
56           ColumnType::kDummy,
57           Flag::kNoFlag,
58           col_idx_in_table,
59           std::numeric_limits<uint32_t>::max(),
60           nullptr};
61 }
62 
IdColumn(uint32_t col_idx,uint32_t overlay_idx,const char * name,uint32_t flags)63 ColumnLegacy ColumnLegacy::IdColumn(uint32_t col_idx,
64                                     uint32_t overlay_idx,
65                                     const char* name,
66                                     uint32_t flags) {
67   return {name, ColumnType::kId, flags, col_idx, overlay_idx, nullptr};
68 }
69 
overlay() const70 const ColumnStorageOverlay& ColumnLegacy::overlay() const {
71   PERFETTO_DCHECK(type_ != ColumnType::kDummy);
72   return table_->overlays_[overlay_index()];
73 }
74 
75 }  // namespace perfetto::trace_processor
76