1 #ifndef SRC_TRACE_PROCESSOR_TABLES_SLICE_TABLES_PY_H_
2 #define SRC_TRACE_PROCESSOR_TABLES_SLICE_TABLES_PY_H_
3 
4 #include <array>
5 #include <cstddef>
6 #include <cstdint>
7 #include <memory>
8 #include <optional>
9 #include <type_traits>
10 #include <utility>
11 #include <vector>
12 
13 #include "perfetto/base/logging.h"
14 #include "perfetto/trace_processor/basic_types.h"
15 #include "perfetto/trace_processor/ref_counted.h"
16 #include "src/trace_processor/containers/bit_vector.h"
17 #include "src/trace_processor/containers/row_map.h"
18 #include "src/trace_processor/containers/string_pool.h"
19 #include "src/trace_processor/db/column/arrangement_overlay.h"
20 #include "src/trace_processor/db/column/data_layer.h"
21 #include "src/trace_processor/db/column/dense_null_overlay.h"
22 #include "src/trace_processor/db/column/numeric_storage.h"
23 #include "src/trace_processor/db/column/id_storage.h"
24 #include "src/trace_processor/db/column/null_overlay.h"
25 #include "src/trace_processor/db/column/range_overlay.h"
26 #include "src/trace_processor/db/column/selector_overlay.h"
27 #include "src/trace_processor/db/column/set_id_storage.h"
28 #include "src/trace_processor/db/column/string_storage.h"
29 #include "src/trace_processor/db/column/types.h"
30 #include "src/trace_processor/db/column_storage.h"
31 #include "src/trace_processor/db/column.h"
32 #include "src/trace_processor/db/table.h"
33 #include "src/trace_processor/db/typed_column.h"
34 #include "src/trace_processor/db/typed_column_internal.h"
35 #include "src/trace_processor/tables/macros_internal.h"
36 
37 #include "src/trace_processor/tables/track_tables_py.h"
38 
39 namespace perfetto::trace_processor::tables {
40 
41 class SliceTable : public macros_internal::MacroTable {
42  public:
43   static constexpr uint32_t kColumnCount = 16;
44 
45   struct Id : public BaseId {
46     Id() = default;
IdId47     explicit constexpr Id(uint32_t v) : BaseId(v) {}
48   };
49   static_assert(std::is_trivially_destructible_v<Id>,
50                 "Inheritance used without trivial destruction");
51 
52   struct ColumnIndex {
53     static constexpr uint32_t id = 0;
54     static constexpr uint32_t type = 1;
55     static constexpr uint32_t ts = 2;
56     static constexpr uint32_t dur = 3;
57     static constexpr uint32_t track_id = 4;
58     static constexpr uint32_t category = 5;
59     static constexpr uint32_t name = 6;
60     static constexpr uint32_t depth = 7;
61     static constexpr uint32_t stack_id = 8;
62     static constexpr uint32_t parent_stack_id = 9;
63     static constexpr uint32_t parent_id = 10;
64     static constexpr uint32_t arg_set_id = 11;
65     static constexpr uint32_t thread_ts = 12;
66     static constexpr uint32_t thread_dur = 13;
67     static constexpr uint32_t thread_instruction_count = 14;
68     static constexpr uint32_t thread_instruction_delta = 15;
69   };
70   struct ColumnType {
71     using id = IdColumn<SliceTable::Id>;
72     using type = TypedColumn<StringPool::Id>;
73     using ts = TypedColumn<int64_t>;
74     using dur = TypedColumn<int64_t>;
75     using track_id = TypedColumn<TrackTable::Id>;
76     using category = TypedColumn<std::optional<StringPool::Id>>;
77     using name = TypedColumn<std::optional<StringPool::Id>>;
78     using depth = TypedColumn<uint32_t>;
79     using stack_id = TypedColumn<int64_t>;
80     using parent_stack_id = TypedColumn<int64_t>;
81     using parent_id = TypedColumn<std::optional<SliceTable::Id>>;
82     using arg_set_id = TypedColumn<uint32_t>;
83     using thread_ts = TypedColumn<std::optional<int64_t>>;
84     using thread_dur = TypedColumn<std::optional<int64_t>>;
85     using thread_instruction_count = TypedColumn<std::optional<int64_t>>;
86     using thread_instruction_delta = TypedColumn<std::optional<int64_t>>;
87   };
88   struct Row : public macros_internal::RootParentTable::Row {
89     Row(int64_t in_ts = {},
90         int64_t in_dur = {},
91         TrackTable::Id in_track_id = {},
92         std::optional<StringPool::Id> in_category = {},
93         std::optional<StringPool::Id> in_name = {},
94         uint32_t in_depth = {},
95         int64_t in_stack_id = {},
96         int64_t in_parent_stack_id = {},
97         std::optional<SliceTable::Id> in_parent_id = {},
98         uint32_t in_arg_set_id = {},
99         std::optional<int64_t> in_thread_ts = {},
100         std::optional<int64_t> in_thread_dur = {},
101         std::optional<int64_t> in_thread_instruction_count = {},
102         std::optional<int64_t> in_thread_instruction_delta = {},
103         std::nullptr_t = nullptr)
RowRow104         : macros_internal::RootParentTable::Row(),
105           ts(in_ts),
106           dur(in_dur),
107           track_id(in_track_id),
108           category(in_category),
109           name(in_name),
110           depth(in_depth),
111           stack_id(in_stack_id),
112           parent_stack_id(in_parent_stack_id),
113           parent_id(in_parent_id),
114           arg_set_id(in_arg_set_id),
115           thread_ts(in_thread_ts),
116           thread_dur(in_thread_dur),
117           thread_instruction_count(in_thread_instruction_count),
118           thread_instruction_delta(in_thread_instruction_delta) {
119       type_ = "__intrinsic_slice";
120     }
121     int64_t ts;
122     int64_t dur;
123     TrackTable::Id track_id;
124     std::optional<StringPool::Id> category;
125     std::optional<StringPool::Id> name;
126     uint32_t depth;
127     int64_t stack_id;
128     int64_t parent_stack_id;
129     std::optional<SliceTable::Id> parent_id;
130     uint32_t arg_set_id;
131     std::optional<int64_t> thread_ts;
132     std::optional<int64_t> thread_dur;
133     std::optional<int64_t> thread_instruction_count;
134     std::optional<int64_t> thread_instruction_delta;
135 
136     bool operator==(const SliceTable::Row& other) const {
137       return type() == other.type() && ColumnType::ts::Equals(ts, other.ts) &&
138        ColumnType::dur::Equals(dur, other.dur) &&
139        ColumnType::track_id::Equals(track_id, other.track_id) &&
140        ColumnType::category::Equals(category, other.category) &&
141        ColumnType::name::Equals(name, other.name) &&
142        ColumnType::depth::Equals(depth, other.depth) &&
143        ColumnType::stack_id::Equals(stack_id, other.stack_id) &&
144        ColumnType::parent_stack_id::Equals(parent_stack_id, other.parent_stack_id) &&
145        ColumnType::parent_id::Equals(parent_id, other.parent_id) &&
146        ColumnType::arg_set_id::Equals(arg_set_id, other.arg_set_id) &&
147        ColumnType::thread_ts::Equals(thread_ts, other.thread_ts) &&
148        ColumnType::thread_dur::Equals(thread_dur, other.thread_dur) &&
149        ColumnType::thread_instruction_count::Equals(thread_instruction_count, other.thread_instruction_count) &&
150        ColumnType::thread_instruction_delta::Equals(thread_instruction_delta, other.thread_instruction_delta);
151     }
152   };
153   struct ColumnFlag {
154     static constexpr uint32_t ts = static_cast<uint32_t>(ColumnLegacy::Flag::kSorted) | ColumnType::ts::default_flags();
155     static constexpr uint32_t dur = ColumnType::dur::default_flags();
156     static constexpr uint32_t track_id = ColumnType::track_id::default_flags();
157     static constexpr uint32_t category = ColumnType::category::default_flags();
158     static constexpr uint32_t name = ColumnType::name::default_flags();
159     static constexpr uint32_t depth = ColumnType::depth::default_flags();
160     static constexpr uint32_t stack_id = ColumnType::stack_id::default_flags();
161     static constexpr uint32_t parent_stack_id = ColumnType::parent_stack_id::default_flags();
162     static constexpr uint32_t parent_id = ColumnType::parent_id::default_flags();
163     static constexpr uint32_t arg_set_id = ColumnType::arg_set_id::default_flags();
164     static constexpr uint32_t thread_ts = ColumnType::thread_ts::default_flags();
165     static constexpr uint32_t thread_dur = ColumnType::thread_dur::default_flags();
166     static constexpr uint32_t thread_instruction_count = ColumnType::thread_instruction_count::default_flags();
167     static constexpr uint32_t thread_instruction_delta = ColumnType::thread_instruction_delta::default_flags();
168   };
169 
170   class RowNumber;
171   class ConstRowReference;
172   class RowReference;
173 
174   class RowNumber : public macros_internal::AbstractRowNumber<
175       SliceTable, ConstRowReference, RowReference> {
176    public:
RowNumber(uint32_t row_number)177     explicit RowNumber(uint32_t row_number)
178         : AbstractRowNumber(row_number) {}
179   };
180   static_assert(std::is_trivially_destructible_v<RowNumber>,
181                 "Inheritance used without trivial destruction");
182 
183   class ConstRowReference : public macros_internal::AbstractConstRowReference<
184     SliceTable, RowNumber> {
185    public:
ConstRowReference(const SliceTable * table,uint32_t row_number)186     ConstRowReference(const SliceTable* table, uint32_t row_number)
187         : AbstractConstRowReference(table, row_number) {}
188 
id()189     ColumnType::id::type id() const {
190       return table()->id()[row_number_];
191     }
type()192     ColumnType::type::type type() const {
193       return table()->type()[row_number_];
194     }
ts()195     ColumnType::ts::type ts() const {
196       return table()->ts()[row_number_];
197     }
dur()198     ColumnType::dur::type dur() const {
199       return table()->dur()[row_number_];
200     }
track_id()201     ColumnType::track_id::type track_id() const {
202       return table()->track_id()[row_number_];
203     }
category()204     ColumnType::category::type category() const {
205       return table()->category()[row_number_];
206     }
name()207     ColumnType::name::type name() const {
208       return table()->name()[row_number_];
209     }
depth()210     ColumnType::depth::type depth() const {
211       return table()->depth()[row_number_];
212     }
stack_id()213     ColumnType::stack_id::type stack_id() const {
214       return table()->stack_id()[row_number_];
215     }
parent_stack_id()216     ColumnType::parent_stack_id::type parent_stack_id() const {
217       return table()->parent_stack_id()[row_number_];
218     }
parent_id()219     ColumnType::parent_id::type parent_id() const {
220       return table()->parent_id()[row_number_];
221     }
arg_set_id()222     ColumnType::arg_set_id::type arg_set_id() const {
223       return table()->arg_set_id()[row_number_];
224     }
thread_ts()225     ColumnType::thread_ts::type thread_ts() const {
226       return table()->thread_ts()[row_number_];
227     }
thread_dur()228     ColumnType::thread_dur::type thread_dur() const {
229       return table()->thread_dur()[row_number_];
230     }
thread_instruction_count()231     ColumnType::thread_instruction_count::type thread_instruction_count() const {
232       return table()->thread_instruction_count()[row_number_];
233     }
thread_instruction_delta()234     ColumnType::thread_instruction_delta::type thread_instruction_delta() const {
235       return table()->thread_instruction_delta()[row_number_];
236     }
237   };
238   static_assert(std::is_trivially_destructible_v<ConstRowReference>,
239                 "Inheritance used without trivial destruction");
240   class RowReference : public ConstRowReference {
241    public:
RowReference(const SliceTable * table,uint32_t row_number)242     RowReference(const SliceTable* table, uint32_t row_number)
243         : ConstRowReference(table, row_number) {}
244 
set_ts(ColumnType::ts::non_optional_type v)245     void set_ts(
246         ColumnType::ts::non_optional_type v) {
247       return mutable_table()->mutable_ts()->Set(row_number_, v);
248     }
set_dur(ColumnType::dur::non_optional_type v)249     void set_dur(
250         ColumnType::dur::non_optional_type v) {
251       return mutable_table()->mutable_dur()->Set(row_number_, v);
252     }
set_track_id(ColumnType::track_id::non_optional_type v)253     void set_track_id(
254         ColumnType::track_id::non_optional_type v) {
255       return mutable_table()->mutable_track_id()->Set(row_number_, v);
256     }
set_category(ColumnType::category::non_optional_type v)257     void set_category(
258         ColumnType::category::non_optional_type v) {
259       return mutable_table()->mutable_category()->Set(row_number_, v);
260     }
set_name(ColumnType::name::non_optional_type v)261     void set_name(
262         ColumnType::name::non_optional_type v) {
263       return mutable_table()->mutable_name()->Set(row_number_, v);
264     }
set_depth(ColumnType::depth::non_optional_type v)265     void set_depth(
266         ColumnType::depth::non_optional_type v) {
267       return mutable_table()->mutable_depth()->Set(row_number_, v);
268     }
set_stack_id(ColumnType::stack_id::non_optional_type v)269     void set_stack_id(
270         ColumnType::stack_id::non_optional_type v) {
271       return mutable_table()->mutable_stack_id()->Set(row_number_, v);
272     }
set_parent_stack_id(ColumnType::parent_stack_id::non_optional_type v)273     void set_parent_stack_id(
274         ColumnType::parent_stack_id::non_optional_type v) {
275       return mutable_table()->mutable_parent_stack_id()->Set(row_number_, v);
276     }
set_parent_id(ColumnType::parent_id::non_optional_type v)277     void set_parent_id(
278         ColumnType::parent_id::non_optional_type v) {
279       return mutable_table()->mutable_parent_id()->Set(row_number_, v);
280     }
set_arg_set_id(ColumnType::arg_set_id::non_optional_type v)281     void set_arg_set_id(
282         ColumnType::arg_set_id::non_optional_type v) {
283       return mutable_table()->mutable_arg_set_id()->Set(row_number_, v);
284     }
set_thread_ts(ColumnType::thread_ts::non_optional_type v)285     void set_thread_ts(
286         ColumnType::thread_ts::non_optional_type v) {
287       return mutable_table()->mutable_thread_ts()->Set(row_number_, v);
288     }
set_thread_dur(ColumnType::thread_dur::non_optional_type v)289     void set_thread_dur(
290         ColumnType::thread_dur::non_optional_type v) {
291       return mutable_table()->mutable_thread_dur()->Set(row_number_, v);
292     }
set_thread_instruction_count(ColumnType::thread_instruction_count::non_optional_type v)293     void set_thread_instruction_count(
294         ColumnType::thread_instruction_count::non_optional_type v) {
295       return mutable_table()->mutable_thread_instruction_count()->Set(row_number_, v);
296     }
set_thread_instruction_delta(ColumnType::thread_instruction_delta::non_optional_type v)297     void set_thread_instruction_delta(
298         ColumnType::thread_instruction_delta::non_optional_type v) {
299       return mutable_table()->mutable_thread_instruction_delta()->Set(row_number_, v);
300     }
301 
302    private:
mutable_table()303     SliceTable* mutable_table() const {
304       return const_cast<SliceTable*>(table());
305     }
306   };
307   static_assert(std::is_trivially_destructible_v<RowReference>,
308                 "Inheritance used without trivial destruction");
309 
310   class ConstIterator;
311   class ConstIterator : public macros_internal::AbstractConstIterator<
312     ConstIterator, SliceTable, RowNumber, ConstRowReference> {
313    public:
id()314     ColumnType::id::type id() const {
315       const auto& col = table()->id();
316       return col.GetAtIdx(
317         iterator_.StorageIndexForColumn(col.index_in_table()));
318     }
type()319     ColumnType::type::type type() const {
320       const auto& col = table()->type();
321       return col.GetAtIdx(
322         iterator_.StorageIndexForColumn(col.index_in_table()));
323     }
ts()324     ColumnType::ts::type ts() const {
325       const auto& col = table()->ts();
326       return col.GetAtIdx(
327         iterator_.StorageIndexForColumn(col.index_in_table()));
328     }
dur()329     ColumnType::dur::type dur() const {
330       const auto& col = table()->dur();
331       return col.GetAtIdx(
332         iterator_.StorageIndexForColumn(col.index_in_table()));
333     }
track_id()334     ColumnType::track_id::type track_id() const {
335       const auto& col = table()->track_id();
336       return col.GetAtIdx(
337         iterator_.StorageIndexForColumn(col.index_in_table()));
338     }
category()339     ColumnType::category::type category() const {
340       const auto& col = table()->category();
341       return col.GetAtIdx(
342         iterator_.StorageIndexForColumn(col.index_in_table()));
343     }
name()344     ColumnType::name::type name() const {
345       const auto& col = table()->name();
346       return col.GetAtIdx(
347         iterator_.StorageIndexForColumn(col.index_in_table()));
348     }
depth()349     ColumnType::depth::type depth() const {
350       const auto& col = table()->depth();
351       return col.GetAtIdx(
352         iterator_.StorageIndexForColumn(col.index_in_table()));
353     }
stack_id()354     ColumnType::stack_id::type stack_id() const {
355       const auto& col = table()->stack_id();
356       return col.GetAtIdx(
357         iterator_.StorageIndexForColumn(col.index_in_table()));
358     }
parent_stack_id()359     ColumnType::parent_stack_id::type parent_stack_id() const {
360       const auto& col = table()->parent_stack_id();
361       return col.GetAtIdx(
362         iterator_.StorageIndexForColumn(col.index_in_table()));
363     }
parent_id()364     ColumnType::parent_id::type parent_id() const {
365       const auto& col = table()->parent_id();
366       return col.GetAtIdx(
367         iterator_.StorageIndexForColumn(col.index_in_table()));
368     }
arg_set_id()369     ColumnType::arg_set_id::type arg_set_id() const {
370       const auto& col = table()->arg_set_id();
371       return col.GetAtIdx(
372         iterator_.StorageIndexForColumn(col.index_in_table()));
373     }
thread_ts()374     ColumnType::thread_ts::type thread_ts() const {
375       const auto& col = table()->thread_ts();
376       return col.GetAtIdx(
377         iterator_.StorageIndexForColumn(col.index_in_table()));
378     }
thread_dur()379     ColumnType::thread_dur::type thread_dur() const {
380       const auto& col = table()->thread_dur();
381       return col.GetAtIdx(
382         iterator_.StorageIndexForColumn(col.index_in_table()));
383     }
thread_instruction_count()384     ColumnType::thread_instruction_count::type thread_instruction_count() const {
385       const auto& col = table()->thread_instruction_count();
386       return col.GetAtIdx(
387         iterator_.StorageIndexForColumn(col.index_in_table()));
388     }
thread_instruction_delta()389     ColumnType::thread_instruction_delta::type thread_instruction_delta() const {
390       const auto& col = table()->thread_instruction_delta();
391       return col.GetAtIdx(
392         iterator_.StorageIndexForColumn(col.index_in_table()));
393     }
394 
395    protected:
ConstIterator(const SliceTable * table,Table::Iterator iterator)396     explicit ConstIterator(const SliceTable* table,
397                            Table::Iterator iterator)
398         : AbstractConstIterator(table, std::move(iterator)) {}
399 
CurrentRowNumber()400     uint32_t CurrentRowNumber() const {
401       return iterator_.StorageIndexForLastOverlay();
402     }
403 
404    private:
405     friend class SliceTable;
406     friend class macros_internal::AbstractConstIterator<
407       ConstIterator, SliceTable, RowNumber, ConstRowReference>;
408   };
409   class Iterator : public ConstIterator {
410     public:
row_reference()411      RowReference row_reference() const {
412        return {const_cast<SliceTable*>(table()), CurrentRowNumber()};
413      }
414 
415     private:
416      friend class SliceTable;
417 
Iterator(SliceTable * table,Table::Iterator iterator)418      explicit Iterator(SliceTable* table, Table::Iterator iterator)
419         : ConstIterator(table, std::move(iterator)) {}
420   };
421 
422   struct IdAndRow {
423     Id id;
424     uint32_t row;
425     RowReference row_reference;
426     RowNumber row_number;
427   };
428 
GetColumns(SliceTable * self,const macros_internal::MacroTable * parent)429   static std::vector<ColumnLegacy> GetColumns(
430       SliceTable* self,
431       const macros_internal::MacroTable* parent) {
432     std::vector<ColumnLegacy> columns =
433         CopyColumnsFromParentOrAddRootColumns(self, parent);
434     uint32_t olay_idx = OverlayCount(parent);
435     AddColumnToVector(columns, "ts", &self->ts_, ColumnFlag::ts,
436                       static_cast<uint32_t>(columns.size()), olay_idx);
437     AddColumnToVector(columns, "dur", &self->dur_, ColumnFlag::dur,
438                       static_cast<uint32_t>(columns.size()), olay_idx);
439     AddColumnToVector(columns, "track_id", &self->track_id_, ColumnFlag::track_id,
440                       static_cast<uint32_t>(columns.size()), olay_idx);
441     AddColumnToVector(columns, "category", &self->category_, ColumnFlag::category,
442                       static_cast<uint32_t>(columns.size()), olay_idx);
443     AddColumnToVector(columns, "name", &self->name_, ColumnFlag::name,
444                       static_cast<uint32_t>(columns.size()), olay_idx);
445     AddColumnToVector(columns, "depth", &self->depth_, ColumnFlag::depth,
446                       static_cast<uint32_t>(columns.size()), olay_idx);
447     AddColumnToVector(columns, "stack_id", &self->stack_id_, ColumnFlag::stack_id,
448                       static_cast<uint32_t>(columns.size()), olay_idx);
449     AddColumnToVector(columns, "parent_stack_id", &self->parent_stack_id_, ColumnFlag::parent_stack_id,
450                       static_cast<uint32_t>(columns.size()), olay_idx);
451     AddColumnToVector(columns, "parent_id", &self->parent_id_, ColumnFlag::parent_id,
452                       static_cast<uint32_t>(columns.size()), olay_idx);
453     AddColumnToVector(columns, "arg_set_id", &self->arg_set_id_, ColumnFlag::arg_set_id,
454                       static_cast<uint32_t>(columns.size()), olay_idx);
455     AddColumnToVector(columns, "thread_ts", &self->thread_ts_, ColumnFlag::thread_ts,
456                       static_cast<uint32_t>(columns.size()), olay_idx);
457     AddColumnToVector(columns, "thread_dur", &self->thread_dur_, ColumnFlag::thread_dur,
458                       static_cast<uint32_t>(columns.size()), olay_idx);
459     AddColumnToVector(columns, "thread_instruction_count", &self->thread_instruction_count_, ColumnFlag::thread_instruction_count,
460                       static_cast<uint32_t>(columns.size()), olay_idx);
461     AddColumnToVector(columns, "thread_instruction_delta", &self->thread_instruction_delta_, ColumnFlag::thread_instruction_delta,
462                       static_cast<uint32_t>(columns.size()), olay_idx);
463     return columns;
464   }
465 
SliceTable(StringPool * pool)466   PERFETTO_NO_INLINE explicit SliceTable(StringPool* pool)
467       : macros_internal::MacroTable(
468           pool,
469           GetColumns(this, nullptr),
470           nullptr),
471         ts_(ColumnStorage<ColumnType::ts::stored_type>::Create<false>()),
472         dur_(ColumnStorage<ColumnType::dur::stored_type>::Create<false>()),
473         track_id_(ColumnStorage<ColumnType::track_id::stored_type>::Create<false>()),
474         category_(ColumnStorage<ColumnType::category::stored_type>::Create<false>()),
475         name_(ColumnStorage<ColumnType::name::stored_type>::Create<false>()),
476         depth_(ColumnStorage<ColumnType::depth::stored_type>::Create<false>()),
477         stack_id_(ColumnStorage<ColumnType::stack_id::stored_type>::Create<false>()),
478         parent_stack_id_(ColumnStorage<ColumnType::parent_stack_id::stored_type>::Create<false>()),
479         parent_id_(ColumnStorage<ColumnType::parent_id::stored_type>::Create<false>()),
480         arg_set_id_(ColumnStorage<ColumnType::arg_set_id::stored_type>::Create<false>()),
481         thread_ts_(ColumnStorage<ColumnType::thread_ts::stored_type>::Create<false>()),
482         thread_dur_(ColumnStorage<ColumnType::thread_dur::stored_type>::Create<false>()),
483         thread_instruction_count_(ColumnStorage<ColumnType::thread_instruction_count::stored_type>::Create<false>()),
484         thread_instruction_delta_(ColumnStorage<ColumnType::thread_instruction_delta::stored_type>::Create<false>())
485 ,
486         id_storage_layer_(new column::IdStorage()),
487         type_storage_layer_(
488           new column::StringStorage(string_pool(), &type_.vector())),
489         ts_storage_layer_(
490         new column::NumericStorage<ColumnType::ts::non_optional_stored_type>(
491           &ts_.vector(),
492           ColumnTypeHelper<ColumnType::ts::stored_type>::ToColumnType(),
493           true)),
494         dur_storage_layer_(
495         new column::NumericStorage<ColumnType::dur::non_optional_stored_type>(
496           &dur_.vector(),
497           ColumnTypeHelper<ColumnType::dur::stored_type>::ToColumnType(),
498           false)),
499         track_id_storage_layer_(
500         new column::NumericStorage<ColumnType::track_id::non_optional_stored_type>(
501           &track_id_.vector(),
502           ColumnTypeHelper<ColumnType::track_id::stored_type>::ToColumnType(),
503           false)),
504         category_storage_layer_(
505           new column::StringStorage(string_pool(), &category_.vector())),
506         name_storage_layer_(
507           new column::StringStorage(string_pool(), &name_.vector())),
508         depth_storage_layer_(
509         new column::NumericStorage<ColumnType::depth::non_optional_stored_type>(
510           &depth_.vector(),
511           ColumnTypeHelper<ColumnType::depth::stored_type>::ToColumnType(),
512           false)),
513         stack_id_storage_layer_(
514         new column::NumericStorage<ColumnType::stack_id::non_optional_stored_type>(
515           &stack_id_.vector(),
516           ColumnTypeHelper<ColumnType::stack_id::stored_type>::ToColumnType(),
517           false)),
518         parent_stack_id_storage_layer_(
519         new column::NumericStorage<ColumnType::parent_stack_id::non_optional_stored_type>(
520           &parent_stack_id_.vector(),
521           ColumnTypeHelper<ColumnType::parent_stack_id::stored_type>::ToColumnType(),
522           false)),
523         parent_id_storage_layer_(
524           new column::NumericStorage<ColumnType::parent_id::non_optional_stored_type>(
525             &parent_id_.non_null_vector(),
526             ColumnTypeHelper<ColumnType::parent_id::stored_type>::ToColumnType(),
527             false)),
528         arg_set_id_storage_layer_(
529         new column::NumericStorage<ColumnType::arg_set_id::non_optional_stored_type>(
530           &arg_set_id_.vector(),
531           ColumnTypeHelper<ColumnType::arg_set_id::stored_type>::ToColumnType(),
532           false)),
533         thread_ts_storage_layer_(
534           new column::NumericStorage<ColumnType::thread_ts::non_optional_stored_type>(
535             &thread_ts_.non_null_vector(),
536             ColumnTypeHelper<ColumnType::thread_ts::stored_type>::ToColumnType(),
537             false)),
538         thread_dur_storage_layer_(
539           new column::NumericStorage<ColumnType::thread_dur::non_optional_stored_type>(
540             &thread_dur_.non_null_vector(),
541             ColumnTypeHelper<ColumnType::thread_dur::stored_type>::ToColumnType(),
542             false)),
543         thread_instruction_count_storage_layer_(
544           new column::NumericStorage<ColumnType::thread_instruction_count::non_optional_stored_type>(
545             &thread_instruction_count_.non_null_vector(),
546             ColumnTypeHelper<ColumnType::thread_instruction_count::stored_type>::ToColumnType(),
547             false)),
548         thread_instruction_delta_storage_layer_(
549           new column::NumericStorage<ColumnType::thread_instruction_delta::non_optional_stored_type>(
550             &thread_instruction_delta_.non_null_vector(),
551             ColumnTypeHelper<ColumnType::thread_instruction_delta::stored_type>::ToColumnType(),
552             false))
553 ,
554         parent_id_null_layer_(new column::NullOverlay(parent_id_.bv())),
555         thread_ts_null_layer_(new column::NullOverlay(thread_ts_.bv())),
556         thread_dur_null_layer_(new column::NullOverlay(thread_dur_.bv())),
557         thread_instruction_count_null_layer_(new column::NullOverlay(thread_instruction_count_.bv())),
558         thread_instruction_delta_null_layer_(new column::NullOverlay(thread_instruction_delta_.bv())) {
559     static_assert(
560         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::ts::stored_type>(
561           ColumnFlag::ts),
562         "Column type and flag combination is not valid");
563       static_assert(
564         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::dur::stored_type>(
565           ColumnFlag::dur),
566         "Column type and flag combination is not valid");
567       static_assert(
568         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::track_id::stored_type>(
569           ColumnFlag::track_id),
570         "Column type and flag combination is not valid");
571       static_assert(
572         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::category::stored_type>(
573           ColumnFlag::category),
574         "Column type and flag combination is not valid");
575       static_assert(
576         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::name::stored_type>(
577           ColumnFlag::name),
578         "Column type and flag combination is not valid");
579       static_assert(
580         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::depth::stored_type>(
581           ColumnFlag::depth),
582         "Column type and flag combination is not valid");
583       static_assert(
584         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::stack_id::stored_type>(
585           ColumnFlag::stack_id),
586         "Column type and flag combination is not valid");
587       static_assert(
588         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::parent_stack_id::stored_type>(
589           ColumnFlag::parent_stack_id),
590         "Column type and flag combination is not valid");
591       static_assert(
592         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::parent_id::stored_type>(
593           ColumnFlag::parent_id),
594         "Column type and flag combination is not valid");
595       static_assert(
596         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::arg_set_id::stored_type>(
597           ColumnFlag::arg_set_id),
598         "Column type and flag combination is not valid");
599       static_assert(
600         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::thread_ts::stored_type>(
601           ColumnFlag::thread_ts),
602         "Column type and flag combination is not valid");
603       static_assert(
604         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::thread_dur::stored_type>(
605           ColumnFlag::thread_dur),
606         "Column type and flag combination is not valid");
607       static_assert(
608         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::thread_instruction_count::stored_type>(
609           ColumnFlag::thread_instruction_count),
610         "Column type and flag combination is not valid");
611       static_assert(
612         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::thread_instruction_delta::stored_type>(
613           ColumnFlag::thread_instruction_delta),
614         "Column type and flag combination is not valid");
615     OnConstructionCompletedRegularConstructor(
616       {id_storage_layer_,type_storage_layer_,ts_storage_layer_,dur_storage_layer_,track_id_storage_layer_,category_storage_layer_,name_storage_layer_,depth_storage_layer_,stack_id_storage_layer_,parent_stack_id_storage_layer_,parent_id_storage_layer_,arg_set_id_storage_layer_,thread_ts_storage_layer_,thread_dur_storage_layer_,thread_instruction_count_storage_layer_,thread_instruction_delta_storage_layer_},
617       {{},{},{},{},{},{},{},{},{},{},parent_id_null_layer_,{},thread_ts_null_layer_,thread_dur_null_layer_,thread_instruction_count_null_layer_,thread_instruction_delta_null_layer_});
618   }
619   ~SliceTable() override;
620 
Name()621   static const char* Name() { return "__intrinsic_slice"; }
622 
ComputeStaticSchema()623   static Table::Schema ComputeStaticSchema() {
624     Table::Schema schema;
625     schema.columns.emplace_back(Table::Schema::Column{
626         "id", SqlValue::Type::kLong, true, true, false, false});
627     schema.columns.emplace_back(Table::Schema::Column{
628         "type", SqlValue::Type::kString, false, false, false, false});
629     schema.columns.emplace_back(Table::Schema::Column{
630         "ts", ColumnType::ts::SqlValueType(), false,
631         true,
632         false,
633         false});
634     schema.columns.emplace_back(Table::Schema::Column{
635         "dur", ColumnType::dur::SqlValueType(), false,
636         false,
637         false,
638         false});
639     schema.columns.emplace_back(Table::Schema::Column{
640         "track_id", ColumnType::track_id::SqlValueType(), false,
641         false,
642         false,
643         false});
644     schema.columns.emplace_back(Table::Schema::Column{
645         "category", ColumnType::category::SqlValueType(), false,
646         false,
647         false,
648         false});
649     schema.columns.emplace_back(Table::Schema::Column{
650         "name", ColumnType::name::SqlValueType(), false,
651         false,
652         false,
653         false});
654     schema.columns.emplace_back(Table::Schema::Column{
655         "depth", ColumnType::depth::SqlValueType(), false,
656         false,
657         false,
658         false});
659     schema.columns.emplace_back(Table::Schema::Column{
660         "stack_id", ColumnType::stack_id::SqlValueType(), false,
661         false,
662         false,
663         false});
664     schema.columns.emplace_back(Table::Schema::Column{
665         "parent_stack_id", ColumnType::parent_stack_id::SqlValueType(), false,
666         false,
667         false,
668         false});
669     schema.columns.emplace_back(Table::Schema::Column{
670         "parent_id", ColumnType::parent_id::SqlValueType(), false,
671         false,
672         false,
673         false});
674     schema.columns.emplace_back(Table::Schema::Column{
675         "arg_set_id", ColumnType::arg_set_id::SqlValueType(), false,
676         false,
677         false,
678         false});
679     schema.columns.emplace_back(Table::Schema::Column{
680         "thread_ts", ColumnType::thread_ts::SqlValueType(), false,
681         false,
682         false,
683         false});
684     schema.columns.emplace_back(Table::Schema::Column{
685         "thread_dur", ColumnType::thread_dur::SqlValueType(), false,
686         false,
687         false,
688         false});
689     schema.columns.emplace_back(Table::Schema::Column{
690         "thread_instruction_count", ColumnType::thread_instruction_count::SqlValueType(), false,
691         false,
692         false,
693         false});
694     schema.columns.emplace_back(Table::Schema::Column{
695         "thread_instruction_delta", ColumnType::thread_instruction_delta::SqlValueType(), false,
696         false,
697         false,
698         false});
699     return schema;
700   }
701 
IterateRows()702   ConstIterator IterateRows() const {
703     return ConstIterator(this, Table::IterateRows());
704   }
705 
IterateRows()706   Iterator IterateRows() { return Iterator(this, Table::IterateRows()); }
707 
FilterToIterator(const Query & q)708   ConstIterator FilterToIterator(const Query& q) const {
709     return ConstIterator(this, QueryToIterator(q));
710   }
711 
FilterToIterator(const Query & q)712   Iterator FilterToIterator(const Query& q) {
713     return Iterator(this, QueryToIterator(q));
714   }
715 
ShrinkToFit()716   void ShrinkToFit() {
717     type_.ShrinkToFit();
718     ts_.ShrinkToFit();
719     dur_.ShrinkToFit();
720     track_id_.ShrinkToFit();
721     category_.ShrinkToFit();
722     name_.ShrinkToFit();
723     depth_.ShrinkToFit();
724     stack_id_.ShrinkToFit();
725     parent_stack_id_.ShrinkToFit();
726     parent_id_.ShrinkToFit();
727     arg_set_id_.ShrinkToFit();
728     thread_ts_.ShrinkToFit();
729     thread_dur_.ShrinkToFit();
730     thread_instruction_count_.ShrinkToFit();
731     thread_instruction_delta_.ShrinkToFit();
732   }
733 
734   ConstRowReference operator[](uint32_t r) const {
735     return ConstRowReference(this, r);
736   }
737   RowReference operator[](uint32_t r) { return RowReference(this, r); }
738   ConstRowReference operator[](RowNumber r) const {
739     return ConstRowReference(this, r.row_number());
740   }
741   RowReference operator[](RowNumber r) {
742     return RowReference(this, r.row_number());
743   }
744 
FindById(Id find_id)745   std::optional<ConstRowReference> FindById(Id find_id) const {
746     std::optional<uint32_t> row = id().IndexOf(find_id);
747     return row ? std::make_optional(ConstRowReference(this, *row))
748                : std::nullopt;
749   }
750 
FindById(Id find_id)751   std::optional<RowReference> FindById(Id find_id) {
752     std::optional<uint32_t> row = id().IndexOf(find_id);
753     return row ? std::make_optional(RowReference(this, *row)) : std::nullopt;
754   }
755 
Insert(const Row & row)756   IdAndRow Insert(const Row& row) {
757     uint32_t row_number = row_count();
758     Id id = Id{row_number};
759     type_.Append(string_pool()->InternString(row.type()));
760     mutable_ts()->Append(row.ts);
761     mutable_dur()->Append(row.dur);
762     mutable_track_id()->Append(row.track_id);
763     mutable_category()->Append(row.category);
764     mutable_name()->Append(row.name);
765     mutable_depth()->Append(row.depth);
766     mutable_stack_id()->Append(row.stack_id);
767     mutable_parent_stack_id()->Append(row.parent_stack_id);
768     mutable_parent_id()->Append(row.parent_id);
769     mutable_arg_set_id()->Append(row.arg_set_id);
770     mutable_thread_ts()->Append(row.thread_ts);
771     mutable_thread_dur()->Append(row.thread_dur);
772     mutable_thread_instruction_count()->Append(row.thread_instruction_count);
773     mutable_thread_instruction_delta()->Append(row.thread_instruction_delta);
774     UpdateSelfOverlayAfterInsert();
775     return IdAndRow{id, row_number, RowReference(this, row_number),
776                      RowNumber(row_number)};
777   }
778 
779 
780 
id()781   const IdColumn<SliceTable::Id>& id() const {
782     return static_cast<const ColumnType::id&>(columns()[ColumnIndex::id]);
783   }
type()784   const TypedColumn<StringPool::Id>& type() const {
785     return static_cast<const ColumnType::type&>(columns()[ColumnIndex::type]);
786   }
ts()787   const TypedColumn<int64_t>& ts() const {
788     return static_cast<const ColumnType::ts&>(columns()[ColumnIndex::ts]);
789   }
dur()790   const TypedColumn<int64_t>& dur() const {
791     return static_cast<const ColumnType::dur&>(columns()[ColumnIndex::dur]);
792   }
track_id()793   const TypedColumn<TrackTable::Id>& track_id() const {
794     return static_cast<const ColumnType::track_id&>(columns()[ColumnIndex::track_id]);
795   }
category()796   const TypedColumn<std::optional<StringPool::Id>>& category() const {
797     return static_cast<const ColumnType::category&>(columns()[ColumnIndex::category]);
798   }
name()799   const TypedColumn<std::optional<StringPool::Id>>& name() const {
800     return static_cast<const ColumnType::name&>(columns()[ColumnIndex::name]);
801   }
depth()802   const TypedColumn<uint32_t>& depth() const {
803     return static_cast<const ColumnType::depth&>(columns()[ColumnIndex::depth]);
804   }
stack_id()805   const TypedColumn<int64_t>& stack_id() const {
806     return static_cast<const ColumnType::stack_id&>(columns()[ColumnIndex::stack_id]);
807   }
parent_stack_id()808   const TypedColumn<int64_t>& parent_stack_id() const {
809     return static_cast<const ColumnType::parent_stack_id&>(columns()[ColumnIndex::parent_stack_id]);
810   }
parent_id()811   const TypedColumn<std::optional<SliceTable::Id>>& parent_id() const {
812     return static_cast<const ColumnType::parent_id&>(columns()[ColumnIndex::parent_id]);
813   }
arg_set_id()814   const TypedColumn<uint32_t>& arg_set_id() const {
815     return static_cast<const ColumnType::arg_set_id&>(columns()[ColumnIndex::arg_set_id]);
816   }
thread_ts()817   const TypedColumn<std::optional<int64_t>>& thread_ts() const {
818     return static_cast<const ColumnType::thread_ts&>(columns()[ColumnIndex::thread_ts]);
819   }
thread_dur()820   const TypedColumn<std::optional<int64_t>>& thread_dur() const {
821     return static_cast<const ColumnType::thread_dur&>(columns()[ColumnIndex::thread_dur]);
822   }
thread_instruction_count()823   const TypedColumn<std::optional<int64_t>>& thread_instruction_count() const {
824     return static_cast<const ColumnType::thread_instruction_count&>(columns()[ColumnIndex::thread_instruction_count]);
825   }
thread_instruction_delta()826   const TypedColumn<std::optional<int64_t>>& thread_instruction_delta() const {
827     return static_cast<const ColumnType::thread_instruction_delta&>(columns()[ColumnIndex::thread_instruction_delta]);
828   }
829 
mutable_ts()830   TypedColumn<int64_t>* mutable_ts() {
831     return static_cast<ColumnType::ts*>(
832         GetColumn(ColumnIndex::ts));
833   }
mutable_dur()834   TypedColumn<int64_t>* mutable_dur() {
835     return static_cast<ColumnType::dur*>(
836         GetColumn(ColumnIndex::dur));
837   }
mutable_track_id()838   TypedColumn<TrackTable::Id>* mutable_track_id() {
839     return static_cast<ColumnType::track_id*>(
840         GetColumn(ColumnIndex::track_id));
841   }
mutable_category()842   TypedColumn<std::optional<StringPool::Id>>* mutable_category() {
843     return static_cast<ColumnType::category*>(
844         GetColumn(ColumnIndex::category));
845   }
mutable_name()846   TypedColumn<std::optional<StringPool::Id>>* mutable_name() {
847     return static_cast<ColumnType::name*>(
848         GetColumn(ColumnIndex::name));
849   }
mutable_depth()850   TypedColumn<uint32_t>* mutable_depth() {
851     return static_cast<ColumnType::depth*>(
852         GetColumn(ColumnIndex::depth));
853   }
mutable_stack_id()854   TypedColumn<int64_t>* mutable_stack_id() {
855     return static_cast<ColumnType::stack_id*>(
856         GetColumn(ColumnIndex::stack_id));
857   }
mutable_parent_stack_id()858   TypedColumn<int64_t>* mutable_parent_stack_id() {
859     return static_cast<ColumnType::parent_stack_id*>(
860         GetColumn(ColumnIndex::parent_stack_id));
861   }
mutable_parent_id()862   TypedColumn<std::optional<SliceTable::Id>>* mutable_parent_id() {
863     return static_cast<ColumnType::parent_id*>(
864         GetColumn(ColumnIndex::parent_id));
865   }
mutable_arg_set_id()866   TypedColumn<uint32_t>* mutable_arg_set_id() {
867     return static_cast<ColumnType::arg_set_id*>(
868         GetColumn(ColumnIndex::arg_set_id));
869   }
mutable_thread_ts()870   TypedColumn<std::optional<int64_t>>* mutable_thread_ts() {
871     return static_cast<ColumnType::thread_ts*>(
872         GetColumn(ColumnIndex::thread_ts));
873   }
mutable_thread_dur()874   TypedColumn<std::optional<int64_t>>* mutable_thread_dur() {
875     return static_cast<ColumnType::thread_dur*>(
876         GetColumn(ColumnIndex::thread_dur));
877   }
mutable_thread_instruction_count()878   TypedColumn<std::optional<int64_t>>* mutable_thread_instruction_count() {
879     return static_cast<ColumnType::thread_instruction_count*>(
880         GetColumn(ColumnIndex::thread_instruction_count));
881   }
mutable_thread_instruction_delta()882   TypedColumn<std::optional<int64_t>>* mutable_thread_instruction_delta() {
883     return static_cast<ColumnType::thread_instruction_delta*>(
884         GetColumn(ColumnIndex::thread_instruction_delta));
885   }
886 
887  private:
888 
889 
890   ColumnStorage<ColumnType::ts::stored_type> ts_;
891   ColumnStorage<ColumnType::dur::stored_type> dur_;
892   ColumnStorage<ColumnType::track_id::stored_type> track_id_;
893   ColumnStorage<ColumnType::category::stored_type> category_;
894   ColumnStorage<ColumnType::name::stored_type> name_;
895   ColumnStorage<ColumnType::depth::stored_type> depth_;
896   ColumnStorage<ColumnType::stack_id::stored_type> stack_id_;
897   ColumnStorage<ColumnType::parent_stack_id::stored_type> parent_stack_id_;
898   ColumnStorage<ColumnType::parent_id::stored_type> parent_id_;
899   ColumnStorage<ColumnType::arg_set_id::stored_type> arg_set_id_;
900   ColumnStorage<ColumnType::thread_ts::stored_type> thread_ts_;
901   ColumnStorage<ColumnType::thread_dur::stored_type> thread_dur_;
902   ColumnStorage<ColumnType::thread_instruction_count::stored_type> thread_instruction_count_;
903   ColumnStorage<ColumnType::thread_instruction_delta::stored_type> thread_instruction_delta_;
904 
905   RefPtr<column::StorageLayer> id_storage_layer_;
906   RefPtr<column::StorageLayer> type_storage_layer_;
907   RefPtr<column::StorageLayer> ts_storage_layer_;
908   RefPtr<column::StorageLayer> dur_storage_layer_;
909   RefPtr<column::StorageLayer> track_id_storage_layer_;
910   RefPtr<column::StorageLayer> category_storage_layer_;
911   RefPtr<column::StorageLayer> name_storage_layer_;
912   RefPtr<column::StorageLayer> depth_storage_layer_;
913   RefPtr<column::StorageLayer> stack_id_storage_layer_;
914   RefPtr<column::StorageLayer> parent_stack_id_storage_layer_;
915   RefPtr<column::StorageLayer> parent_id_storage_layer_;
916   RefPtr<column::StorageLayer> arg_set_id_storage_layer_;
917   RefPtr<column::StorageLayer> thread_ts_storage_layer_;
918   RefPtr<column::StorageLayer> thread_dur_storage_layer_;
919   RefPtr<column::StorageLayer> thread_instruction_count_storage_layer_;
920   RefPtr<column::StorageLayer> thread_instruction_delta_storage_layer_;
921 
922   RefPtr<column::OverlayLayer> parent_id_null_layer_;
923   RefPtr<column::OverlayLayer> thread_ts_null_layer_;
924   RefPtr<column::OverlayLayer> thread_dur_null_layer_;
925   RefPtr<column::OverlayLayer> thread_instruction_count_null_layer_;
926   RefPtr<column::OverlayLayer> thread_instruction_delta_null_layer_;
927 };
928 
929 
930 class ActualFrameTimelineSliceTable : public macros_internal::MacroTable {
931  public:
932   static constexpr uint32_t kColumnCount = 27;
933 
934   using Id = SliceTable::Id;
935 
936   struct ColumnIndex {
937     static constexpr uint32_t id = 0;
938     static constexpr uint32_t type = 1;
939     static constexpr uint32_t ts = 2;
940     static constexpr uint32_t dur = 3;
941     static constexpr uint32_t track_id = 4;
942     static constexpr uint32_t category = 5;
943     static constexpr uint32_t name = 6;
944     static constexpr uint32_t depth = 7;
945     static constexpr uint32_t stack_id = 8;
946     static constexpr uint32_t parent_stack_id = 9;
947     static constexpr uint32_t parent_id = 10;
948     static constexpr uint32_t arg_set_id = 11;
949     static constexpr uint32_t thread_ts = 12;
950     static constexpr uint32_t thread_dur = 13;
951     static constexpr uint32_t thread_instruction_count = 14;
952     static constexpr uint32_t thread_instruction_delta = 15;
953     static constexpr uint32_t display_frame_token = 16;
954     static constexpr uint32_t surface_frame_token = 17;
955     static constexpr uint32_t upid = 18;
956     static constexpr uint32_t layer_name = 19;
957     static constexpr uint32_t present_type = 20;
958     static constexpr uint32_t on_time_finish = 21;
959     static constexpr uint32_t gpu_composition = 22;
960     static constexpr uint32_t jank_type = 23;
961     static constexpr uint32_t jank_severity_type = 24;
962     static constexpr uint32_t prediction_type = 25;
963     static constexpr uint32_t jank_tag = 26;
964   };
965   struct ColumnType {
966     using id = IdColumn<ActualFrameTimelineSliceTable::Id>;
967     using type = TypedColumn<StringPool::Id>;
968     using ts = TypedColumn<int64_t>;
969     using dur = TypedColumn<int64_t>;
970     using track_id = TypedColumn<TrackTable::Id>;
971     using category = TypedColumn<std::optional<StringPool::Id>>;
972     using name = TypedColumn<std::optional<StringPool::Id>>;
973     using depth = TypedColumn<uint32_t>;
974     using stack_id = TypedColumn<int64_t>;
975     using parent_stack_id = TypedColumn<int64_t>;
976     using parent_id = TypedColumn<std::optional<ActualFrameTimelineSliceTable::Id>>;
977     using arg_set_id = TypedColumn<uint32_t>;
978     using thread_ts = TypedColumn<std::optional<int64_t>>;
979     using thread_dur = TypedColumn<std::optional<int64_t>>;
980     using thread_instruction_count = TypedColumn<std::optional<int64_t>>;
981     using thread_instruction_delta = TypedColumn<std::optional<int64_t>>;
982     using display_frame_token = TypedColumn<int64_t>;
983     using surface_frame_token = TypedColumn<int64_t>;
984     using upid = TypedColumn<uint32_t>;
985     using layer_name = TypedColumn<StringPool::Id>;
986     using present_type = TypedColumn<StringPool::Id>;
987     using on_time_finish = TypedColumn<int32_t>;
988     using gpu_composition = TypedColumn<int32_t>;
989     using jank_type = TypedColumn<StringPool::Id>;
990     using jank_severity_type = TypedColumn<StringPool::Id>;
991     using prediction_type = TypedColumn<StringPool::Id>;
992     using jank_tag = TypedColumn<StringPool::Id>;
993   };
994   struct Row : public SliceTable::Row {
995     Row(int64_t in_ts = {},
996         int64_t in_dur = {},
997         TrackTable::Id in_track_id = {},
998         std::optional<StringPool::Id> in_category = {},
999         std::optional<StringPool::Id> in_name = {},
1000         uint32_t in_depth = {},
1001         int64_t in_stack_id = {},
1002         int64_t in_parent_stack_id = {},
1003         std::optional<ActualFrameTimelineSliceTable::Id> in_parent_id = {},
1004         uint32_t in_arg_set_id = {},
1005         std::optional<int64_t> in_thread_ts = {},
1006         std::optional<int64_t> in_thread_dur = {},
1007         std::optional<int64_t> in_thread_instruction_count = {},
1008         std::optional<int64_t> in_thread_instruction_delta = {},
1009         int64_t in_display_frame_token = {},
1010         int64_t in_surface_frame_token = {},
1011         uint32_t in_upid = {},
1012         StringPool::Id in_layer_name = {},
1013         StringPool::Id in_present_type = {},
1014         int32_t in_on_time_finish = {},
1015         int32_t in_gpu_composition = {},
1016         StringPool::Id in_jank_type = {},
1017         StringPool::Id in_jank_severity_type = {},
1018         StringPool::Id in_prediction_type = {},
1019         StringPool::Id in_jank_tag = {},
1020         std::nullptr_t = nullptr)
RowRow1021         : SliceTable::Row(in_ts, in_dur, in_track_id, in_category, in_name, in_depth, in_stack_id, in_parent_stack_id, in_parent_id, in_arg_set_id, in_thread_ts, in_thread_dur, in_thread_instruction_count, in_thread_instruction_delta),
1022           display_frame_token(in_display_frame_token),
1023           surface_frame_token(in_surface_frame_token),
1024           upid(in_upid),
1025           layer_name(in_layer_name),
1026           present_type(in_present_type),
1027           on_time_finish(in_on_time_finish),
1028           gpu_composition(in_gpu_composition),
1029           jank_type(in_jank_type),
1030           jank_severity_type(in_jank_severity_type),
1031           prediction_type(in_prediction_type),
1032           jank_tag(in_jank_tag) {
1033       type_ = "actual_frame_timeline_slice";
1034     }
1035     int64_t display_frame_token;
1036     int64_t surface_frame_token;
1037     uint32_t upid;
1038     StringPool::Id layer_name;
1039     StringPool::Id present_type;
1040     int32_t on_time_finish;
1041     int32_t gpu_composition;
1042     StringPool::Id jank_type;
1043     StringPool::Id jank_severity_type;
1044     StringPool::Id prediction_type;
1045     StringPool::Id jank_tag;
1046 
1047     bool operator==(const ActualFrameTimelineSliceTable::Row& other) const {
1048       return type() == other.type() && ColumnType::ts::Equals(ts, other.ts) &&
1049        ColumnType::dur::Equals(dur, other.dur) &&
1050        ColumnType::track_id::Equals(track_id, other.track_id) &&
1051        ColumnType::category::Equals(category, other.category) &&
1052        ColumnType::name::Equals(name, other.name) &&
1053        ColumnType::depth::Equals(depth, other.depth) &&
1054        ColumnType::stack_id::Equals(stack_id, other.stack_id) &&
1055        ColumnType::parent_stack_id::Equals(parent_stack_id, other.parent_stack_id) &&
1056        ColumnType::parent_id::Equals(parent_id, other.parent_id) &&
1057        ColumnType::arg_set_id::Equals(arg_set_id, other.arg_set_id) &&
1058        ColumnType::thread_ts::Equals(thread_ts, other.thread_ts) &&
1059        ColumnType::thread_dur::Equals(thread_dur, other.thread_dur) &&
1060        ColumnType::thread_instruction_count::Equals(thread_instruction_count, other.thread_instruction_count) &&
1061        ColumnType::thread_instruction_delta::Equals(thread_instruction_delta, other.thread_instruction_delta) &&
1062        ColumnType::display_frame_token::Equals(display_frame_token, other.display_frame_token) &&
1063        ColumnType::surface_frame_token::Equals(surface_frame_token, other.surface_frame_token) &&
1064        ColumnType::upid::Equals(upid, other.upid) &&
1065        ColumnType::layer_name::Equals(layer_name, other.layer_name) &&
1066        ColumnType::present_type::Equals(present_type, other.present_type) &&
1067        ColumnType::on_time_finish::Equals(on_time_finish, other.on_time_finish) &&
1068        ColumnType::gpu_composition::Equals(gpu_composition, other.gpu_composition) &&
1069        ColumnType::jank_type::Equals(jank_type, other.jank_type) &&
1070        ColumnType::jank_severity_type::Equals(jank_severity_type, other.jank_severity_type) &&
1071        ColumnType::prediction_type::Equals(prediction_type, other.prediction_type) &&
1072        ColumnType::jank_tag::Equals(jank_tag, other.jank_tag);
1073     }
1074   };
1075   struct ColumnFlag {
1076     static constexpr uint32_t display_frame_token = ColumnType::display_frame_token::default_flags();
1077     static constexpr uint32_t surface_frame_token = ColumnType::surface_frame_token::default_flags();
1078     static constexpr uint32_t upid = ColumnType::upid::default_flags();
1079     static constexpr uint32_t layer_name = ColumnType::layer_name::default_flags();
1080     static constexpr uint32_t present_type = ColumnType::present_type::default_flags();
1081     static constexpr uint32_t on_time_finish = ColumnType::on_time_finish::default_flags();
1082     static constexpr uint32_t gpu_composition = ColumnType::gpu_composition::default_flags();
1083     static constexpr uint32_t jank_type = ColumnType::jank_type::default_flags();
1084     static constexpr uint32_t jank_severity_type = ColumnType::jank_severity_type::default_flags();
1085     static constexpr uint32_t prediction_type = ColumnType::prediction_type::default_flags();
1086     static constexpr uint32_t jank_tag = ColumnType::jank_tag::default_flags();
1087   };
1088 
1089   class RowNumber;
1090   class ConstRowReference;
1091   class RowReference;
1092 
1093   class RowNumber : public macros_internal::AbstractRowNumber<
1094       ActualFrameTimelineSliceTable, ConstRowReference, RowReference> {
1095    public:
RowNumber(uint32_t row_number)1096     explicit RowNumber(uint32_t row_number)
1097         : AbstractRowNumber(row_number) {}
1098   };
1099   static_assert(std::is_trivially_destructible_v<RowNumber>,
1100                 "Inheritance used without trivial destruction");
1101 
1102   class ConstRowReference : public macros_internal::AbstractConstRowReference<
1103     ActualFrameTimelineSliceTable, RowNumber> {
1104    public:
ConstRowReference(const ActualFrameTimelineSliceTable * table,uint32_t row_number)1105     ConstRowReference(const ActualFrameTimelineSliceTable* table, uint32_t row_number)
1106         : AbstractConstRowReference(table, row_number) {}
1107 
id()1108     ColumnType::id::type id() const {
1109       return table()->id()[row_number_];
1110     }
type()1111     ColumnType::type::type type() const {
1112       return table()->type()[row_number_];
1113     }
ts()1114     ColumnType::ts::type ts() const {
1115       return table()->ts()[row_number_];
1116     }
dur()1117     ColumnType::dur::type dur() const {
1118       return table()->dur()[row_number_];
1119     }
track_id()1120     ColumnType::track_id::type track_id() const {
1121       return table()->track_id()[row_number_];
1122     }
category()1123     ColumnType::category::type category() const {
1124       return table()->category()[row_number_];
1125     }
name()1126     ColumnType::name::type name() const {
1127       return table()->name()[row_number_];
1128     }
depth()1129     ColumnType::depth::type depth() const {
1130       return table()->depth()[row_number_];
1131     }
stack_id()1132     ColumnType::stack_id::type stack_id() const {
1133       return table()->stack_id()[row_number_];
1134     }
parent_stack_id()1135     ColumnType::parent_stack_id::type parent_stack_id() const {
1136       return table()->parent_stack_id()[row_number_];
1137     }
parent_id()1138     ColumnType::parent_id::type parent_id() const {
1139       return table()->parent_id()[row_number_];
1140     }
arg_set_id()1141     ColumnType::arg_set_id::type arg_set_id() const {
1142       return table()->arg_set_id()[row_number_];
1143     }
thread_ts()1144     ColumnType::thread_ts::type thread_ts() const {
1145       return table()->thread_ts()[row_number_];
1146     }
thread_dur()1147     ColumnType::thread_dur::type thread_dur() const {
1148       return table()->thread_dur()[row_number_];
1149     }
thread_instruction_count()1150     ColumnType::thread_instruction_count::type thread_instruction_count() const {
1151       return table()->thread_instruction_count()[row_number_];
1152     }
thread_instruction_delta()1153     ColumnType::thread_instruction_delta::type thread_instruction_delta() const {
1154       return table()->thread_instruction_delta()[row_number_];
1155     }
display_frame_token()1156     ColumnType::display_frame_token::type display_frame_token() const {
1157       return table()->display_frame_token()[row_number_];
1158     }
surface_frame_token()1159     ColumnType::surface_frame_token::type surface_frame_token() const {
1160       return table()->surface_frame_token()[row_number_];
1161     }
upid()1162     ColumnType::upid::type upid() const {
1163       return table()->upid()[row_number_];
1164     }
layer_name()1165     ColumnType::layer_name::type layer_name() const {
1166       return table()->layer_name()[row_number_];
1167     }
present_type()1168     ColumnType::present_type::type present_type() const {
1169       return table()->present_type()[row_number_];
1170     }
on_time_finish()1171     ColumnType::on_time_finish::type on_time_finish() const {
1172       return table()->on_time_finish()[row_number_];
1173     }
gpu_composition()1174     ColumnType::gpu_composition::type gpu_composition() const {
1175       return table()->gpu_composition()[row_number_];
1176     }
jank_type()1177     ColumnType::jank_type::type jank_type() const {
1178       return table()->jank_type()[row_number_];
1179     }
jank_severity_type()1180     ColumnType::jank_severity_type::type jank_severity_type() const {
1181       return table()->jank_severity_type()[row_number_];
1182     }
prediction_type()1183     ColumnType::prediction_type::type prediction_type() const {
1184       return table()->prediction_type()[row_number_];
1185     }
jank_tag()1186     ColumnType::jank_tag::type jank_tag() const {
1187       return table()->jank_tag()[row_number_];
1188     }
1189   };
1190   static_assert(std::is_trivially_destructible_v<ConstRowReference>,
1191                 "Inheritance used without trivial destruction");
1192   class RowReference : public ConstRowReference {
1193    public:
RowReference(const ActualFrameTimelineSliceTable * table,uint32_t row_number)1194     RowReference(const ActualFrameTimelineSliceTable* table, uint32_t row_number)
1195         : ConstRowReference(table, row_number) {}
1196 
set_ts(ColumnType::ts::non_optional_type v)1197     void set_ts(
1198         ColumnType::ts::non_optional_type v) {
1199       return mutable_table()->mutable_ts()->Set(row_number_, v);
1200     }
set_dur(ColumnType::dur::non_optional_type v)1201     void set_dur(
1202         ColumnType::dur::non_optional_type v) {
1203       return mutable_table()->mutable_dur()->Set(row_number_, v);
1204     }
set_track_id(ColumnType::track_id::non_optional_type v)1205     void set_track_id(
1206         ColumnType::track_id::non_optional_type v) {
1207       return mutable_table()->mutable_track_id()->Set(row_number_, v);
1208     }
set_category(ColumnType::category::non_optional_type v)1209     void set_category(
1210         ColumnType::category::non_optional_type v) {
1211       return mutable_table()->mutable_category()->Set(row_number_, v);
1212     }
set_name(ColumnType::name::non_optional_type v)1213     void set_name(
1214         ColumnType::name::non_optional_type v) {
1215       return mutable_table()->mutable_name()->Set(row_number_, v);
1216     }
set_depth(ColumnType::depth::non_optional_type v)1217     void set_depth(
1218         ColumnType::depth::non_optional_type v) {
1219       return mutable_table()->mutable_depth()->Set(row_number_, v);
1220     }
set_stack_id(ColumnType::stack_id::non_optional_type v)1221     void set_stack_id(
1222         ColumnType::stack_id::non_optional_type v) {
1223       return mutable_table()->mutable_stack_id()->Set(row_number_, v);
1224     }
set_parent_stack_id(ColumnType::parent_stack_id::non_optional_type v)1225     void set_parent_stack_id(
1226         ColumnType::parent_stack_id::non_optional_type v) {
1227       return mutable_table()->mutable_parent_stack_id()->Set(row_number_, v);
1228     }
set_parent_id(ColumnType::parent_id::non_optional_type v)1229     void set_parent_id(
1230         ColumnType::parent_id::non_optional_type v) {
1231       return mutable_table()->mutable_parent_id()->Set(row_number_, v);
1232     }
set_arg_set_id(ColumnType::arg_set_id::non_optional_type v)1233     void set_arg_set_id(
1234         ColumnType::arg_set_id::non_optional_type v) {
1235       return mutable_table()->mutable_arg_set_id()->Set(row_number_, v);
1236     }
set_thread_ts(ColumnType::thread_ts::non_optional_type v)1237     void set_thread_ts(
1238         ColumnType::thread_ts::non_optional_type v) {
1239       return mutable_table()->mutable_thread_ts()->Set(row_number_, v);
1240     }
set_thread_dur(ColumnType::thread_dur::non_optional_type v)1241     void set_thread_dur(
1242         ColumnType::thread_dur::non_optional_type v) {
1243       return mutable_table()->mutable_thread_dur()->Set(row_number_, v);
1244     }
set_thread_instruction_count(ColumnType::thread_instruction_count::non_optional_type v)1245     void set_thread_instruction_count(
1246         ColumnType::thread_instruction_count::non_optional_type v) {
1247       return mutable_table()->mutable_thread_instruction_count()->Set(row_number_, v);
1248     }
set_thread_instruction_delta(ColumnType::thread_instruction_delta::non_optional_type v)1249     void set_thread_instruction_delta(
1250         ColumnType::thread_instruction_delta::non_optional_type v) {
1251       return mutable_table()->mutable_thread_instruction_delta()->Set(row_number_, v);
1252     }
set_display_frame_token(ColumnType::display_frame_token::non_optional_type v)1253     void set_display_frame_token(
1254         ColumnType::display_frame_token::non_optional_type v) {
1255       return mutable_table()->mutable_display_frame_token()->Set(row_number_, v);
1256     }
set_surface_frame_token(ColumnType::surface_frame_token::non_optional_type v)1257     void set_surface_frame_token(
1258         ColumnType::surface_frame_token::non_optional_type v) {
1259       return mutable_table()->mutable_surface_frame_token()->Set(row_number_, v);
1260     }
set_upid(ColumnType::upid::non_optional_type v)1261     void set_upid(
1262         ColumnType::upid::non_optional_type v) {
1263       return mutable_table()->mutable_upid()->Set(row_number_, v);
1264     }
set_layer_name(ColumnType::layer_name::non_optional_type v)1265     void set_layer_name(
1266         ColumnType::layer_name::non_optional_type v) {
1267       return mutable_table()->mutable_layer_name()->Set(row_number_, v);
1268     }
set_present_type(ColumnType::present_type::non_optional_type v)1269     void set_present_type(
1270         ColumnType::present_type::non_optional_type v) {
1271       return mutable_table()->mutable_present_type()->Set(row_number_, v);
1272     }
set_on_time_finish(ColumnType::on_time_finish::non_optional_type v)1273     void set_on_time_finish(
1274         ColumnType::on_time_finish::non_optional_type v) {
1275       return mutable_table()->mutable_on_time_finish()->Set(row_number_, v);
1276     }
set_gpu_composition(ColumnType::gpu_composition::non_optional_type v)1277     void set_gpu_composition(
1278         ColumnType::gpu_composition::non_optional_type v) {
1279       return mutable_table()->mutable_gpu_composition()->Set(row_number_, v);
1280     }
set_jank_type(ColumnType::jank_type::non_optional_type v)1281     void set_jank_type(
1282         ColumnType::jank_type::non_optional_type v) {
1283       return mutable_table()->mutable_jank_type()->Set(row_number_, v);
1284     }
set_jank_severity_type(ColumnType::jank_severity_type::non_optional_type v)1285     void set_jank_severity_type(
1286         ColumnType::jank_severity_type::non_optional_type v) {
1287       return mutable_table()->mutable_jank_severity_type()->Set(row_number_, v);
1288     }
set_prediction_type(ColumnType::prediction_type::non_optional_type v)1289     void set_prediction_type(
1290         ColumnType::prediction_type::non_optional_type v) {
1291       return mutable_table()->mutable_prediction_type()->Set(row_number_, v);
1292     }
set_jank_tag(ColumnType::jank_tag::non_optional_type v)1293     void set_jank_tag(
1294         ColumnType::jank_tag::non_optional_type v) {
1295       return mutable_table()->mutable_jank_tag()->Set(row_number_, v);
1296     }
1297 
1298    private:
mutable_table()1299     ActualFrameTimelineSliceTable* mutable_table() const {
1300       return const_cast<ActualFrameTimelineSliceTable*>(table());
1301     }
1302   };
1303   static_assert(std::is_trivially_destructible_v<RowReference>,
1304                 "Inheritance used without trivial destruction");
1305 
1306   class ConstIterator;
1307   class ConstIterator : public macros_internal::AbstractConstIterator<
1308     ConstIterator, ActualFrameTimelineSliceTable, RowNumber, ConstRowReference> {
1309    public:
id()1310     ColumnType::id::type id() const {
1311       const auto& col = table()->id();
1312       return col.GetAtIdx(
1313         iterator_.StorageIndexForColumn(col.index_in_table()));
1314     }
type()1315     ColumnType::type::type type() const {
1316       const auto& col = table()->type();
1317       return col.GetAtIdx(
1318         iterator_.StorageIndexForColumn(col.index_in_table()));
1319     }
ts()1320     ColumnType::ts::type ts() const {
1321       const auto& col = table()->ts();
1322       return col.GetAtIdx(
1323         iterator_.StorageIndexForColumn(col.index_in_table()));
1324     }
dur()1325     ColumnType::dur::type dur() const {
1326       const auto& col = table()->dur();
1327       return col.GetAtIdx(
1328         iterator_.StorageIndexForColumn(col.index_in_table()));
1329     }
track_id()1330     ColumnType::track_id::type track_id() const {
1331       const auto& col = table()->track_id();
1332       return col.GetAtIdx(
1333         iterator_.StorageIndexForColumn(col.index_in_table()));
1334     }
category()1335     ColumnType::category::type category() const {
1336       const auto& col = table()->category();
1337       return col.GetAtIdx(
1338         iterator_.StorageIndexForColumn(col.index_in_table()));
1339     }
name()1340     ColumnType::name::type name() const {
1341       const auto& col = table()->name();
1342       return col.GetAtIdx(
1343         iterator_.StorageIndexForColumn(col.index_in_table()));
1344     }
depth()1345     ColumnType::depth::type depth() const {
1346       const auto& col = table()->depth();
1347       return col.GetAtIdx(
1348         iterator_.StorageIndexForColumn(col.index_in_table()));
1349     }
stack_id()1350     ColumnType::stack_id::type stack_id() const {
1351       const auto& col = table()->stack_id();
1352       return col.GetAtIdx(
1353         iterator_.StorageIndexForColumn(col.index_in_table()));
1354     }
parent_stack_id()1355     ColumnType::parent_stack_id::type parent_stack_id() const {
1356       const auto& col = table()->parent_stack_id();
1357       return col.GetAtIdx(
1358         iterator_.StorageIndexForColumn(col.index_in_table()));
1359     }
parent_id()1360     ColumnType::parent_id::type parent_id() const {
1361       const auto& col = table()->parent_id();
1362       return col.GetAtIdx(
1363         iterator_.StorageIndexForColumn(col.index_in_table()));
1364     }
arg_set_id()1365     ColumnType::arg_set_id::type arg_set_id() const {
1366       const auto& col = table()->arg_set_id();
1367       return col.GetAtIdx(
1368         iterator_.StorageIndexForColumn(col.index_in_table()));
1369     }
thread_ts()1370     ColumnType::thread_ts::type thread_ts() const {
1371       const auto& col = table()->thread_ts();
1372       return col.GetAtIdx(
1373         iterator_.StorageIndexForColumn(col.index_in_table()));
1374     }
thread_dur()1375     ColumnType::thread_dur::type thread_dur() const {
1376       const auto& col = table()->thread_dur();
1377       return col.GetAtIdx(
1378         iterator_.StorageIndexForColumn(col.index_in_table()));
1379     }
thread_instruction_count()1380     ColumnType::thread_instruction_count::type thread_instruction_count() const {
1381       const auto& col = table()->thread_instruction_count();
1382       return col.GetAtIdx(
1383         iterator_.StorageIndexForColumn(col.index_in_table()));
1384     }
thread_instruction_delta()1385     ColumnType::thread_instruction_delta::type thread_instruction_delta() const {
1386       const auto& col = table()->thread_instruction_delta();
1387       return col.GetAtIdx(
1388         iterator_.StorageIndexForColumn(col.index_in_table()));
1389     }
display_frame_token()1390     ColumnType::display_frame_token::type display_frame_token() const {
1391       const auto& col = table()->display_frame_token();
1392       return col.GetAtIdx(
1393         iterator_.StorageIndexForColumn(col.index_in_table()));
1394     }
surface_frame_token()1395     ColumnType::surface_frame_token::type surface_frame_token() const {
1396       const auto& col = table()->surface_frame_token();
1397       return col.GetAtIdx(
1398         iterator_.StorageIndexForColumn(col.index_in_table()));
1399     }
upid()1400     ColumnType::upid::type upid() const {
1401       const auto& col = table()->upid();
1402       return col.GetAtIdx(
1403         iterator_.StorageIndexForColumn(col.index_in_table()));
1404     }
layer_name()1405     ColumnType::layer_name::type layer_name() const {
1406       const auto& col = table()->layer_name();
1407       return col.GetAtIdx(
1408         iterator_.StorageIndexForColumn(col.index_in_table()));
1409     }
present_type()1410     ColumnType::present_type::type present_type() const {
1411       const auto& col = table()->present_type();
1412       return col.GetAtIdx(
1413         iterator_.StorageIndexForColumn(col.index_in_table()));
1414     }
on_time_finish()1415     ColumnType::on_time_finish::type on_time_finish() const {
1416       const auto& col = table()->on_time_finish();
1417       return col.GetAtIdx(
1418         iterator_.StorageIndexForColumn(col.index_in_table()));
1419     }
gpu_composition()1420     ColumnType::gpu_composition::type gpu_composition() const {
1421       const auto& col = table()->gpu_composition();
1422       return col.GetAtIdx(
1423         iterator_.StorageIndexForColumn(col.index_in_table()));
1424     }
jank_type()1425     ColumnType::jank_type::type jank_type() const {
1426       const auto& col = table()->jank_type();
1427       return col.GetAtIdx(
1428         iterator_.StorageIndexForColumn(col.index_in_table()));
1429     }
jank_severity_type()1430     ColumnType::jank_severity_type::type jank_severity_type() const {
1431       const auto& col = table()->jank_severity_type();
1432       return col.GetAtIdx(
1433         iterator_.StorageIndexForColumn(col.index_in_table()));
1434     }
prediction_type()1435     ColumnType::prediction_type::type prediction_type() const {
1436       const auto& col = table()->prediction_type();
1437       return col.GetAtIdx(
1438         iterator_.StorageIndexForColumn(col.index_in_table()));
1439     }
jank_tag()1440     ColumnType::jank_tag::type jank_tag() const {
1441       const auto& col = table()->jank_tag();
1442       return col.GetAtIdx(
1443         iterator_.StorageIndexForColumn(col.index_in_table()));
1444     }
1445 
1446    protected:
ConstIterator(const ActualFrameTimelineSliceTable * table,Table::Iterator iterator)1447     explicit ConstIterator(const ActualFrameTimelineSliceTable* table,
1448                            Table::Iterator iterator)
1449         : AbstractConstIterator(table, std::move(iterator)) {}
1450 
CurrentRowNumber()1451     uint32_t CurrentRowNumber() const {
1452       return iterator_.StorageIndexForLastOverlay();
1453     }
1454 
1455    private:
1456     friend class ActualFrameTimelineSliceTable;
1457     friend class macros_internal::AbstractConstIterator<
1458       ConstIterator, ActualFrameTimelineSliceTable, RowNumber, ConstRowReference>;
1459   };
1460   class Iterator : public ConstIterator {
1461     public:
row_reference()1462      RowReference row_reference() const {
1463        return {const_cast<ActualFrameTimelineSliceTable*>(table()), CurrentRowNumber()};
1464      }
1465 
1466     private:
1467      friend class ActualFrameTimelineSliceTable;
1468 
Iterator(ActualFrameTimelineSliceTable * table,Table::Iterator iterator)1469      explicit Iterator(ActualFrameTimelineSliceTable* table, Table::Iterator iterator)
1470         : ConstIterator(table, std::move(iterator)) {}
1471   };
1472 
1473   struct IdAndRow {
1474     Id id;
1475     uint32_t row;
1476     RowReference row_reference;
1477     RowNumber row_number;
1478   };
1479 
GetColumns(ActualFrameTimelineSliceTable * self,const macros_internal::MacroTable * parent)1480   static std::vector<ColumnLegacy> GetColumns(
1481       ActualFrameTimelineSliceTable* self,
1482       const macros_internal::MacroTable* parent) {
1483     std::vector<ColumnLegacy> columns =
1484         CopyColumnsFromParentOrAddRootColumns(self, parent);
1485     uint32_t olay_idx = OverlayCount(parent);
1486     AddColumnToVector(columns, "display_frame_token", &self->display_frame_token_, ColumnFlag::display_frame_token,
1487                       static_cast<uint32_t>(columns.size()), olay_idx);
1488     AddColumnToVector(columns, "surface_frame_token", &self->surface_frame_token_, ColumnFlag::surface_frame_token,
1489                       static_cast<uint32_t>(columns.size()), olay_idx);
1490     AddColumnToVector(columns, "upid", &self->upid_, ColumnFlag::upid,
1491                       static_cast<uint32_t>(columns.size()), olay_idx);
1492     AddColumnToVector(columns, "layer_name", &self->layer_name_, ColumnFlag::layer_name,
1493                       static_cast<uint32_t>(columns.size()), olay_idx);
1494     AddColumnToVector(columns, "present_type", &self->present_type_, ColumnFlag::present_type,
1495                       static_cast<uint32_t>(columns.size()), olay_idx);
1496     AddColumnToVector(columns, "on_time_finish", &self->on_time_finish_, ColumnFlag::on_time_finish,
1497                       static_cast<uint32_t>(columns.size()), olay_idx);
1498     AddColumnToVector(columns, "gpu_composition", &self->gpu_composition_, ColumnFlag::gpu_composition,
1499                       static_cast<uint32_t>(columns.size()), olay_idx);
1500     AddColumnToVector(columns, "jank_type", &self->jank_type_, ColumnFlag::jank_type,
1501                       static_cast<uint32_t>(columns.size()), olay_idx);
1502     AddColumnToVector(columns, "jank_severity_type", &self->jank_severity_type_, ColumnFlag::jank_severity_type,
1503                       static_cast<uint32_t>(columns.size()), olay_idx);
1504     AddColumnToVector(columns, "prediction_type", &self->prediction_type_, ColumnFlag::prediction_type,
1505                       static_cast<uint32_t>(columns.size()), olay_idx);
1506     AddColumnToVector(columns, "jank_tag", &self->jank_tag_, ColumnFlag::jank_tag,
1507                       static_cast<uint32_t>(columns.size()), olay_idx);
1508     return columns;
1509   }
1510 
ActualFrameTimelineSliceTable(StringPool * pool,SliceTable * parent)1511   PERFETTO_NO_INLINE explicit ActualFrameTimelineSliceTable(StringPool* pool, SliceTable* parent)
1512       : macros_internal::MacroTable(
1513           pool,
1514           GetColumns(this, parent),
1515           parent),
1516         parent_(parent), const_parent_(parent), display_frame_token_(ColumnStorage<ColumnType::display_frame_token::stored_type>::Create<false>()),
1517         surface_frame_token_(ColumnStorage<ColumnType::surface_frame_token::stored_type>::Create<false>()),
1518         upid_(ColumnStorage<ColumnType::upid::stored_type>::Create<false>()),
1519         layer_name_(ColumnStorage<ColumnType::layer_name::stored_type>::Create<false>()),
1520         present_type_(ColumnStorage<ColumnType::present_type::stored_type>::Create<false>()),
1521         on_time_finish_(ColumnStorage<ColumnType::on_time_finish::stored_type>::Create<false>()),
1522         gpu_composition_(ColumnStorage<ColumnType::gpu_composition::stored_type>::Create<false>()),
1523         jank_type_(ColumnStorage<ColumnType::jank_type::stored_type>::Create<false>()),
1524         jank_severity_type_(ColumnStorage<ColumnType::jank_severity_type::stored_type>::Create<false>()),
1525         prediction_type_(ColumnStorage<ColumnType::prediction_type::stored_type>::Create<false>()),
1526         jank_tag_(ColumnStorage<ColumnType::jank_tag::stored_type>::Create<false>())
1527 ,
1528         display_frame_token_storage_layer_(
1529         new column::NumericStorage<ColumnType::display_frame_token::non_optional_stored_type>(
1530           &display_frame_token_.vector(),
1531           ColumnTypeHelper<ColumnType::display_frame_token::stored_type>::ToColumnType(),
1532           false)),
1533         surface_frame_token_storage_layer_(
1534         new column::NumericStorage<ColumnType::surface_frame_token::non_optional_stored_type>(
1535           &surface_frame_token_.vector(),
1536           ColumnTypeHelper<ColumnType::surface_frame_token::stored_type>::ToColumnType(),
1537           false)),
1538         upid_storage_layer_(
1539         new column::NumericStorage<ColumnType::upid::non_optional_stored_type>(
1540           &upid_.vector(),
1541           ColumnTypeHelper<ColumnType::upid::stored_type>::ToColumnType(),
1542           false)),
1543         layer_name_storage_layer_(
1544           new column::StringStorage(string_pool(), &layer_name_.vector())),
1545         present_type_storage_layer_(
1546           new column::StringStorage(string_pool(), &present_type_.vector())),
1547         on_time_finish_storage_layer_(
1548         new column::NumericStorage<ColumnType::on_time_finish::non_optional_stored_type>(
1549           &on_time_finish_.vector(),
1550           ColumnTypeHelper<ColumnType::on_time_finish::stored_type>::ToColumnType(),
1551           false)),
1552         gpu_composition_storage_layer_(
1553         new column::NumericStorage<ColumnType::gpu_composition::non_optional_stored_type>(
1554           &gpu_composition_.vector(),
1555           ColumnTypeHelper<ColumnType::gpu_composition::stored_type>::ToColumnType(),
1556           false)),
1557         jank_type_storage_layer_(
1558           new column::StringStorage(string_pool(), &jank_type_.vector())),
1559         jank_severity_type_storage_layer_(
1560           new column::StringStorage(string_pool(), &jank_severity_type_.vector())),
1561         prediction_type_storage_layer_(
1562           new column::StringStorage(string_pool(), &prediction_type_.vector())),
1563         jank_tag_storage_layer_(
1564           new column::StringStorage(string_pool(), &jank_tag_.vector()))
1565          {
1566     static_assert(
1567         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::display_frame_token::stored_type>(
1568           ColumnFlag::display_frame_token),
1569         "Column type and flag combination is not valid");
1570       static_assert(
1571         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::surface_frame_token::stored_type>(
1572           ColumnFlag::surface_frame_token),
1573         "Column type and flag combination is not valid");
1574       static_assert(
1575         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::upid::stored_type>(
1576           ColumnFlag::upid),
1577         "Column type and flag combination is not valid");
1578       static_assert(
1579         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::layer_name::stored_type>(
1580           ColumnFlag::layer_name),
1581         "Column type and flag combination is not valid");
1582       static_assert(
1583         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::present_type::stored_type>(
1584           ColumnFlag::present_type),
1585         "Column type and flag combination is not valid");
1586       static_assert(
1587         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::on_time_finish::stored_type>(
1588           ColumnFlag::on_time_finish),
1589         "Column type and flag combination is not valid");
1590       static_assert(
1591         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::gpu_composition::stored_type>(
1592           ColumnFlag::gpu_composition),
1593         "Column type and flag combination is not valid");
1594       static_assert(
1595         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::jank_type::stored_type>(
1596           ColumnFlag::jank_type),
1597         "Column type and flag combination is not valid");
1598       static_assert(
1599         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::jank_severity_type::stored_type>(
1600           ColumnFlag::jank_severity_type),
1601         "Column type and flag combination is not valid");
1602       static_assert(
1603         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::prediction_type::stored_type>(
1604           ColumnFlag::prediction_type),
1605         "Column type and flag combination is not valid");
1606       static_assert(
1607         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::jank_tag::stored_type>(
1608           ColumnFlag::jank_tag),
1609         "Column type and flag combination is not valid");
1610     OnConstructionCompletedRegularConstructor(
1611       {const_parent_->storage_layers()[ColumnIndex::id],const_parent_->storage_layers()[ColumnIndex::type],const_parent_->storage_layers()[ColumnIndex::ts],const_parent_->storage_layers()[ColumnIndex::dur],const_parent_->storage_layers()[ColumnIndex::track_id],const_parent_->storage_layers()[ColumnIndex::category],const_parent_->storage_layers()[ColumnIndex::name],const_parent_->storage_layers()[ColumnIndex::depth],const_parent_->storage_layers()[ColumnIndex::stack_id],const_parent_->storage_layers()[ColumnIndex::parent_stack_id],const_parent_->storage_layers()[ColumnIndex::parent_id],const_parent_->storage_layers()[ColumnIndex::arg_set_id],const_parent_->storage_layers()[ColumnIndex::thread_ts],const_parent_->storage_layers()[ColumnIndex::thread_dur],const_parent_->storage_layers()[ColumnIndex::thread_instruction_count],const_parent_->storage_layers()[ColumnIndex::thread_instruction_delta],display_frame_token_storage_layer_,surface_frame_token_storage_layer_,upid_storage_layer_,layer_name_storage_layer_,present_type_storage_layer_,on_time_finish_storage_layer_,gpu_composition_storage_layer_,jank_type_storage_layer_,jank_severity_type_storage_layer_,prediction_type_storage_layer_,jank_tag_storage_layer_},
1612       {{},{},{},{},{},{},{},{},{},{},const_parent_->null_layers()[ColumnIndex::parent_id],{},const_parent_->null_layers()[ColumnIndex::thread_ts],const_parent_->null_layers()[ColumnIndex::thread_dur],const_parent_->null_layers()[ColumnIndex::thread_instruction_count],const_parent_->null_layers()[ColumnIndex::thread_instruction_delta],{},{},{},{},{},{},{},{},{},{},{}});
1613   }
1614   ~ActualFrameTimelineSliceTable() override;
1615 
Name()1616   static const char* Name() { return "actual_frame_timeline_slice"; }
1617 
ComputeStaticSchema()1618   static Table::Schema ComputeStaticSchema() {
1619     Table::Schema schema;
1620     schema.columns.emplace_back(Table::Schema::Column{
1621         "id", SqlValue::Type::kLong, true, true, false, false});
1622     schema.columns.emplace_back(Table::Schema::Column{
1623         "type", SqlValue::Type::kString, false, false, false, false});
1624     schema.columns.emplace_back(Table::Schema::Column{
1625         "ts", ColumnType::ts::SqlValueType(), false,
1626         true,
1627         false,
1628         false});
1629     schema.columns.emplace_back(Table::Schema::Column{
1630         "dur", ColumnType::dur::SqlValueType(), false,
1631         false,
1632         false,
1633         false});
1634     schema.columns.emplace_back(Table::Schema::Column{
1635         "track_id", ColumnType::track_id::SqlValueType(), false,
1636         false,
1637         false,
1638         false});
1639     schema.columns.emplace_back(Table::Schema::Column{
1640         "category", ColumnType::category::SqlValueType(), false,
1641         false,
1642         false,
1643         false});
1644     schema.columns.emplace_back(Table::Schema::Column{
1645         "name", ColumnType::name::SqlValueType(), false,
1646         false,
1647         false,
1648         false});
1649     schema.columns.emplace_back(Table::Schema::Column{
1650         "depth", ColumnType::depth::SqlValueType(), false,
1651         false,
1652         false,
1653         false});
1654     schema.columns.emplace_back(Table::Schema::Column{
1655         "stack_id", ColumnType::stack_id::SqlValueType(), false,
1656         false,
1657         false,
1658         false});
1659     schema.columns.emplace_back(Table::Schema::Column{
1660         "parent_stack_id", ColumnType::parent_stack_id::SqlValueType(), false,
1661         false,
1662         false,
1663         false});
1664     schema.columns.emplace_back(Table::Schema::Column{
1665         "parent_id", ColumnType::parent_id::SqlValueType(), false,
1666         false,
1667         false,
1668         false});
1669     schema.columns.emplace_back(Table::Schema::Column{
1670         "arg_set_id", ColumnType::arg_set_id::SqlValueType(), false,
1671         false,
1672         false,
1673         false});
1674     schema.columns.emplace_back(Table::Schema::Column{
1675         "thread_ts", ColumnType::thread_ts::SqlValueType(), false,
1676         false,
1677         false,
1678         false});
1679     schema.columns.emplace_back(Table::Schema::Column{
1680         "thread_dur", ColumnType::thread_dur::SqlValueType(), false,
1681         false,
1682         false,
1683         false});
1684     schema.columns.emplace_back(Table::Schema::Column{
1685         "thread_instruction_count", ColumnType::thread_instruction_count::SqlValueType(), false,
1686         false,
1687         false,
1688         false});
1689     schema.columns.emplace_back(Table::Schema::Column{
1690         "thread_instruction_delta", ColumnType::thread_instruction_delta::SqlValueType(), false,
1691         false,
1692         false,
1693         false});
1694     schema.columns.emplace_back(Table::Schema::Column{
1695         "display_frame_token", ColumnType::display_frame_token::SqlValueType(), false,
1696         false,
1697         false,
1698         false});
1699     schema.columns.emplace_back(Table::Schema::Column{
1700         "surface_frame_token", ColumnType::surface_frame_token::SqlValueType(), false,
1701         false,
1702         false,
1703         false});
1704     schema.columns.emplace_back(Table::Schema::Column{
1705         "upid", ColumnType::upid::SqlValueType(), false,
1706         false,
1707         false,
1708         false});
1709     schema.columns.emplace_back(Table::Schema::Column{
1710         "layer_name", ColumnType::layer_name::SqlValueType(), false,
1711         false,
1712         false,
1713         false});
1714     schema.columns.emplace_back(Table::Schema::Column{
1715         "present_type", ColumnType::present_type::SqlValueType(), false,
1716         false,
1717         false,
1718         false});
1719     schema.columns.emplace_back(Table::Schema::Column{
1720         "on_time_finish", ColumnType::on_time_finish::SqlValueType(), false,
1721         false,
1722         false,
1723         false});
1724     schema.columns.emplace_back(Table::Schema::Column{
1725         "gpu_composition", ColumnType::gpu_composition::SqlValueType(), false,
1726         false,
1727         false,
1728         false});
1729     schema.columns.emplace_back(Table::Schema::Column{
1730         "jank_type", ColumnType::jank_type::SqlValueType(), false,
1731         false,
1732         false,
1733         false});
1734     schema.columns.emplace_back(Table::Schema::Column{
1735         "jank_severity_type", ColumnType::jank_severity_type::SqlValueType(), false,
1736         false,
1737         false,
1738         false});
1739     schema.columns.emplace_back(Table::Schema::Column{
1740         "prediction_type", ColumnType::prediction_type::SqlValueType(), false,
1741         false,
1742         false,
1743         false});
1744     schema.columns.emplace_back(Table::Schema::Column{
1745         "jank_tag", ColumnType::jank_tag::SqlValueType(), false,
1746         false,
1747         false,
1748         false});
1749     return schema;
1750   }
1751 
IterateRows()1752   ConstIterator IterateRows() const {
1753     return ConstIterator(this, Table::IterateRows());
1754   }
1755 
IterateRows()1756   Iterator IterateRows() { return Iterator(this, Table::IterateRows()); }
1757 
FilterToIterator(const Query & q)1758   ConstIterator FilterToIterator(const Query& q) const {
1759     return ConstIterator(this, QueryToIterator(q));
1760   }
1761 
FilterToIterator(const Query & q)1762   Iterator FilterToIterator(const Query& q) {
1763     return Iterator(this, QueryToIterator(q));
1764   }
1765 
ShrinkToFit()1766   void ShrinkToFit() {
1767     display_frame_token_.ShrinkToFit();
1768     surface_frame_token_.ShrinkToFit();
1769     upid_.ShrinkToFit();
1770     layer_name_.ShrinkToFit();
1771     present_type_.ShrinkToFit();
1772     on_time_finish_.ShrinkToFit();
1773     gpu_composition_.ShrinkToFit();
1774     jank_type_.ShrinkToFit();
1775     jank_severity_type_.ShrinkToFit();
1776     prediction_type_.ShrinkToFit();
1777     jank_tag_.ShrinkToFit();
1778   }
1779 
1780   ConstRowReference operator[](uint32_t r) const {
1781     return ConstRowReference(this, r);
1782   }
1783   RowReference operator[](uint32_t r) { return RowReference(this, r); }
1784   ConstRowReference operator[](RowNumber r) const {
1785     return ConstRowReference(this, r.row_number());
1786   }
1787   RowReference operator[](RowNumber r) {
1788     return RowReference(this, r.row_number());
1789   }
1790 
FindById(Id find_id)1791   std::optional<ConstRowReference> FindById(Id find_id) const {
1792     std::optional<uint32_t> row = id().IndexOf(find_id);
1793     return row ? std::make_optional(ConstRowReference(this, *row))
1794                : std::nullopt;
1795   }
1796 
FindById(Id find_id)1797   std::optional<RowReference> FindById(Id find_id) {
1798     std::optional<uint32_t> row = id().IndexOf(find_id);
1799     return row ? std::make_optional(RowReference(this, *row)) : std::nullopt;
1800   }
1801 
Insert(const Row & row)1802   IdAndRow Insert(const Row& row) {
1803     uint32_t row_number = row_count();
1804     Id id = Id{parent_->Insert(row).id};
1805     UpdateOverlaysAfterParentInsert();
1806     mutable_display_frame_token()->Append(row.display_frame_token);
1807     mutable_surface_frame_token()->Append(row.surface_frame_token);
1808     mutable_upid()->Append(row.upid);
1809     mutable_layer_name()->Append(row.layer_name);
1810     mutable_present_type()->Append(row.present_type);
1811     mutable_on_time_finish()->Append(row.on_time_finish);
1812     mutable_gpu_composition()->Append(row.gpu_composition);
1813     mutable_jank_type()->Append(row.jank_type);
1814     mutable_jank_severity_type()->Append(row.jank_severity_type);
1815     mutable_prediction_type()->Append(row.prediction_type);
1816     mutable_jank_tag()->Append(row.jank_tag);
1817     UpdateSelfOverlayAfterInsert();
1818     return IdAndRow{id, row_number, RowReference(this, row_number),
1819                      RowNumber(row_number)};
1820   }
1821 
ExtendParent(const SliceTable & parent,ColumnStorage<ColumnType::display_frame_token::stored_type> display_frame_token,ColumnStorage<ColumnType::surface_frame_token::stored_type> surface_frame_token,ColumnStorage<ColumnType::upid::stored_type> upid,ColumnStorage<ColumnType::layer_name::stored_type> layer_name,ColumnStorage<ColumnType::present_type::stored_type> present_type,ColumnStorage<ColumnType::on_time_finish::stored_type> on_time_finish,ColumnStorage<ColumnType::gpu_composition::stored_type> gpu_composition,ColumnStorage<ColumnType::jank_type::stored_type> jank_type,ColumnStorage<ColumnType::jank_severity_type::stored_type> jank_severity_type,ColumnStorage<ColumnType::prediction_type::stored_type> prediction_type,ColumnStorage<ColumnType::jank_tag::stored_type> jank_tag)1822   static std::unique_ptr<ActualFrameTimelineSliceTable> ExtendParent(
1823       const SliceTable& parent,
1824       ColumnStorage<ColumnType::display_frame_token::stored_type> display_frame_token
1825 , ColumnStorage<ColumnType::surface_frame_token::stored_type> surface_frame_token
1826 , ColumnStorage<ColumnType::upid::stored_type> upid
1827 , ColumnStorage<ColumnType::layer_name::stored_type> layer_name
1828 , ColumnStorage<ColumnType::present_type::stored_type> present_type
1829 , ColumnStorage<ColumnType::on_time_finish::stored_type> on_time_finish
1830 , ColumnStorage<ColumnType::gpu_composition::stored_type> gpu_composition
1831 , ColumnStorage<ColumnType::jank_type::stored_type> jank_type
1832 , ColumnStorage<ColumnType::jank_severity_type::stored_type> jank_severity_type
1833 , ColumnStorage<ColumnType::prediction_type::stored_type> prediction_type
1834 , ColumnStorage<ColumnType::jank_tag::stored_type> jank_tag) {
1835     return std::unique_ptr<ActualFrameTimelineSliceTable>(new ActualFrameTimelineSliceTable(
1836         parent.string_pool(), parent, RowMap(0, parent.row_count()),
1837         std::move(display_frame_token), std::move(surface_frame_token), std::move(upid), std::move(layer_name), std::move(present_type), std::move(on_time_finish), std::move(gpu_composition), std::move(jank_type), std::move(jank_severity_type), std::move(prediction_type), std::move(jank_tag)));
1838   }
1839 
SelectAndExtendParent(const SliceTable & parent,std::vector<SliceTable::RowNumber> parent_overlay,ColumnStorage<ColumnType::display_frame_token::stored_type> display_frame_token,ColumnStorage<ColumnType::surface_frame_token::stored_type> surface_frame_token,ColumnStorage<ColumnType::upid::stored_type> upid,ColumnStorage<ColumnType::layer_name::stored_type> layer_name,ColumnStorage<ColumnType::present_type::stored_type> present_type,ColumnStorage<ColumnType::on_time_finish::stored_type> on_time_finish,ColumnStorage<ColumnType::gpu_composition::stored_type> gpu_composition,ColumnStorage<ColumnType::jank_type::stored_type> jank_type,ColumnStorage<ColumnType::jank_severity_type::stored_type> jank_severity_type,ColumnStorage<ColumnType::prediction_type::stored_type> prediction_type,ColumnStorage<ColumnType::jank_tag::stored_type> jank_tag)1840   static std::unique_ptr<ActualFrameTimelineSliceTable> SelectAndExtendParent(
1841       const SliceTable& parent,
1842       std::vector<SliceTable::RowNumber> parent_overlay,
1843       ColumnStorage<ColumnType::display_frame_token::stored_type> display_frame_token
1844 , ColumnStorage<ColumnType::surface_frame_token::stored_type> surface_frame_token
1845 , ColumnStorage<ColumnType::upid::stored_type> upid
1846 , ColumnStorage<ColumnType::layer_name::stored_type> layer_name
1847 , ColumnStorage<ColumnType::present_type::stored_type> present_type
1848 , ColumnStorage<ColumnType::on_time_finish::stored_type> on_time_finish
1849 , ColumnStorage<ColumnType::gpu_composition::stored_type> gpu_composition
1850 , ColumnStorage<ColumnType::jank_type::stored_type> jank_type
1851 , ColumnStorage<ColumnType::jank_severity_type::stored_type> jank_severity_type
1852 , ColumnStorage<ColumnType::prediction_type::stored_type> prediction_type
1853 , ColumnStorage<ColumnType::jank_tag::stored_type> jank_tag) {
1854     std::vector<uint32_t> prs_untyped(parent_overlay.size());
1855     for (uint32_t i = 0; i < parent_overlay.size(); ++i) {
1856       prs_untyped[i] = parent_overlay[i].row_number();
1857     }
1858     return std::unique_ptr<ActualFrameTimelineSliceTable>(new ActualFrameTimelineSliceTable(
1859         parent.string_pool(), parent, RowMap(std::move(prs_untyped)),
1860         std::move(display_frame_token), std::move(surface_frame_token), std::move(upid), std::move(layer_name), std::move(present_type), std::move(on_time_finish), std::move(gpu_composition), std::move(jank_type), std::move(jank_severity_type), std::move(prediction_type), std::move(jank_tag)));
1861   }
1862 
id()1863   const IdColumn<ActualFrameTimelineSliceTable::Id>& id() const {
1864     return static_cast<const ColumnType::id&>(columns()[ColumnIndex::id]);
1865   }
type()1866   const TypedColumn<StringPool::Id>& type() const {
1867     return static_cast<const ColumnType::type&>(columns()[ColumnIndex::type]);
1868   }
ts()1869   const TypedColumn<int64_t>& ts() const {
1870     return static_cast<const ColumnType::ts&>(columns()[ColumnIndex::ts]);
1871   }
dur()1872   const TypedColumn<int64_t>& dur() const {
1873     return static_cast<const ColumnType::dur&>(columns()[ColumnIndex::dur]);
1874   }
track_id()1875   const TypedColumn<TrackTable::Id>& track_id() const {
1876     return static_cast<const ColumnType::track_id&>(columns()[ColumnIndex::track_id]);
1877   }
category()1878   const TypedColumn<std::optional<StringPool::Id>>& category() const {
1879     return static_cast<const ColumnType::category&>(columns()[ColumnIndex::category]);
1880   }
name()1881   const TypedColumn<std::optional<StringPool::Id>>& name() const {
1882     return static_cast<const ColumnType::name&>(columns()[ColumnIndex::name]);
1883   }
depth()1884   const TypedColumn<uint32_t>& depth() const {
1885     return static_cast<const ColumnType::depth&>(columns()[ColumnIndex::depth]);
1886   }
stack_id()1887   const TypedColumn<int64_t>& stack_id() const {
1888     return static_cast<const ColumnType::stack_id&>(columns()[ColumnIndex::stack_id]);
1889   }
parent_stack_id()1890   const TypedColumn<int64_t>& parent_stack_id() const {
1891     return static_cast<const ColumnType::parent_stack_id&>(columns()[ColumnIndex::parent_stack_id]);
1892   }
parent_id()1893   const TypedColumn<std::optional<ActualFrameTimelineSliceTable::Id>>& parent_id() const {
1894     return static_cast<const ColumnType::parent_id&>(columns()[ColumnIndex::parent_id]);
1895   }
arg_set_id()1896   const TypedColumn<uint32_t>& arg_set_id() const {
1897     return static_cast<const ColumnType::arg_set_id&>(columns()[ColumnIndex::arg_set_id]);
1898   }
thread_ts()1899   const TypedColumn<std::optional<int64_t>>& thread_ts() const {
1900     return static_cast<const ColumnType::thread_ts&>(columns()[ColumnIndex::thread_ts]);
1901   }
thread_dur()1902   const TypedColumn<std::optional<int64_t>>& thread_dur() const {
1903     return static_cast<const ColumnType::thread_dur&>(columns()[ColumnIndex::thread_dur]);
1904   }
thread_instruction_count()1905   const TypedColumn<std::optional<int64_t>>& thread_instruction_count() const {
1906     return static_cast<const ColumnType::thread_instruction_count&>(columns()[ColumnIndex::thread_instruction_count]);
1907   }
thread_instruction_delta()1908   const TypedColumn<std::optional<int64_t>>& thread_instruction_delta() const {
1909     return static_cast<const ColumnType::thread_instruction_delta&>(columns()[ColumnIndex::thread_instruction_delta]);
1910   }
display_frame_token()1911   const TypedColumn<int64_t>& display_frame_token() const {
1912     return static_cast<const ColumnType::display_frame_token&>(columns()[ColumnIndex::display_frame_token]);
1913   }
surface_frame_token()1914   const TypedColumn<int64_t>& surface_frame_token() const {
1915     return static_cast<const ColumnType::surface_frame_token&>(columns()[ColumnIndex::surface_frame_token]);
1916   }
upid()1917   const TypedColumn<uint32_t>& upid() const {
1918     return static_cast<const ColumnType::upid&>(columns()[ColumnIndex::upid]);
1919   }
layer_name()1920   const TypedColumn<StringPool::Id>& layer_name() const {
1921     return static_cast<const ColumnType::layer_name&>(columns()[ColumnIndex::layer_name]);
1922   }
present_type()1923   const TypedColumn<StringPool::Id>& present_type() const {
1924     return static_cast<const ColumnType::present_type&>(columns()[ColumnIndex::present_type]);
1925   }
on_time_finish()1926   const TypedColumn<int32_t>& on_time_finish() const {
1927     return static_cast<const ColumnType::on_time_finish&>(columns()[ColumnIndex::on_time_finish]);
1928   }
gpu_composition()1929   const TypedColumn<int32_t>& gpu_composition() const {
1930     return static_cast<const ColumnType::gpu_composition&>(columns()[ColumnIndex::gpu_composition]);
1931   }
jank_type()1932   const TypedColumn<StringPool::Id>& jank_type() const {
1933     return static_cast<const ColumnType::jank_type&>(columns()[ColumnIndex::jank_type]);
1934   }
jank_severity_type()1935   const TypedColumn<StringPool::Id>& jank_severity_type() const {
1936     return static_cast<const ColumnType::jank_severity_type&>(columns()[ColumnIndex::jank_severity_type]);
1937   }
prediction_type()1938   const TypedColumn<StringPool::Id>& prediction_type() const {
1939     return static_cast<const ColumnType::prediction_type&>(columns()[ColumnIndex::prediction_type]);
1940   }
jank_tag()1941   const TypedColumn<StringPool::Id>& jank_tag() const {
1942     return static_cast<const ColumnType::jank_tag&>(columns()[ColumnIndex::jank_tag]);
1943   }
1944 
mutable_ts()1945   TypedColumn<int64_t>* mutable_ts() {
1946     return static_cast<ColumnType::ts*>(
1947         GetColumn(ColumnIndex::ts));
1948   }
mutable_dur()1949   TypedColumn<int64_t>* mutable_dur() {
1950     return static_cast<ColumnType::dur*>(
1951         GetColumn(ColumnIndex::dur));
1952   }
mutable_track_id()1953   TypedColumn<TrackTable::Id>* mutable_track_id() {
1954     return static_cast<ColumnType::track_id*>(
1955         GetColumn(ColumnIndex::track_id));
1956   }
mutable_category()1957   TypedColumn<std::optional<StringPool::Id>>* mutable_category() {
1958     return static_cast<ColumnType::category*>(
1959         GetColumn(ColumnIndex::category));
1960   }
mutable_name()1961   TypedColumn<std::optional<StringPool::Id>>* mutable_name() {
1962     return static_cast<ColumnType::name*>(
1963         GetColumn(ColumnIndex::name));
1964   }
mutable_depth()1965   TypedColumn<uint32_t>* mutable_depth() {
1966     return static_cast<ColumnType::depth*>(
1967         GetColumn(ColumnIndex::depth));
1968   }
mutable_stack_id()1969   TypedColumn<int64_t>* mutable_stack_id() {
1970     return static_cast<ColumnType::stack_id*>(
1971         GetColumn(ColumnIndex::stack_id));
1972   }
mutable_parent_stack_id()1973   TypedColumn<int64_t>* mutable_parent_stack_id() {
1974     return static_cast<ColumnType::parent_stack_id*>(
1975         GetColumn(ColumnIndex::parent_stack_id));
1976   }
mutable_parent_id()1977   TypedColumn<std::optional<ActualFrameTimelineSliceTable::Id>>* mutable_parent_id() {
1978     return static_cast<ColumnType::parent_id*>(
1979         GetColumn(ColumnIndex::parent_id));
1980   }
mutable_arg_set_id()1981   TypedColumn<uint32_t>* mutable_arg_set_id() {
1982     return static_cast<ColumnType::arg_set_id*>(
1983         GetColumn(ColumnIndex::arg_set_id));
1984   }
mutable_thread_ts()1985   TypedColumn<std::optional<int64_t>>* mutable_thread_ts() {
1986     return static_cast<ColumnType::thread_ts*>(
1987         GetColumn(ColumnIndex::thread_ts));
1988   }
mutable_thread_dur()1989   TypedColumn<std::optional<int64_t>>* mutable_thread_dur() {
1990     return static_cast<ColumnType::thread_dur*>(
1991         GetColumn(ColumnIndex::thread_dur));
1992   }
mutable_thread_instruction_count()1993   TypedColumn<std::optional<int64_t>>* mutable_thread_instruction_count() {
1994     return static_cast<ColumnType::thread_instruction_count*>(
1995         GetColumn(ColumnIndex::thread_instruction_count));
1996   }
mutable_thread_instruction_delta()1997   TypedColumn<std::optional<int64_t>>* mutable_thread_instruction_delta() {
1998     return static_cast<ColumnType::thread_instruction_delta*>(
1999         GetColumn(ColumnIndex::thread_instruction_delta));
2000   }
mutable_display_frame_token()2001   TypedColumn<int64_t>* mutable_display_frame_token() {
2002     return static_cast<ColumnType::display_frame_token*>(
2003         GetColumn(ColumnIndex::display_frame_token));
2004   }
mutable_surface_frame_token()2005   TypedColumn<int64_t>* mutable_surface_frame_token() {
2006     return static_cast<ColumnType::surface_frame_token*>(
2007         GetColumn(ColumnIndex::surface_frame_token));
2008   }
mutable_upid()2009   TypedColumn<uint32_t>* mutable_upid() {
2010     return static_cast<ColumnType::upid*>(
2011         GetColumn(ColumnIndex::upid));
2012   }
mutable_layer_name()2013   TypedColumn<StringPool::Id>* mutable_layer_name() {
2014     return static_cast<ColumnType::layer_name*>(
2015         GetColumn(ColumnIndex::layer_name));
2016   }
mutable_present_type()2017   TypedColumn<StringPool::Id>* mutable_present_type() {
2018     return static_cast<ColumnType::present_type*>(
2019         GetColumn(ColumnIndex::present_type));
2020   }
mutable_on_time_finish()2021   TypedColumn<int32_t>* mutable_on_time_finish() {
2022     return static_cast<ColumnType::on_time_finish*>(
2023         GetColumn(ColumnIndex::on_time_finish));
2024   }
mutable_gpu_composition()2025   TypedColumn<int32_t>* mutable_gpu_composition() {
2026     return static_cast<ColumnType::gpu_composition*>(
2027         GetColumn(ColumnIndex::gpu_composition));
2028   }
mutable_jank_type()2029   TypedColumn<StringPool::Id>* mutable_jank_type() {
2030     return static_cast<ColumnType::jank_type*>(
2031         GetColumn(ColumnIndex::jank_type));
2032   }
mutable_jank_severity_type()2033   TypedColumn<StringPool::Id>* mutable_jank_severity_type() {
2034     return static_cast<ColumnType::jank_severity_type*>(
2035         GetColumn(ColumnIndex::jank_severity_type));
2036   }
mutable_prediction_type()2037   TypedColumn<StringPool::Id>* mutable_prediction_type() {
2038     return static_cast<ColumnType::prediction_type*>(
2039         GetColumn(ColumnIndex::prediction_type));
2040   }
mutable_jank_tag()2041   TypedColumn<StringPool::Id>* mutable_jank_tag() {
2042     return static_cast<ColumnType::jank_tag*>(
2043         GetColumn(ColumnIndex::jank_tag));
2044   }
2045 
2046  private:
ActualFrameTimelineSliceTable(StringPool * pool,const SliceTable & parent,const RowMap & parent_overlay,ColumnStorage<ColumnType::display_frame_token::stored_type> display_frame_token,ColumnStorage<ColumnType::surface_frame_token::stored_type> surface_frame_token,ColumnStorage<ColumnType::upid::stored_type> upid,ColumnStorage<ColumnType::layer_name::stored_type> layer_name,ColumnStorage<ColumnType::present_type::stored_type> present_type,ColumnStorage<ColumnType::on_time_finish::stored_type> on_time_finish,ColumnStorage<ColumnType::gpu_composition::stored_type> gpu_composition,ColumnStorage<ColumnType::jank_type::stored_type> jank_type,ColumnStorage<ColumnType::jank_severity_type::stored_type> jank_severity_type,ColumnStorage<ColumnType::prediction_type::stored_type> prediction_type,ColumnStorage<ColumnType::jank_tag::stored_type> jank_tag)2047   ActualFrameTimelineSliceTable(StringPool* pool,
2048             const SliceTable& parent,
2049             const RowMap& parent_overlay,
2050             ColumnStorage<ColumnType::display_frame_token::stored_type> display_frame_token
2051 , ColumnStorage<ColumnType::surface_frame_token::stored_type> surface_frame_token
2052 , ColumnStorage<ColumnType::upid::stored_type> upid
2053 , ColumnStorage<ColumnType::layer_name::stored_type> layer_name
2054 , ColumnStorage<ColumnType::present_type::stored_type> present_type
2055 , ColumnStorage<ColumnType::on_time_finish::stored_type> on_time_finish
2056 , ColumnStorage<ColumnType::gpu_composition::stored_type> gpu_composition
2057 , ColumnStorage<ColumnType::jank_type::stored_type> jank_type
2058 , ColumnStorage<ColumnType::jank_severity_type::stored_type> jank_severity_type
2059 , ColumnStorage<ColumnType::prediction_type::stored_type> prediction_type
2060 , ColumnStorage<ColumnType::jank_tag::stored_type> jank_tag)
2061       : macros_internal::MacroTable(
2062           pool,
2063           GetColumns(this, &parent),
2064           parent,
2065           parent_overlay),
2066           const_parent_(&parent)
2067 ,
2068         display_frame_token_storage_layer_(
2069         new column::NumericStorage<ColumnType::display_frame_token::non_optional_stored_type>(
2070           &display_frame_token_.vector(),
2071           ColumnTypeHelper<ColumnType::display_frame_token::stored_type>::ToColumnType(),
2072           false)),
2073         surface_frame_token_storage_layer_(
2074         new column::NumericStorage<ColumnType::surface_frame_token::non_optional_stored_type>(
2075           &surface_frame_token_.vector(),
2076           ColumnTypeHelper<ColumnType::surface_frame_token::stored_type>::ToColumnType(),
2077           false)),
2078         upid_storage_layer_(
2079         new column::NumericStorage<ColumnType::upid::non_optional_stored_type>(
2080           &upid_.vector(),
2081           ColumnTypeHelper<ColumnType::upid::stored_type>::ToColumnType(),
2082           false)),
2083         layer_name_storage_layer_(
2084           new column::StringStorage(string_pool(), &layer_name_.vector())),
2085         present_type_storage_layer_(
2086           new column::StringStorage(string_pool(), &present_type_.vector())),
2087         on_time_finish_storage_layer_(
2088         new column::NumericStorage<ColumnType::on_time_finish::non_optional_stored_type>(
2089           &on_time_finish_.vector(),
2090           ColumnTypeHelper<ColumnType::on_time_finish::stored_type>::ToColumnType(),
2091           false)),
2092         gpu_composition_storage_layer_(
2093         new column::NumericStorage<ColumnType::gpu_composition::non_optional_stored_type>(
2094           &gpu_composition_.vector(),
2095           ColumnTypeHelper<ColumnType::gpu_composition::stored_type>::ToColumnType(),
2096           false)),
2097         jank_type_storage_layer_(
2098           new column::StringStorage(string_pool(), &jank_type_.vector())),
2099         jank_severity_type_storage_layer_(
2100           new column::StringStorage(string_pool(), &jank_severity_type_.vector())),
2101         prediction_type_storage_layer_(
2102           new column::StringStorage(string_pool(), &prediction_type_.vector())),
2103         jank_tag_storage_layer_(
2104           new column::StringStorage(string_pool(), &jank_tag_.vector()))
2105          {
2106     static_assert(
2107         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::display_frame_token::stored_type>(
2108           ColumnFlag::display_frame_token),
2109         "Column type and flag combination is not valid");
2110       static_assert(
2111         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::surface_frame_token::stored_type>(
2112           ColumnFlag::surface_frame_token),
2113         "Column type and flag combination is not valid");
2114       static_assert(
2115         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::upid::stored_type>(
2116           ColumnFlag::upid),
2117         "Column type and flag combination is not valid");
2118       static_assert(
2119         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::layer_name::stored_type>(
2120           ColumnFlag::layer_name),
2121         "Column type and flag combination is not valid");
2122       static_assert(
2123         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::present_type::stored_type>(
2124           ColumnFlag::present_type),
2125         "Column type and flag combination is not valid");
2126       static_assert(
2127         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::on_time_finish::stored_type>(
2128           ColumnFlag::on_time_finish),
2129         "Column type and flag combination is not valid");
2130       static_assert(
2131         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::gpu_composition::stored_type>(
2132           ColumnFlag::gpu_composition),
2133         "Column type and flag combination is not valid");
2134       static_assert(
2135         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::jank_type::stored_type>(
2136           ColumnFlag::jank_type),
2137         "Column type and flag combination is not valid");
2138       static_assert(
2139         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::jank_severity_type::stored_type>(
2140           ColumnFlag::jank_severity_type),
2141         "Column type and flag combination is not valid");
2142       static_assert(
2143         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::prediction_type::stored_type>(
2144           ColumnFlag::prediction_type),
2145         "Column type and flag combination is not valid");
2146       static_assert(
2147         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::jank_tag::stored_type>(
2148           ColumnFlag::jank_tag),
2149         "Column type and flag combination is not valid");
2150     PERFETTO_DCHECK(display_frame_token.size() == parent_overlay.size());
2151     display_frame_token_ = std::move(display_frame_token);
2152     PERFETTO_DCHECK(surface_frame_token.size() == parent_overlay.size());
2153     surface_frame_token_ = std::move(surface_frame_token);
2154     PERFETTO_DCHECK(upid.size() == parent_overlay.size());
2155     upid_ = std::move(upid);
2156     PERFETTO_DCHECK(layer_name.size() == parent_overlay.size());
2157     layer_name_ = std::move(layer_name);
2158     PERFETTO_DCHECK(present_type.size() == parent_overlay.size());
2159     present_type_ = std::move(present_type);
2160     PERFETTO_DCHECK(on_time_finish.size() == parent_overlay.size());
2161     on_time_finish_ = std::move(on_time_finish);
2162     PERFETTO_DCHECK(gpu_composition.size() == parent_overlay.size());
2163     gpu_composition_ = std::move(gpu_composition);
2164     PERFETTO_DCHECK(jank_type.size() == parent_overlay.size());
2165     jank_type_ = std::move(jank_type);
2166     PERFETTO_DCHECK(jank_severity_type.size() == parent_overlay.size());
2167     jank_severity_type_ = std::move(jank_severity_type);
2168     PERFETTO_DCHECK(prediction_type.size() == parent_overlay.size());
2169     prediction_type_ = std::move(prediction_type);
2170     PERFETTO_DCHECK(jank_tag.size() == parent_overlay.size());
2171     jank_tag_ = std::move(jank_tag);
2172 
2173     std::vector<RefPtr<column::OverlayLayer>> overlay_layers(OverlayCount(&parent) + 1);
2174     for (uint32_t i = 0; i < overlay_layers.size(); ++i) {
2175       if (overlays()[i].row_map().IsIndexVector()) {
2176         overlay_layers[i].reset(new column::ArrangementOverlay(
2177             overlays()[i].row_map().GetIfIndexVector(),
2178             column::DataLayerChain::Indices::State::kNonmonotonic));
2179       } else if (overlays()[i].row_map().IsBitVector()) {
2180         overlay_layers[i].reset(new column::SelectorOverlay(
2181             overlays()[i].row_map().GetIfBitVector()));
2182       } else if (overlays()[i].row_map().IsRange()) {
2183         overlay_layers[i].reset(new column::RangeOverlay(
2184             overlays()[i].row_map().GetIfIRange()));
2185       }
2186     }
2187 
2188     OnConstructionCompleted(
2189       {const_parent_->storage_layers()[ColumnIndex::id],const_parent_->storage_layers()[ColumnIndex::type],const_parent_->storage_layers()[ColumnIndex::ts],const_parent_->storage_layers()[ColumnIndex::dur],const_parent_->storage_layers()[ColumnIndex::track_id],const_parent_->storage_layers()[ColumnIndex::category],const_parent_->storage_layers()[ColumnIndex::name],const_parent_->storage_layers()[ColumnIndex::depth],const_parent_->storage_layers()[ColumnIndex::stack_id],const_parent_->storage_layers()[ColumnIndex::parent_stack_id],const_parent_->storage_layers()[ColumnIndex::parent_id],const_parent_->storage_layers()[ColumnIndex::arg_set_id],const_parent_->storage_layers()[ColumnIndex::thread_ts],const_parent_->storage_layers()[ColumnIndex::thread_dur],const_parent_->storage_layers()[ColumnIndex::thread_instruction_count],const_parent_->storage_layers()[ColumnIndex::thread_instruction_delta],display_frame_token_storage_layer_,surface_frame_token_storage_layer_,upid_storage_layer_,layer_name_storage_layer_,present_type_storage_layer_,on_time_finish_storage_layer_,gpu_composition_storage_layer_,jank_type_storage_layer_,jank_severity_type_storage_layer_,prediction_type_storage_layer_,jank_tag_storage_layer_}, {{},{},{},{},{},{},{},{},{},{},const_parent_->null_layers()[ColumnIndex::parent_id],{},const_parent_->null_layers()[ColumnIndex::thread_ts],const_parent_->null_layers()[ColumnIndex::thread_dur],const_parent_->null_layers()[ColumnIndex::thread_instruction_count],const_parent_->null_layers()[ColumnIndex::thread_instruction_delta],{},{},{},{},{},{},{},{},{},{},{}}, std::move(overlay_layers));
2190   }
2191   SliceTable* parent_ = nullptr;
2192   const SliceTable* const_parent_ = nullptr;
2193   ColumnStorage<ColumnType::display_frame_token::stored_type> display_frame_token_;
2194   ColumnStorage<ColumnType::surface_frame_token::stored_type> surface_frame_token_;
2195   ColumnStorage<ColumnType::upid::stored_type> upid_;
2196   ColumnStorage<ColumnType::layer_name::stored_type> layer_name_;
2197   ColumnStorage<ColumnType::present_type::stored_type> present_type_;
2198   ColumnStorage<ColumnType::on_time_finish::stored_type> on_time_finish_;
2199   ColumnStorage<ColumnType::gpu_composition::stored_type> gpu_composition_;
2200   ColumnStorage<ColumnType::jank_type::stored_type> jank_type_;
2201   ColumnStorage<ColumnType::jank_severity_type::stored_type> jank_severity_type_;
2202   ColumnStorage<ColumnType::prediction_type::stored_type> prediction_type_;
2203   ColumnStorage<ColumnType::jank_tag::stored_type> jank_tag_;
2204 
2205   RefPtr<column::StorageLayer> display_frame_token_storage_layer_;
2206   RefPtr<column::StorageLayer> surface_frame_token_storage_layer_;
2207   RefPtr<column::StorageLayer> upid_storage_layer_;
2208   RefPtr<column::StorageLayer> layer_name_storage_layer_;
2209   RefPtr<column::StorageLayer> present_type_storage_layer_;
2210   RefPtr<column::StorageLayer> on_time_finish_storage_layer_;
2211   RefPtr<column::StorageLayer> gpu_composition_storage_layer_;
2212   RefPtr<column::StorageLayer> jank_type_storage_layer_;
2213   RefPtr<column::StorageLayer> jank_severity_type_storage_layer_;
2214   RefPtr<column::StorageLayer> prediction_type_storage_layer_;
2215   RefPtr<column::StorageLayer> jank_tag_storage_layer_;
2216 
2217 
2218 };
2219 
2220 
2221 class AndroidNetworkPacketsTable : public macros_internal::MacroTable {
2222  public:
2223   static constexpr uint32_t kColumnCount = 30;
2224 
2225   using Id = SliceTable::Id;
2226 
2227   struct ColumnIndex {
2228     static constexpr uint32_t id = 0;
2229     static constexpr uint32_t type = 1;
2230     static constexpr uint32_t ts = 2;
2231     static constexpr uint32_t dur = 3;
2232     static constexpr uint32_t track_id = 4;
2233     static constexpr uint32_t category = 5;
2234     static constexpr uint32_t name = 6;
2235     static constexpr uint32_t depth = 7;
2236     static constexpr uint32_t stack_id = 8;
2237     static constexpr uint32_t parent_stack_id = 9;
2238     static constexpr uint32_t parent_id = 10;
2239     static constexpr uint32_t arg_set_id = 11;
2240     static constexpr uint32_t thread_ts = 12;
2241     static constexpr uint32_t thread_dur = 13;
2242     static constexpr uint32_t thread_instruction_count = 14;
2243     static constexpr uint32_t thread_instruction_delta = 15;
2244     static constexpr uint32_t iface = 16;
2245     static constexpr uint32_t direction = 17;
2246     static constexpr uint32_t packet_transport = 18;
2247     static constexpr uint32_t packet_length = 19;
2248     static constexpr uint32_t packet_count = 20;
2249     static constexpr uint32_t socket_tag = 21;
2250     static constexpr uint32_t socket_tag_str = 22;
2251     static constexpr uint32_t socket_uid = 23;
2252     static constexpr uint32_t local_port = 24;
2253     static constexpr uint32_t remote_port = 25;
2254     static constexpr uint32_t packet_icmp_type = 26;
2255     static constexpr uint32_t packet_icmp_code = 27;
2256     static constexpr uint32_t packet_tcp_flags = 28;
2257     static constexpr uint32_t packet_tcp_flags_str = 29;
2258   };
2259   struct ColumnType {
2260     using id = IdColumn<AndroidNetworkPacketsTable::Id>;
2261     using type = TypedColumn<StringPool::Id>;
2262     using ts = TypedColumn<int64_t>;
2263     using dur = TypedColumn<int64_t>;
2264     using track_id = TypedColumn<TrackTable::Id>;
2265     using category = TypedColumn<std::optional<StringPool::Id>>;
2266     using name = TypedColumn<std::optional<StringPool::Id>>;
2267     using depth = TypedColumn<uint32_t>;
2268     using stack_id = TypedColumn<int64_t>;
2269     using parent_stack_id = TypedColumn<int64_t>;
2270     using parent_id = TypedColumn<std::optional<AndroidNetworkPacketsTable::Id>>;
2271     using arg_set_id = TypedColumn<uint32_t>;
2272     using thread_ts = TypedColumn<std::optional<int64_t>>;
2273     using thread_dur = TypedColumn<std::optional<int64_t>>;
2274     using thread_instruction_count = TypedColumn<std::optional<int64_t>>;
2275     using thread_instruction_delta = TypedColumn<std::optional<int64_t>>;
2276     using iface = TypedColumn<StringPool::Id>;
2277     using direction = TypedColumn<StringPool::Id>;
2278     using packet_transport = TypedColumn<StringPool::Id>;
2279     using packet_length = TypedColumn<int64_t>;
2280     using packet_count = TypedColumn<int64_t>;
2281     using socket_tag = TypedColumn<uint32_t>;
2282     using socket_tag_str = TypedColumn<StringPool::Id>;
2283     using socket_uid = TypedColumn<uint32_t>;
2284     using local_port = TypedColumn<std::optional<uint32_t>>;
2285     using remote_port = TypedColumn<std::optional<uint32_t>>;
2286     using packet_icmp_type = TypedColumn<std::optional<uint32_t>>;
2287     using packet_icmp_code = TypedColumn<std::optional<uint32_t>>;
2288     using packet_tcp_flags = TypedColumn<std::optional<uint32_t>>;
2289     using packet_tcp_flags_str = TypedColumn<std::optional<StringPool::Id>>;
2290   };
2291   struct Row : public SliceTable::Row {
2292     Row(int64_t in_ts = {},
2293         int64_t in_dur = {},
2294         TrackTable::Id in_track_id = {},
2295         std::optional<StringPool::Id> in_category = {},
2296         std::optional<StringPool::Id> in_name = {},
2297         uint32_t in_depth = {},
2298         int64_t in_stack_id = {},
2299         int64_t in_parent_stack_id = {},
2300         std::optional<AndroidNetworkPacketsTable::Id> in_parent_id = {},
2301         uint32_t in_arg_set_id = {},
2302         std::optional<int64_t> in_thread_ts = {},
2303         std::optional<int64_t> in_thread_dur = {},
2304         std::optional<int64_t> in_thread_instruction_count = {},
2305         std::optional<int64_t> in_thread_instruction_delta = {},
2306         StringPool::Id in_iface = {},
2307         StringPool::Id in_direction = {},
2308         StringPool::Id in_packet_transport = {},
2309         int64_t in_packet_length = {},
2310         int64_t in_packet_count = {},
2311         uint32_t in_socket_tag = {},
2312         StringPool::Id in_socket_tag_str = {},
2313         uint32_t in_socket_uid = {},
2314         std::optional<uint32_t> in_local_port = {},
2315         std::optional<uint32_t> in_remote_port = {},
2316         std::optional<uint32_t> in_packet_icmp_type = {},
2317         std::optional<uint32_t> in_packet_icmp_code = {},
2318         std::optional<uint32_t> in_packet_tcp_flags = {},
2319         std::optional<StringPool::Id> in_packet_tcp_flags_str = {},
2320         std::nullptr_t = nullptr)
RowRow2321         : SliceTable::Row(in_ts, in_dur, in_track_id, in_category, in_name, in_depth, in_stack_id, in_parent_stack_id, in_parent_id, in_arg_set_id, in_thread_ts, in_thread_dur, in_thread_instruction_count, in_thread_instruction_delta),
2322           iface(in_iface),
2323           direction(in_direction),
2324           packet_transport(in_packet_transport),
2325           packet_length(in_packet_length),
2326           packet_count(in_packet_count),
2327           socket_tag(in_socket_tag),
2328           socket_tag_str(in_socket_tag_str),
2329           socket_uid(in_socket_uid),
2330           local_port(in_local_port),
2331           remote_port(in_remote_port),
2332           packet_icmp_type(in_packet_icmp_type),
2333           packet_icmp_code(in_packet_icmp_code),
2334           packet_tcp_flags(in_packet_tcp_flags),
2335           packet_tcp_flags_str(in_packet_tcp_flags_str) {
2336       type_ = "__intrinsic_android_network_packets";
2337     }
2338     StringPool::Id iface;
2339     StringPool::Id direction;
2340     StringPool::Id packet_transport;
2341     int64_t packet_length;
2342     int64_t packet_count;
2343     uint32_t socket_tag;
2344     StringPool::Id socket_tag_str;
2345     uint32_t socket_uid;
2346     std::optional<uint32_t> local_port;
2347     std::optional<uint32_t> remote_port;
2348     std::optional<uint32_t> packet_icmp_type;
2349     std::optional<uint32_t> packet_icmp_code;
2350     std::optional<uint32_t> packet_tcp_flags;
2351     std::optional<StringPool::Id> packet_tcp_flags_str;
2352 
2353     bool operator==(const AndroidNetworkPacketsTable::Row& other) const {
2354       return type() == other.type() && ColumnType::ts::Equals(ts, other.ts) &&
2355        ColumnType::dur::Equals(dur, other.dur) &&
2356        ColumnType::track_id::Equals(track_id, other.track_id) &&
2357        ColumnType::category::Equals(category, other.category) &&
2358        ColumnType::name::Equals(name, other.name) &&
2359        ColumnType::depth::Equals(depth, other.depth) &&
2360        ColumnType::stack_id::Equals(stack_id, other.stack_id) &&
2361        ColumnType::parent_stack_id::Equals(parent_stack_id, other.parent_stack_id) &&
2362        ColumnType::parent_id::Equals(parent_id, other.parent_id) &&
2363        ColumnType::arg_set_id::Equals(arg_set_id, other.arg_set_id) &&
2364        ColumnType::thread_ts::Equals(thread_ts, other.thread_ts) &&
2365        ColumnType::thread_dur::Equals(thread_dur, other.thread_dur) &&
2366        ColumnType::thread_instruction_count::Equals(thread_instruction_count, other.thread_instruction_count) &&
2367        ColumnType::thread_instruction_delta::Equals(thread_instruction_delta, other.thread_instruction_delta) &&
2368        ColumnType::iface::Equals(iface, other.iface) &&
2369        ColumnType::direction::Equals(direction, other.direction) &&
2370        ColumnType::packet_transport::Equals(packet_transport, other.packet_transport) &&
2371        ColumnType::packet_length::Equals(packet_length, other.packet_length) &&
2372        ColumnType::packet_count::Equals(packet_count, other.packet_count) &&
2373        ColumnType::socket_tag::Equals(socket_tag, other.socket_tag) &&
2374        ColumnType::socket_tag_str::Equals(socket_tag_str, other.socket_tag_str) &&
2375        ColumnType::socket_uid::Equals(socket_uid, other.socket_uid) &&
2376        ColumnType::local_port::Equals(local_port, other.local_port) &&
2377        ColumnType::remote_port::Equals(remote_port, other.remote_port) &&
2378        ColumnType::packet_icmp_type::Equals(packet_icmp_type, other.packet_icmp_type) &&
2379        ColumnType::packet_icmp_code::Equals(packet_icmp_code, other.packet_icmp_code) &&
2380        ColumnType::packet_tcp_flags::Equals(packet_tcp_flags, other.packet_tcp_flags) &&
2381        ColumnType::packet_tcp_flags_str::Equals(packet_tcp_flags_str, other.packet_tcp_flags_str);
2382     }
2383   };
2384   struct ColumnFlag {
2385     static constexpr uint32_t iface = ColumnType::iface::default_flags();
2386     static constexpr uint32_t direction = ColumnType::direction::default_flags();
2387     static constexpr uint32_t packet_transport = ColumnType::packet_transport::default_flags();
2388     static constexpr uint32_t packet_length = ColumnType::packet_length::default_flags();
2389     static constexpr uint32_t packet_count = ColumnType::packet_count::default_flags();
2390     static constexpr uint32_t socket_tag = ColumnType::socket_tag::default_flags();
2391     static constexpr uint32_t socket_tag_str = ColumnType::socket_tag_str::default_flags();
2392     static constexpr uint32_t socket_uid = ColumnType::socket_uid::default_flags();
2393     static constexpr uint32_t local_port = ColumnType::local_port::default_flags();
2394     static constexpr uint32_t remote_port = ColumnType::remote_port::default_flags();
2395     static constexpr uint32_t packet_icmp_type = ColumnType::packet_icmp_type::default_flags();
2396     static constexpr uint32_t packet_icmp_code = ColumnType::packet_icmp_code::default_flags();
2397     static constexpr uint32_t packet_tcp_flags = ColumnType::packet_tcp_flags::default_flags();
2398     static constexpr uint32_t packet_tcp_flags_str = ColumnType::packet_tcp_flags_str::default_flags();
2399   };
2400 
2401   class RowNumber;
2402   class ConstRowReference;
2403   class RowReference;
2404 
2405   class RowNumber : public macros_internal::AbstractRowNumber<
2406       AndroidNetworkPacketsTable, ConstRowReference, RowReference> {
2407    public:
RowNumber(uint32_t row_number)2408     explicit RowNumber(uint32_t row_number)
2409         : AbstractRowNumber(row_number) {}
2410   };
2411   static_assert(std::is_trivially_destructible_v<RowNumber>,
2412                 "Inheritance used without trivial destruction");
2413 
2414   class ConstRowReference : public macros_internal::AbstractConstRowReference<
2415     AndroidNetworkPacketsTable, RowNumber> {
2416    public:
ConstRowReference(const AndroidNetworkPacketsTable * table,uint32_t row_number)2417     ConstRowReference(const AndroidNetworkPacketsTable* table, uint32_t row_number)
2418         : AbstractConstRowReference(table, row_number) {}
2419 
id()2420     ColumnType::id::type id() const {
2421       return table()->id()[row_number_];
2422     }
type()2423     ColumnType::type::type type() const {
2424       return table()->type()[row_number_];
2425     }
ts()2426     ColumnType::ts::type ts() const {
2427       return table()->ts()[row_number_];
2428     }
dur()2429     ColumnType::dur::type dur() const {
2430       return table()->dur()[row_number_];
2431     }
track_id()2432     ColumnType::track_id::type track_id() const {
2433       return table()->track_id()[row_number_];
2434     }
category()2435     ColumnType::category::type category() const {
2436       return table()->category()[row_number_];
2437     }
name()2438     ColumnType::name::type name() const {
2439       return table()->name()[row_number_];
2440     }
depth()2441     ColumnType::depth::type depth() const {
2442       return table()->depth()[row_number_];
2443     }
stack_id()2444     ColumnType::stack_id::type stack_id() const {
2445       return table()->stack_id()[row_number_];
2446     }
parent_stack_id()2447     ColumnType::parent_stack_id::type parent_stack_id() const {
2448       return table()->parent_stack_id()[row_number_];
2449     }
parent_id()2450     ColumnType::parent_id::type parent_id() const {
2451       return table()->parent_id()[row_number_];
2452     }
arg_set_id()2453     ColumnType::arg_set_id::type arg_set_id() const {
2454       return table()->arg_set_id()[row_number_];
2455     }
thread_ts()2456     ColumnType::thread_ts::type thread_ts() const {
2457       return table()->thread_ts()[row_number_];
2458     }
thread_dur()2459     ColumnType::thread_dur::type thread_dur() const {
2460       return table()->thread_dur()[row_number_];
2461     }
thread_instruction_count()2462     ColumnType::thread_instruction_count::type thread_instruction_count() const {
2463       return table()->thread_instruction_count()[row_number_];
2464     }
thread_instruction_delta()2465     ColumnType::thread_instruction_delta::type thread_instruction_delta() const {
2466       return table()->thread_instruction_delta()[row_number_];
2467     }
iface()2468     ColumnType::iface::type iface() const {
2469       return table()->iface()[row_number_];
2470     }
direction()2471     ColumnType::direction::type direction() const {
2472       return table()->direction()[row_number_];
2473     }
packet_transport()2474     ColumnType::packet_transport::type packet_transport() const {
2475       return table()->packet_transport()[row_number_];
2476     }
packet_length()2477     ColumnType::packet_length::type packet_length() const {
2478       return table()->packet_length()[row_number_];
2479     }
packet_count()2480     ColumnType::packet_count::type packet_count() const {
2481       return table()->packet_count()[row_number_];
2482     }
socket_tag()2483     ColumnType::socket_tag::type socket_tag() const {
2484       return table()->socket_tag()[row_number_];
2485     }
socket_tag_str()2486     ColumnType::socket_tag_str::type socket_tag_str() const {
2487       return table()->socket_tag_str()[row_number_];
2488     }
socket_uid()2489     ColumnType::socket_uid::type socket_uid() const {
2490       return table()->socket_uid()[row_number_];
2491     }
local_port()2492     ColumnType::local_port::type local_port() const {
2493       return table()->local_port()[row_number_];
2494     }
remote_port()2495     ColumnType::remote_port::type remote_port() const {
2496       return table()->remote_port()[row_number_];
2497     }
packet_icmp_type()2498     ColumnType::packet_icmp_type::type packet_icmp_type() const {
2499       return table()->packet_icmp_type()[row_number_];
2500     }
packet_icmp_code()2501     ColumnType::packet_icmp_code::type packet_icmp_code() const {
2502       return table()->packet_icmp_code()[row_number_];
2503     }
packet_tcp_flags()2504     ColumnType::packet_tcp_flags::type packet_tcp_flags() const {
2505       return table()->packet_tcp_flags()[row_number_];
2506     }
packet_tcp_flags_str()2507     ColumnType::packet_tcp_flags_str::type packet_tcp_flags_str() const {
2508       return table()->packet_tcp_flags_str()[row_number_];
2509     }
2510   };
2511   static_assert(std::is_trivially_destructible_v<ConstRowReference>,
2512                 "Inheritance used without trivial destruction");
2513   class RowReference : public ConstRowReference {
2514    public:
RowReference(const AndroidNetworkPacketsTable * table,uint32_t row_number)2515     RowReference(const AndroidNetworkPacketsTable* table, uint32_t row_number)
2516         : ConstRowReference(table, row_number) {}
2517 
set_ts(ColumnType::ts::non_optional_type v)2518     void set_ts(
2519         ColumnType::ts::non_optional_type v) {
2520       return mutable_table()->mutable_ts()->Set(row_number_, v);
2521     }
set_dur(ColumnType::dur::non_optional_type v)2522     void set_dur(
2523         ColumnType::dur::non_optional_type v) {
2524       return mutable_table()->mutable_dur()->Set(row_number_, v);
2525     }
set_track_id(ColumnType::track_id::non_optional_type v)2526     void set_track_id(
2527         ColumnType::track_id::non_optional_type v) {
2528       return mutable_table()->mutable_track_id()->Set(row_number_, v);
2529     }
set_category(ColumnType::category::non_optional_type v)2530     void set_category(
2531         ColumnType::category::non_optional_type v) {
2532       return mutable_table()->mutable_category()->Set(row_number_, v);
2533     }
set_name(ColumnType::name::non_optional_type v)2534     void set_name(
2535         ColumnType::name::non_optional_type v) {
2536       return mutable_table()->mutable_name()->Set(row_number_, v);
2537     }
set_depth(ColumnType::depth::non_optional_type v)2538     void set_depth(
2539         ColumnType::depth::non_optional_type v) {
2540       return mutable_table()->mutable_depth()->Set(row_number_, v);
2541     }
set_stack_id(ColumnType::stack_id::non_optional_type v)2542     void set_stack_id(
2543         ColumnType::stack_id::non_optional_type v) {
2544       return mutable_table()->mutable_stack_id()->Set(row_number_, v);
2545     }
set_parent_stack_id(ColumnType::parent_stack_id::non_optional_type v)2546     void set_parent_stack_id(
2547         ColumnType::parent_stack_id::non_optional_type v) {
2548       return mutable_table()->mutable_parent_stack_id()->Set(row_number_, v);
2549     }
set_parent_id(ColumnType::parent_id::non_optional_type v)2550     void set_parent_id(
2551         ColumnType::parent_id::non_optional_type v) {
2552       return mutable_table()->mutable_parent_id()->Set(row_number_, v);
2553     }
set_arg_set_id(ColumnType::arg_set_id::non_optional_type v)2554     void set_arg_set_id(
2555         ColumnType::arg_set_id::non_optional_type v) {
2556       return mutable_table()->mutable_arg_set_id()->Set(row_number_, v);
2557     }
set_thread_ts(ColumnType::thread_ts::non_optional_type v)2558     void set_thread_ts(
2559         ColumnType::thread_ts::non_optional_type v) {
2560       return mutable_table()->mutable_thread_ts()->Set(row_number_, v);
2561     }
set_thread_dur(ColumnType::thread_dur::non_optional_type v)2562     void set_thread_dur(
2563         ColumnType::thread_dur::non_optional_type v) {
2564       return mutable_table()->mutable_thread_dur()->Set(row_number_, v);
2565     }
set_thread_instruction_count(ColumnType::thread_instruction_count::non_optional_type v)2566     void set_thread_instruction_count(
2567         ColumnType::thread_instruction_count::non_optional_type v) {
2568       return mutable_table()->mutable_thread_instruction_count()->Set(row_number_, v);
2569     }
set_thread_instruction_delta(ColumnType::thread_instruction_delta::non_optional_type v)2570     void set_thread_instruction_delta(
2571         ColumnType::thread_instruction_delta::non_optional_type v) {
2572       return mutable_table()->mutable_thread_instruction_delta()->Set(row_number_, v);
2573     }
set_iface(ColumnType::iface::non_optional_type v)2574     void set_iface(
2575         ColumnType::iface::non_optional_type v) {
2576       return mutable_table()->mutable_iface()->Set(row_number_, v);
2577     }
set_direction(ColumnType::direction::non_optional_type v)2578     void set_direction(
2579         ColumnType::direction::non_optional_type v) {
2580       return mutable_table()->mutable_direction()->Set(row_number_, v);
2581     }
set_packet_transport(ColumnType::packet_transport::non_optional_type v)2582     void set_packet_transport(
2583         ColumnType::packet_transport::non_optional_type v) {
2584       return mutable_table()->mutable_packet_transport()->Set(row_number_, v);
2585     }
set_packet_length(ColumnType::packet_length::non_optional_type v)2586     void set_packet_length(
2587         ColumnType::packet_length::non_optional_type v) {
2588       return mutable_table()->mutable_packet_length()->Set(row_number_, v);
2589     }
set_packet_count(ColumnType::packet_count::non_optional_type v)2590     void set_packet_count(
2591         ColumnType::packet_count::non_optional_type v) {
2592       return mutable_table()->mutable_packet_count()->Set(row_number_, v);
2593     }
set_socket_tag(ColumnType::socket_tag::non_optional_type v)2594     void set_socket_tag(
2595         ColumnType::socket_tag::non_optional_type v) {
2596       return mutable_table()->mutable_socket_tag()->Set(row_number_, v);
2597     }
set_socket_tag_str(ColumnType::socket_tag_str::non_optional_type v)2598     void set_socket_tag_str(
2599         ColumnType::socket_tag_str::non_optional_type v) {
2600       return mutable_table()->mutable_socket_tag_str()->Set(row_number_, v);
2601     }
set_socket_uid(ColumnType::socket_uid::non_optional_type v)2602     void set_socket_uid(
2603         ColumnType::socket_uid::non_optional_type v) {
2604       return mutable_table()->mutable_socket_uid()->Set(row_number_, v);
2605     }
set_local_port(ColumnType::local_port::non_optional_type v)2606     void set_local_port(
2607         ColumnType::local_port::non_optional_type v) {
2608       return mutable_table()->mutable_local_port()->Set(row_number_, v);
2609     }
set_remote_port(ColumnType::remote_port::non_optional_type v)2610     void set_remote_port(
2611         ColumnType::remote_port::non_optional_type v) {
2612       return mutable_table()->mutable_remote_port()->Set(row_number_, v);
2613     }
set_packet_icmp_type(ColumnType::packet_icmp_type::non_optional_type v)2614     void set_packet_icmp_type(
2615         ColumnType::packet_icmp_type::non_optional_type v) {
2616       return mutable_table()->mutable_packet_icmp_type()->Set(row_number_, v);
2617     }
set_packet_icmp_code(ColumnType::packet_icmp_code::non_optional_type v)2618     void set_packet_icmp_code(
2619         ColumnType::packet_icmp_code::non_optional_type v) {
2620       return mutable_table()->mutable_packet_icmp_code()->Set(row_number_, v);
2621     }
set_packet_tcp_flags(ColumnType::packet_tcp_flags::non_optional_type v)2622     void set_packet_tcp_flags(
2623         ColumnType::packet_tcp_flags::non_optional_type v) {
2624       return mutable_table()->mutable_packet_tcp_flags()->Set(row_number_, v);
2625     }
set_packet_tcp_flags_str(ColumnType::packet_tcp_flags_str::non_optional_type v)2626     void set_packet_tcp_flags_str(
2627         ColumnType::packet_tcp_flags_str::non_optional_type v) {
2628       return mutable_table()->mutable_packet_tcp_flags_str()->Set(row_number_, v);
2629     }
2630 
2631    private:
mutable_table()2632     AndroidNetworkPacketsTable* mutable_table() const {
2633       return const_cast<AndroidNetworkPacketsTable*>(table());
2634     }
2635   };
2636   static_assert(std::is_trivially_destructible_v<RowReference>,
2637                 "Inheritance used without trivial destruction");
2638 
2639   class ConstIterator;
2640   class ConstIterator : public macros_internal::AbstractConstIterator<
2641     ConstIterator, AndroidNetworkPacketsTable, RowNumber, ConstRowReference> {
2642    public:
id()2643     ColumnType::id::type id() const {
2644       const auto& col = table()->id();
2645       return col.GetAtIdx(
2646         iterator_.StorageIndexForColumn(col.index_in_table()));
2647     }
type()2648     ColumnType::type::type type() const {
2649       const auto& col = table()->type();
2650       return col.GetAtIdx(
2651         iterator_.StorageIndexForColumn(col.index_in_table()));
2652     }
ts()2653     ColumnType::ts::type ts() const {
2654       const auto& col = table()->ts();
2655       return col.GetAtIdx(
2656         iterator_.StorageIndexForColumn(col.index_in_table()));
2657     }
dur()2658     ColumnType::dur::type dur() const {
2659       const auto& col = table()->dur();
2660       return col.GetAtIdx(
2661         iterator_.StorageIndexForColumn(col.index_in_table()));
2662     }
track_id()2663     ColumnType::track_id::type track_id() const {
2664       const auto& col = table()->track_id();
2665       return col.GetAtIdx(
2666         iterator_.StorageIndexForColumn(col.index_in_table()));
2667     }
category()2668     ColumnType::category::type category() const {
2669       const auto& col = table()->category();
2670       return col.GetAtIdx(
2671         iterator_.StorageIndexForColumn(col.index_in_table()));
2672     }
name()2673     ColumnType::name::type name() const {
2674       const auto& col = table()->name();
2675       return col.GetAtIdx(
2676         iterator_.StorageIndexForColumn(col.index_in_table()));
2677     }
depth()2678     ColumnType::depth::type depth() const {
2679       const auto& col = table()->depth();
2680       return col.GetAtIdx(
2681         iterator_.StorageIndexForColumn(col.index_in_table()));
2682     }
stack_id()2683     ColumnType::stack_id::type stack_id() const {
2684       const auto& col = table()->stack_id();
2685       return col.GetAtIdx(
2686         iterator_.StorageIndexForColumn(col.index_in_table()));
2687     }
parent_stack_id()2688     ColumnType::parent_stack_id::type parent_stack_id() const {
2689       const auto& col = table()->parent_stack_id();
2690       return col.GetAtIdx(
2691         iterator_.StorageIndexForColumn(col.index_in_table()));
2692     }
parent_id()2693     ColumnType::parent_id::type parent_id() const {
2694       const auto& col = table()->parent_id();
2695       return col.GetAtIdx(
2696         iterator_.StorageIndexForColumn(col.index_in_table()));
2697     }
arg_set_id()2698     ColumnType::arg_set_id::type arg_set_id() const {
2699       const auto& col = table()->arg_set_id();
2700       return col.GetAtIdx(
2701         iterator_.StorageIndexForColumn(col.index_in_table()));
2702     }
thread_ts()2703     ColumnType::thread_ts::type thread_ts() const {
2704       const auto& col = table()->thread_ts();
2705       return col.GetAtIdx(
2706         iterator_.StorageIndexForColumn(col.index_in_table()));
2707     }
thread_dur()2708     ColumnType::thread_dur::type thread_dur() const {
2709       const auto& col = table()->thread_dur();
2710       return col.GetAtIdx(
2711         iterator_.StorageIndexForColumn(col.index_in_table()));
2712     }
thread_instruction_count()2713     ColumnType::thread_instruction_count::type thread_instruction_count() const {
2714       const auto& col = table()->thread_instruction_count();
2715       return col.GetAtIdx(
2716         iterator_.StorageIndexForColumn(col.index_in_table()));
2717     }
thread_instruction_delta()2718     ColumnType::thread_instruction_delta::type thread_instruction_delta() const {
2719       const auto& col = table()->thread_instruction_delta();
2720       return col.GetAtIdx(
2721         iterator_.StorageIndexForColumn(col.index_in_table()));
2722     }
iface()2723     ColumnType::iface::type iface() const {
2724       const auto& col = table()->iface();
2725       return col.GetAtIdx(
2726         iterator_.StorageIndexForColumn(col.index_in_table()));
2727     }
direction()2728     ColumnType::direction::type direction() const {
2729       const auto& col = table()->direction();
2730       return col.GetAtIdx(
2731         iterator_.StorageIndexForColumn(col.index_in_table()));
2732     }
packet_transport()2733     ColumnType::packet_transport::type packet_transport() const {
2734       const auto& col = table()->packet_transport();
2735       return col.GetAtIdx(
2736         iterator_.StorageIndexForColumn(col.index_in_table()));
2737     }
packet_length()2738     ColumnType::packet_length::type packet_length() const {
2739       const auto& col = table()->packet_length();
2740       return col.GetAtIdx(
2741         iterator_.StorageIndexForColumn(col.index_in_table()));
2742     }
packet_count()2743     ColumnType::packet_count::type packet_count() const {
2744       const auto& col = table()->packet_count();
2745       return col.GetAtIdx(
2746         iterator_.StorageIndexForColumn(col.index_in_table()));
2747     }
socket_tag()2748     ColumnType::socket_tag::type socket_tag() const {
2749       const auto& col = table()->socket_tag();
2750       return col.GetAtIdx(
2751         iterator_.StorageIndexForColumn(col.index_in_table()));
2752     }
socket_tag_str()2753     ColumnType::socket_tag_str::type socket_tag_str() const {
2754       const auto& col = table()->socket_tag_str();
2755       return col.GetAtIdx(
2756         iterator_.StorageIndexForColumn(col.index_in_table()));
2757     }
socket_uid()2758     ColumnType::socket_uid::type socket_uid() const {
2759       const auto& col = table()->socket_uid();
2760       return col.GetAtIdx(
2761         iterator_.StorageIndexForColumn(col.index_in_table()));
2762     }
local_port()2763     ColumnType::local_port::type local_port() const {
2764       const auto& col = table()->local_port();
2765       return col.GetAtIdx(
2766         iterator_.StorageIndexForColumn(col.index_in_table()));
2767     }
remote_port()2768     ColumnType::remote_port::type remote_port() const {
2769       const auto& col = table()->remote_port();
2770       return col.GetAtIdx(
2771         iterator_.StorageIndexForColumn(col.index_in_table()));
2772     }
packet_icmp_type()2773     ColumnType::packet_icmp_type::type packet_icmp_type() const {
2774       const auto& col = table()->packet_icmp_type();
2775       return col.GetAtIdx(
2776         iterator_.StorageIndexForColumn(col.index_in_table()));
2777     }
packet_icmp_code()2778     ColumnType::packet_icmp_code::type packet_icmp_code() const {
2779       const auto& col = table()->packet_icmp_code();
2780       return col.GetAtIdx(
2781         iterator_.StorageIndexForColumn(col.index_in_table()));
2782     }
packet_tcp_flags()2783     ColumnType::packet_tcp_flags::type packet_tcp_flags() const {
2784       const auto& col = table()->packet_tcp_flags();
2785       return col.GetAtIdx(
2786         iterator_.StorageIndexForColumn(col.index_in_table()));
2787     }
packet_tcp_flags_str()2788     ColumnType::packet_tcp_flags_str::type packet_tcp_flags_str() const {
2789       const auto& col = table()->packet_tcp_flags_str();
2790       return col.GetAtIdx(
2791         iterator_.StorageIndexForColumn(col.index_in_table()));
2792     }
2793 
2794    protected:
ConstIterator(const AndroidNetworkPacketsTable * table,Table::Iterator iterator)2795     explicit ConstIterator(const AndroidNetworkPacketsTable* table,
2796                            Table::Iterator iterator)
2797         : AbstractConstIterator(table, std::move(iterator)) {}
2798 
CurrentRowNumber()2799     uint32_t CurrentRowNumber() const {
2800       return iterator_.StorageIndexForLastOverlay();
2801     }
2802 
2803    private:
2804     friend class AndroidNetworkPacketsTable;
2805     friend class macros_internal::AbstractConstIterator<
2806       ConstIterator, AndroidNetworkPacketsTable, RowNumber, ConstRowReference>;
2807   };
2808   class Iterator : public ConstIterator {
2809     public:
row_reference()2810      RowReference row_reference() const {
2811        return {const_cast<AndroidNetworkPacketsTable*>(table()), CurrentRowNumber()};
2812      }
2813 
2814     private:
2815      friend class AndroidNetworkPacketsTable;
2816 
Iterator(AndroidNetworkPacketsTable * table,Table::Iterator iterator)2817      explicit Iterator(AndroidNetworkPacketsTable* table, Table::Iterator iterator)
2818         : ConstIterator(table, std::move(iterator)) {}
2819   };
2820 
2821   struct IdAndRow {
2822     Id id;
2823     uint32_t row;
2824     RowReference row_reference;
2825     RowNumber row_number;
2826   };
2827 
GetColumns(AndroidNetworkPacketsTable * self,const macros_internal::MacroTable * parent)2828   static std::vector<ColumnLegacy> GetColumns(
2829       AndroidNetworkPacketsTable* self,
2830       const macros_internal::MacroTable* parent) {
2831     std::vector<ColumnLegacy> columns =
2832         CopyColumnsFromParentOrAddRootColumns(self, parent);
2833     uint32_t olay_idx = OverlayCount(parent);
2834     AddColumnToVector(columns, "iface", &self->iface_, ColumnFlag::iface,
2835                       static_cast<uint32_t>(columns.size()), olay_idx);
2836     AddColumnToVector(columns, "direction", &self->direction_, ColumnFlag::direction,
2837                       static_cast<uint32_t>(columns.size()), olay_idx);
2838     AddColumnToVector(columns, "packet_transport", &self->packet_transport_, ColumnFlag::packet_transport,
2839                       static_cast<uint32_t>(columns.size()), olay_idx);
2840     AddColumnToVector(columns, "packet_length", &self->packet_length_, ColumnFlag::packet_length,
2841                       static_cast<uint32_t>(columns.size()), olay_idx);
2842     AddColumnToVector(columns, "packet_count", &self->packet_count_, ColumnFlag::packet_count,
2843                       static_cast<uint32_t>(columns.size()), olay_idx);
2844     AddColumnToVector(columns, "socket_tag", &self->socket_tag_, ColumnFlag::socket_tag,
2845                       static_cast<uint32_t>(columns.size()), olay_idx);
2846     AddColumnToVector(columns, "socket_tag_str", &self->socket_tag_str_, ColumnFlag::socket_tag_str,
2847                       static_cast<uint32_t>(columns.size()), olay_idx);
2848     AddColumnToVector(columns, "socket_uid", &self->socket_uid_, ColumnFlag::socket_uid,
2849                       static_cast<uint32_t>(columns.size()), olay_idx);
2850     AddColumnToVector(columns, "local_port", &self->local_port_, ColumnFlag::local_port,
2851                       static_cast<uint32_t>(columns.size()), olay_idx);
2852     AddColumnToVector(columns, "remote_port", &self->remote_port_, ColumnFlag::remote_port,
2853                       static_cast<uint32_t>(columns.size()), olay_idx);
2854     AddColumnToVector(columns, "packet_icmp_type", &self->packet_icmp_type_, ColumnFlag::packet_icmp_type,
2855                       static_cast<uint32_t>(columns.size()), olay_idx);
2856     AddColumnToVector(columns, "packet_icmp_code", &self->packet_icmp_code_, ColumnFlag::packet_icmp_code,
2857                       static_cast<uint32_t>(columns.size()), olay_idx);
2858     AddColumnToVector(columns, "packet_tcp_flags", &self->packet_tcp_flags_, ColumnFlag::packet_tcp_flags,
2859                       static_cast<uint32_t>(columns.size()), olay_idx);
2860     AddColumnToVector(columns, "packet_tcp_flags_str", &self->packet_tcp_flags_str_, ColumnFlag::packet_tcp_flags_str,
2861                       static_cast<uint32_t>(columns.size()), olay_idx);
2862     return columns;
2863   }
2864 
AndroidNetworkPacketsTable(StringPool * pool,SliceTable * parent)2865   PERFETTO_NO_INLINE explicit AndroidNetworkPacketsTable(StringPool* pool, SliceTable* parent)
2866       : macros_internal::MacroTable(
2867           pool,
2868           GetColumns(this, parent),
2869           parent),
2870         parent_(parent), const_parent_(parent), iface_(ColumnStorage<ColumnType::iface::stored_type>::Create<false>()),
2871         direction_(ColumnStorage<ColumnType::direction::stored_type>::Create<false>()),
2872         packet_transport_(ColumnStorage<ColumnType::packet_transport::stored_type>::Create<false>()),
2873         packet_length_(ColumnStorage<ColumnType::packet_length::stored_type>::Create<false>()),
2874         packet_count_(ColumnStorage<ColumnType::packet_count::stored_type>::Create<false>()),
2875         socket_tag_(ColumnStorage<ColumnType::socket_tag::stored_type>::Create<false>()),
2876         socket_tag_str_(ColumnStorage<ColumnType::socket_tag_str::stored_type>::Create<false>()),
2877         socket_uid_(ColumnStorage<ColumnType::socket_uid::stored_type>::Create<false>()),
2878         local_port_(ColumnStorage<ColumnType::local_port::stored_type>::Create<false>()),
2879         remote_port_(ColumnStorage<ColumnType::remote_port::stored_type>::Create<false>()),
2880         packet_icmp_type_(ColumnStorage<ColumnType::packet_icmp_type::stored_type>::Create<false>()),
2881         packet_icmp_code_(ColumnStorage<ColumnType::packet_icmp_code::stored_type>::Create<false>()),
2882         packet_tcp_flags_(ColumnStorage<ColumnType::packet_tcp_flags::stored_type>::Create<false>()),
2883         packet_tcp_flags_str_(ColumnStorage<ColumnType::packet_tcp_flags_str::stored_type>::Create<false>())
2884 ,
2885         iface_storage_layer_(
2886           new column::StringStorage(string_pool(), &iface_.vector())),
2887         direction_storage_layer_(
2888           new column::StringStorage(string_pool(), &direction_.vector())),
2889         packet_transport_storage_layer_(
2890           new column::StringStorage(string_pool(), &packet_transport_.vector())),
2891         packet_length_storage_layer_(
2892         new column::NumericStorage<ColumnType::packet_length::non_optional_stored_type>(
2893           &packet_length_.vector(),
2894           ColumnTypeHelper<ColumnType::packet_length::stored_type>::ToColumnType(),
2895           false)),
2896         packet_count_storage_layer_(
2897         new column::NumericStorage<ColumnType::packet_count::non_optional_stored_type>(
2898           &packet_count_.vector(),
2899           ColumnTypeHelper<ColumnType::packet_count::stored_type>::ToColumnType(),
2900           false)),
2901         socket_tag_storage_layer_(
2902         new column::NumericStorage<ColumnType::socket_tag::non_optional_stored_type>(
2903           &socket_tag_.vector(),
2904           ColumnTypeHelper<ColumnType::socket_tag::stored_type>::ToColumnType(),
2905           false)),
2906         socket_tag_str_storage_layer_(
2907           new column::StringStorage(string_pool(), &socket_tag_str_.vector())),
2908         socket_uid_storage_layer_(
2909         new column::NumericStorage<ColumnType::socket_uid::non_optional_stored_type>(
2910           &socket_uid_.vector(),
2911           ColumnTypeHelper<ColumnType::socket_uid::stored_type>::ToColumnType(),
2912           false)),
2913         local_port_storage_layer_(
2914           new column::NumericStorage<ColumnType::local_port::non_optional_stored_type>(
2915             &local_port_.non_null_vector(),
2916             ColumnTypeHelper<ColumnType::local_port::stored_type>::ToColumnType(),
2917             false)),
2918         remote_port_storage_layer_(
2919           new column::NumericStorage<ColumnType::remote_port::non_optional_stored_type>(
2920             &remote_port_.non_null_vector(),
2921             ColumnTypeHelper<ColumnType::remote_port::stored_type>::ToColumnType(),
2922             false)),
2923         packet_icmp_type_storage_layer_(
2924           new column::NumericStorage<ColumnType::packet_icmp_type::non_optional_stored_type>(
2925             &packet_icmp_type_.non_null_vector(),
2926             ColumnTypeHelper<ColumnType::packet_icmp_type::stored_type>::ToColumnType(),
2927             false)),
2928         packet_icmp_code_storage_layer_(
2929           new column::NumericStorage<ColumnType::packet_icmp_code::non_optional_stored_type>(
2930             &packet_icmp_code_.non_null_vector(),
2931             ColumnTypeHelper<ColumnType::packet_icmp_code::stored_type>::ToColumnType(),
2932             false)),
2933         packet_tcp_flags_storage_layer_(
2934           new column::NumericStorage<ColumnType::packet_tcp_flags::non_optional_stored_type>(
2935             &packet_tcp_flags_.non_null_vector(),
2936             ColumnTypeHelper<ColumnType::packet_tcp_flags::stored_type>::ToColumnType(),
2937             false)),
2938         packet_tcp_flags_str_storage_layer_(
2939           new column::StringStorage(string_pool(), &packet_tcp_flags_str_.vector()))
2940 ,
2941         local_port_null_layer_(new column::NullOverlay(local_port_.bv())),
2942         remote_port_null_layer_(new column::NullOverlay(remote_port_.bv())),
2943         packet_icmp_type_null_layer_(new column::NullOverlay(packet_icmp_type_.bv())),
2944         packet_icmp_code_null_layer_(new column::NullOverlay(packet_icmp_code_.bv())),
2945         packet_tcp_flags_null_layer_(new column::NullOverlay(packet_tcp_flags_.bv())) {
2946     static_assert(
2947         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::iface::stored_type>(
2948           ColumnFlag::iface),
2949         "Column type and flag combination is not valid");
2950       static_assert(
2951         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::direction::stored_type>(
2952           ColumnFlag::direction),
2953         "Column type and flag combination is not valid");
2954       static_assert(
2955         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::packet_transport::stored_type>(
2956           ColumnFlag::packet_transport),
2957         "Column type and flag combination is not valid");
2958       static_assert(
2959         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::packet_length::stored_type>(
2960           ColumnFlag::packet_length),
2961         "Column type and flag combination is not valid");
2962       static_assert(
2963         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::packet_count::stored_type>(
2964           ColumnFlag::packet_count),
2965         "Column type and flag combination is not valid");
2966       static_assert(
2967         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::socket_tag::stored_type>(
2968           ColumnFlag::socket_tag),
2969         "Column type and flag combination is not valid");
2970       static_assert(
2971         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::socket_tag_str::stored_type>(
2972           ColumnFlag::socket_tag_str),
2973         "Column type and flag combination is not valid");
2974       static_assert(
2975         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::socket_uid::stored_type>(
2976           ColumnFlag::socket_uid),
2977         "Column type and flag combination is not valid");
2978       static_assert(
2979         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::local_port::stored_type>(
2980           ColumnFlag::local_port),
2981         "Column type and flag combination is not valid");
2982       static_assert(
2983         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::remote_port::stored_type>(
2984           ColumnFlag::remote_port),
2985         "Column type and flag combination is not valid");
2986       static_assert(
2987         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::packet_icmp_type::stored_type>(
2988           ColumnFlag::packet_icmp_type),
2989         "Column type and flag combination is not valid");
2990       static_assert(
2991         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::packet_icmp_code::stored_type>(
2992           ColumnFlag::packet_icmp_code),
2993         "Column type and flag combination is not valid");
2994       static_assert(
2995         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::packet_tcp_flags::stored_type>(
2996           ColumnFlag::packet_tcp_flags),
2997         "Column type and flag combination is not valid");
2998       static_assert(
2999         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::packet_tcp_flags_str::stored_type>(
3000           ColumnFlag::packet_tcp_flags_str),
3001         "Column type and flag combination is not valid");
3002     OnConstructionCompletedRegularConstructor(
3003       {const_parent_->storage_layers()[ColumnIndex::id],const_parent_->storage_layers()[ColumnIndex::type],const_parent_->storage_layers()[ColumnIndex::ts],const_parent_->storage_layers()[ColumnIndex::dur],const_parent_->storage_layers()[ColumnIndex::track_id],const_parent_->storage_layers()[ColumnIndex::category],const_parent_->storage_layers()[ColumnIndex::name],const_parent_->storage_layers()[ColumnIndex::depth],const_parent_->storage_layers()[ColumnIndex::stack_id],const_parent_->storage_layers()[ColumnIndex::parent_stack_id],const_parent_->storage_layers()[ColumnIndex::parent_id],const_parent_->storage_layers()[ColumnIndex::arg_set_id],const_parent_->storage_layers()[ColumnIndex::thread_ts],const_parent_->storage_layers()[ColumnIndex::thread_dur],const_parent_->storage_layers()[ColumnIndex::thread_instruction_count],const_parent_->storage_layers()[ColumnIndex::thread_instruction_delta],iface_storage_layer_,direction_storage_layer_,packet_transport_storage_layer_,packet_length_storage_layer_,packet_count_storage_layer_,socket_tag_storage_layer_,socket_tag_str_storage_layer_,socket_uid_storage_layer_,local_port_storage_layer_,remote_port_storage_layer_,packet_icmp_type_storage_layer_,packet_icmp_code_storage_layer_,packet_tcp_flags_storage_layer_,packet_tcp_flags_str_storage_layer_},
3004       {{},{},{},{},{},{},{},{},{},{},const_parent_->null_layers()[ColumnIndex::parent_id],{},const_parent_->null_layers()[ColumnIndex::thread_ts],const_parent_->null_layers()[ColumnIndex::thread_dur],const_parent_->null_layers()[ColumnIndex::thread_instruction_count],const_parent_->null_layers()[ColumnIndex::thread_instruction_delta],{},{},{},{},{},{},{},{},local_port_null_layer_,remote_port_null_layer_,packet_icmp_type_null_layer_,packet_icmp_code_null_layer_,packet_tcp_flags_null_layer_,{}});
3005   }
3006   ~AndroidNetworkPacketsTable() override;
3007 
Name()3008   static const char* Name() { return "__intrinsic_android_network_packets"; }
3009 
ComputeStaticSchema()3010   static Table::Schema ComputeStaticSchema() {
3011     Table::Schema schema;
3012     schema.columns.emplace_back(Table::Schema::Column{
3013         "id", SqlValue::Type::kLong, true, true, false, false});
3014     schema.columns.emplace_back(Table::Schema::Column{
3015         "type", SqlValue::Type::kString, false, false, false, false});
3016     schema.columns.emplace_back(Table::Schema::Column{
3017         "ts", ColumnType::ts::SqlValueType(), false,
3018         true,
3019         false,
3020         false});
3021     schema.columns.emplace_back(Table::Schema::Column{
3022         "dur", ColumnType::dur::SqlValueType(), false,
3023         false,
3024         false,
3025         false});
3026     schema.columns.emplace_back(Table::Schema::Column{
3027         "track_id", ColumnType::track_id::SqlValueType(), false,
3028         false,
3029         false,
3030         false});
3031     schema.columns.emplace_back(Table::Schema::Column{
3032         "category", ColumnType::category::SqlValueType(), false,
3033         false,
3034         false,
3035         false});
3036     schema.columns.emplace_back(Table::Schema::Column{
3037         "name", ColumnType::name::SqlValueType(), false,
3038         false,
3039         false,
3040         false});
3041     schema.columns.emplace_back(Table::Schema::Column{
3042         "depth", ColumnType::depth::SqlValueType(), false,
3043         false,
3044         false,
3045         false});
3046     schema.columns.emplace_back(Table::Schema::Column{
3047         "stack_id", ColumnType::stack_id::SqlValueType(), false,
3048         false,
3049         false,
3050         false});
3051     schema.columns.emplace_back(Table::Schema::Column{
3052         "parent_stack_id", ColumnType::parent_stack_id::SqlValueType(), false,
3053         false,
3054         false,
3055         false});
3056     schema.columns.emplace_back(Table::Schema::Column{
3057         "parent_id", ColumnType::parent_id::SqlValueType(), false,
3058         false,
3059         false,
3060         false});
3061     schema.columns.emplace_back(Table::Schema::Column{
3062         "arg_set_id", ColumnType::arg_set_id::SqlValueType(), false,
3063         false,
3064         false,
3065         false});
3066     schema.columns.emplace_back(Table::Schema::Column{
3067         "thread_ts", ColumnType::thread_ts::SqlValueType(), false,
3068         false,
3069         false,
3070         false});
3071     schema.columns.emplace_back(Table::Schema::Column{
3072         "thread_dur", ColumnType::thread_dur::SqlValueType(), false,
3073         false,
3074         false,
3075         false});
3076     schema.columns.emplace_back(Table::Schema::Column{
3077         "thread_instruction_count", ColumnType::thread_instruction_count::SqlValueType(), false,
3078         false,
3079         false,
3080         false});
3081     schema.columns.emplace_back(Table::Schema::Column{
3082         "thread_instruction_delta", ColumnType::thread_instruction_delta::SqlValueType(), false,
3083         false,
3084         false,
3085         false});
3086     schema.columns.emplace_back(Table::Schema::Column{
3087         "iface", ColumnType::iface::SqlValueType(), false,
3088         false,
3089         false,
3090         false});
3091     schema.columns.emplace_back(Table::Schema::Column{
3092         "direction", ColumnType::direction::SqlValueType(), false,
3093         false,
3094         false,
3095         false});
3096     schema.columns.emplace_back(Table::Schema::Column{
3097         "packet_transport", ColumnType::packet_transport::SqlValueType(), false,
3098         false,
3099         false,
3100         false});
3101     schema.columns.emplace_back(Table::Schema::Column{
3102         "packet_length", ColumnType::packet_length::SqlValueType(), false,
3103         false,
3104         false,
3105         false});
3106     schema.columns.emplace_back(Table::Schema::Column{
3107         "packet_count", ColumnType::packet_count::SqlValueType(), false,
3108         false,
3109         false,
3110         false});
3111     schema.columns.emplace_back(Table::Schema::Column{
3112         "socket_tag", ColumnType::socket_tag::SqlValueType(), false,
3113         false,
3114         false,
3115         false});
3116     schema.columns.emplace_back(Table::Schema::Column{
3117         "socket_tag_str", ColumnType::socket_tag_str::SqlValueType(), false,
3118         false,
3119         false,
3120         false});
3121     schema.columns.emplace_back(Table::Schema::Column{
3122         "socket_uid", ColumnType::socket_uid::SqlValueType(), false,
3123         false,
3124         false,
3125         false});
3126     schema.columns.emplace_back(Table::Schema::Column{
3127         "local_port", ColumnType::local_port::SqlValueType(), false,
3128         false,
3129         false,
3130         false});
3131     schema.columns.emplace_back(Table::Schema::Column{
3132         "remote_port", ColumnType::remote_port::SqlValueType(), false,
3133         false,
3134         false,
3135         false});
3136     schema.columns.emplace_back(Table::Schema::Column{
3137         "packet_icmp_type", ColumnType::packet_icmp_type::SqlValueType(), false,
3138         false,
3139         false,
3140         false});
3141     schema.columns.emplace_back(Table::Schema::Column{
3142         "packet_icmp_code", ColumnType::packet_icmp_code::SqlValueType(), false,
3143         false,
3144         false,
3145         false});
3146     schema.columns.emplace_back(Table::Schema::Column{
3147         "packet_tcp_flags", ColumnType::packet_tcp_flags::SqlValueType(), false,
3148         false,
3149         false,
3150         false});
3151     schema.columns.emplace_back(Table::Schema::Column{
3152         "packet_tcp_flags_str", ColumnType::packet_tcp_flags_str::SqlValueType(), false,
3153         false,
3154         false,
3155         false});
3156     return schema;
3157   }
3158 
IterateRows()3159   ConstIterator IterateRows() const {
3160     return ConstIterator(this, Table::IterateRows());
3161   }
3162 
IterateRows()3163   Iterator IterateRows() { return Iterator(this, Table::IterateRows()); }
3164 
FilterToIterator(const Query & q)3165   ConstIterator FilterToIterator(const Query& q) const {
3166     return ConstIterator(this, QueryToIterator(q));
3167   }
3168 
FilterToIterator(const Query & q)3169   Iterator FilterToIterator(const Query& q) {
3170     return Iterator(this, QueryToIterator(q));
3171   }
3172 
ShrinkToFit()3173   void ShrinkToFit() {
3174     iface_.ShrinkToFit();
3175     direction_.ShrinkToFit();
3176     packet_transport_.ShrinkToFit();
3177     packet_length_.ShrinkToFit();
3178     packet_count_.ShrinkToFit();
3179     socket_tag_.ShrinkToFit();
3180     socket_tag_str_.ShrinkToFit();
3181     socket_uid_.ShrinkToFit();
3182     local_port_.ShrinkToFit();
3183     remote_port_.ShrinkToFit();
3184     packet_icmp_type_.ShrinkToFit();
3185     packet_icmp_code_.ShrinkToFit();
3186     packet_tcp_flags_.ShrinkToFit();
3187     packet_tcp_flags_str_.ShrinkToFit();
3188   }
3189 
3190   ConstRowReference operator[](uint32_t r) const {
3191     return ConstRowReference(this, r);
3192   }
3193   RowReference operator[](uint32_t r) { return RowReference(this, r); }
3194   ConstRowReference operator[](RowNumber r) const {
3195     return ConstRowReference(this, r.row_number());
3196   }
3197   RowReference operator[](RowNumber r) {
3198     return RowReference(this, r.row_number());
3199   }
3200 
FindById(Id find_id)3201   std::optional<ConstRowReference> FindById(Id find_id) const {
3202     std::optional<uint32_t> row = id().IndexOf(find_id);
3203     return row ? std::make_optional(ConstRowReference(this, *row))
3204                : std::nullopt;
3205   }
3206 
FindById(Id find_id)3207   std::optional<RowReference> FindById(Id find_id) {
3208     std::optional<uint32_t> row = id().IndexOf(find_id);
3209     return row ? std::make_optional(RowReference(this, *row)) : std::nullopt;
3210   }
3211 
Insert(const Row & row)3212   IdAndRow Insert(const Row& row) {
3213     uint32_t row_number = row_count();
3214     Id id = Id{parent_->Insert(row).id};
3215     UpdateOverlaysAfterParentInsert();
3216     mutable_iface()->Append(row.iface);
3217     mutable_direction()->Append(row.direction);
3218     mutable_packet_transport()->Append(row.packet_transport);
3219     mutable_packet_length()->Append(row.packet_length);
3220     mutable_packet_count()->Append(row.packet_count);
3221     mutable_socket_tag()->Append(row.socket_tag);
3222     mutable_socket_tag_str()->Append(row.socket_tag_str);
3223     mutable_socket_uid()->Append(row.socket_uid);
3224     mutable_local_port()->Append(row.local_port);
3225     mutable_remote_port()->Append(row.remote_port);
3226     mutable_packet_icmp_type()->Append(row.packet_icmp_type);
3227     mutable_packet_icmp_code()->Append(row.packet_icmp_code);
3228     mutable_packet_tcp_flags()->Append(row.packet_tcp_flags);
3229     mutable_packet_tcp_flags_str()->Append(row.packet_tcp_flags_str);
3230     UpdateSelfOverlayAfterInsert();
3231     return IdAndRow{id, row_number, RowReference(this, row_number),
3232                      RowNumber(row_number)};
3233   }
3234 
ExtendParent(const SliceTable & parent,ColumnStorage<ColumnType::iface::stored_type> iface,ColumnStorage<ColumnType::direction::stored_type> direction,ColumnStorage<ColumnType::packet_transport::stored_type> packet_transport,ColumnStorage<ColumnType::packet_length::stored_type> packet_length,ColumnStorage<ColumnType::packet_count::stored_type> packet_count,ColumnStorage<ColumnType::socket_tag::stored_type> socket_tag,ColumnStorage<ColumnType::socket_tag_str::stored_type> socket_tag_str,ColumnStorage<ColumnType::socket_uid::stored_type> socket_uid,ColumnStorage<ColumnType::local_port::stored_type> local_port,ColumnStorage<ColumnType::remote_port::stored_type> remote_port,ColumnStorage<ColumnType::packet_icmp_type::stored_type> packet_icmp_type,ColumnStorage<ColumnType::packet_icmp_code::stored_type> packet_icmp_code,ColumnStorage<ColumnType::packet_tcp_flags::stored_type> packet_tcp_flags,ColumnStorage<ColumnType::packet_tcp_flags_str::stored_type> packet_tcp_flags_str)3235   static std::unique_ptr<AndroidNetworkPacketsTable> ExtendParent(
3236       const SliceTable& parent,
3237       ColumnStorage<ColumnType::iface::stored_type> iface
3238 , ColumnStorage<ColumnType::direction::stored_type> direction
3239 , ColumnStorage<ColumnType::packet_transport::stored_type> packet_transport
3240 , ColumnStorage<ColumnType::packet_length::stored_type> packet_length
3241 , ColumnStorage<ColumnType::packet_count::stored_type> packet_count
3242 , ColumnStorage<ColumnType::socket_tag::stored_type> socket_tag
3243 , ColumnStorage<ColumnType::socket_tag_str::stored_type> socket_tag_str
3244 , ColumnStorage<ColumnType::socket_uid::stored_type> socket_uid
3245 , ColumnStorage<ColumnType::local_port::stored_type> local_port
3246 , ColumnStorage<ColumnType::remote_port::stored_type> remote_port
3247 , ColumnStorage<ColumnType::packet_icmp_type::stored_type> packet_icmp_type
3248 , ColumnStorage<ColumnType::packet_icmp_code::stored_type> packet_icmp_code
3249 , ColumnStorage<ColumnType::packet_tcp_flags::stored_type> packet_tcp_flags
3250 , ColumnStorage<ColumnType::packet_tcp_flags_str::stored_type> packet_tcp_flags_str) {
3251     return std::unique_ptr<AndroidNetworkPacketsTable>(new AndroidNetworkPacketsTable(
3252         parent.string_pool(), parent, RowMap(0, parent.row_count()),
3253         std::move(iface), std::move(direction), std::move(packet_transport), std::move(packet_length), std::move(packet_count), std::move(socket_tag), std::move(socket_tag_str), std::move(socket_uid), std::move(local_port), std::move(remote_port), std::move(packet_icmp_type), std::move(packet_icmp_code), std::move(packet_tcp_flags), std::move(packet_tcp_flags_str)));
3254   }
3255 
SelectAndExtendParent(const SliceTable & parent,std::vector<SliceTable::RowNumber> parent_overlay,ColumnStorage<ColumnType::iface::stored_type> iface,ColumnStorage<ColumnType::direction::stored_type> direction,ColumnStorage<ColumnType::packet_transport::stored_type> packet_transport,ColumnStorage<ColumnType::packet_length::stored_type> packet_length,ColumnStorage<ColumnType::packet_count::stored_type> packet_count,ColumnStorage<ColumnType::socket_tag::stored_type> socket_tag,ColumnStorage<ColumnType::socket_tag_str::stored_type> socket_tag_str,ColumnStorage<ColumnType::socket_uid::stored_type> socket_uid,ColumnStorage<ColumnType::local_port::stored_type> local_port,ColumnStorage<ColumnType::remote_port::stored_type> remote_port,ColumnStorage<ColumnType::packet_icmp_type::stored_type> packet_icmp_type,ColumnStorage<ColumnType::packet_icmp_code::stored_type> packet_icmp_code,ColumnStorage<ColumnType::packet_tcp_flags::stored_type> packet_tcp_flags,ColumnStorage<ColumnType::packet_tcp_flags_str::stored_type> packet_tcp_flags_str)3256   static std::unique_ptr<AndroidNetworkPacketsTable> SelectAndExtendParent(
3257       const SliceTable& parent,
3258       std::vector<SliceTable::RowNumber> parent_overlay,
3259       ColumnStorage<ColumnType::iface::stored_type> iface
3260 , ColumnStorage<ColumnType::direction::stored_type> direction
3261 , ColumnStorage<ColumnType::packet_transport::stored_type> packet_transport
3262 , ColumnStorage<ColumnType::packet_length::stored_type> packet_length
3263 , ColumnStorage<ColumnType::packet_count::stored_type> packet_count
3264 , ColumnStorage<ColumnType::socket_tag::stored_type> socket_tag
3265 , ColumnStorage<ColumnType::socket_tag_str::stored_type> socket_tag_str
3266 , ColumnStorage<ColumnType::socket_uid::stored_type> socket_uid
3267 , ColumnStorage<ColumnType::local_port::stored_type> local_port
3268 , ColumnStorage<ColumnType::remote_port::stored_type> remote_port
3269 , ColumnStorage<ColumnType::packet_icmp_type::stored_type> packet_icmp_type
3270 , ColumnStorage<ColumnType::packet_icmp_code::stored_type> packet_icmp_code
3271 , ColumnStorage<ColumnType::packet_tcp_flags::stored_type> packet_tcp_flags
3272 , ColumnStorage<ColumnType::packet_tcp_flags_str::stored_type> packet_tcp_flags_str) {
3273     std::vector<uint32_t> prs_untyped(parent_overlay.size());
3274     for (uint32_t i = 0; i < parent_overlay.size(); ++i) {
3275       prs_untyped[i] = parent_overlay[i].row_number();
3276     }
3277     return std::unique_ptr<AndroidNetworkPacketsTable>(new AndroidNetworkPacketsTable(
3278         parent.string_pool(), parent, RowMap(std::move(prs_untyped)),
3279         std::move(iface), std::move(direction), std::move(packet_transport), std::move(packet_length), std::move(packet_count), std::move(socket_tag), std::move(socket_tag_str), std::move(socket_uid), std::move(local_port), std::move(remote_port), std::move(packet_icmp_type), std::move(packet_icmp_code), std::move(packet_tcp_flags), std::move(packet_tcp_flags_str)));
3280   }
3281 
id()3282   const IdColumn<AndroidNetworkPacketsTable::Id>& id() const {
3283     return static_cast<const ColumnType::id&>(columns()[ColumnIndex::id]);
3284   }
type()3285   const TypedColumn<StringPool::Id>& type() const {
3286     return static_cast<const ColumnType::type&>(columns()[ColumnIndex::type]);
3287   }
ts()3288   const TypedColumn<int64_t>& ts() const {
3289     return static_cast<const ColumnType::ts&>(columns()[ColumnIndex::ts]);
3290   }
dur()3291   const TypedColumn<int64_t>& dur() const {
3292     return static_cast<const ColumnType::dur&>(columns()[ColumnIndex::dur]);
3293   }
track_id()3294   const TypedColumn<TrackTable::Id>& track_id() const {
3295     return static_cast<const ColumnType::track_id&>(columns()[ColumnIndex::track_id]);
3296   }
category()3297   const TypedColumn<std::optional<StringPool::Id>>& category() const {
3298     return static_cast<const ColumnType::category&>(columns()[ColumnIndex::category]);
3299   }
name()3300   const TypedColumn<std::optional<StringPool::Id>>& name() const {
3301     return static_cast<const ColumnType::name&>(columns()[ColumnIndex::name]);
3302   }
depth()3303   const TypedColumn<uint32_t>& depth() const {
3304     return static_cast<const ColumnType::depth&>(columns()[ColumnIndex::depth]);
3305   }
stack_id()3306   const TypedColumn<int64_t>& stack_id() const {
3307     return static_cast<const ColumnType::stack_id&>(columns()[ColumnIndex::stack_id]);
3308   }
parent_stack_id()3309   const TypedColumn<int64_t>& parent_stack_id() const {
3310     return static_cast<const ColumnType::parent_stack_id&>(columns()[ColumnIndex::parent_stack_id]);
3311   }
parent_id()3312   const TypedColumn<std::optional<AndroidNetworkPacketsTable::Id>>& parent_id() const {
3313     return static_cast<const ColumnType::parent_id&>(columns()[ColumnIndex::parent_id]);
3314   }
arg_set_id()3315   const TypedColumn<uint32_t>& arg_set_id() const {
3316     return static_cast<const ColumnType::arg_set_id&>(columns()[ColumnIndex::arg_set_id]);
3317   }
thread_ts()3318   const TypedColumn<std::optional<int64_t>>& thread_ts() const {
3319     return static_cast<const ColumnType::thread_ts&>(columns()[ColumnIndex::thread_ts]);
3320   }
thread_dur()3321   const TypedColumn<std::optional<int64_t>>& thread_dur() const {
3322     return static_cast<const ColumnType::thread_dur&>(columns()[ColumnIndex::thread_dur]);
3323   }
thread_instruction_count()3324   const TypedColumn<std::optional<int64_t>>& thread_instruction_count() const {
3325     return static_cast<const ColumnType::thread_instruction_count&>(columns()[ColumnIndex::thread_instruction_count]);
3326   }
thread_instruction_delta()3327   const TypedColumn<std::optional<int64_t>>& thread_instruction_delta() const {
3328     return static_cast<const ColumnType::thread_instruction_delta&>(columns()[ColumnIndex::thread_instruction_delta]);
3329   }
iface()3330   const TypedColumn<StringPool::Id>& iface() const {
3331     return static_cast<const ColumnType::iface&>(columns()[ColumnIndex::iface]);
3332   }
direction()3333   const TypedColumn<StringPool::Id>& direction() const {
3334     return static_cast<const ColumnType::direction&>(columns()[ColumnIndex::direction]);
3335   }
packet_transport()3336   const TypedColumn<StringPool::Id>& packet_transport() const {
3337     return static_cast<const ColumnType::packet_transport&>(columns()[ColumnIndex::packet_transport]);
3338   }
packet_length()3339   const TypedColumn<int64_t>& packet_length() const {
3340     return static_cast<const ColumnType::packet_length&>(columns()[ColumnIndex::packet_length]);
3341   }
packet_count()3342   const TypedColumn<int64_t>& packet_count() const {
3343     return static_cast<const ColumnType::packet_count&>(columns()[ColumnIndex::packet_count]);
3344   }
socket_tag()3345   const TypedColumn<uint32_t>& socket_tag() const {
3346     return static_cast<const ColumnType::socket_tag&>(columns()[ColumnIndex::socket_tag]);
3347   }
socket_tag_str()3348   const TypedColumn<StringPool::Id>& socket_tag_str() const {
3349     return static_cast<const ColumnType::socket_tag_str&>(columns()[ColumnIndex::socket_tag_str]);
3350   }
socket_uid()3351   const TypedColumn<uint32_t>& socket_uid() const {
3352     return static_cast<const ColumnType::socket_uid&>(columns()[ColumnIndex::socket_uid]);
3353   }
local_port()3354   const TypedColumn<std::optional<uint32_t>>& local_port() const {
3355     return static_cast<const ColumnType::local_port&>(columns()[ColumnIndex::local_port]);
3356   }
remote_port()3357   const TypedColumn<std::optional<uint32_t>>& remote_port() const {
3358     return static_cast<const ColumnType::remote_port&>(columns()[ColumnIndex::remote_port]);
3359   }
packet_icmp_type()3360   const TypedColumn<std::optional<uint32_t>>& packet_icmp_type() const {
3361     return static_cast<const ColumnType::packet_icmp_type&>(columns()[ColumnIndex::packet_icmp_type]);
3362   }
packet_icmp_code()3363   const TypedColumn<std::optional<uint32_t>>& packet_icmp_code() const {
3364     return static_cast<const ColumnType::packet_icmp_code&>(columns()[ColumnIndex::packet_icmp_code]);
3365   }
packet_tcp_flags()3366   const TypedColumn<std::optional<uint32_t>>& packet_tcp_flags() const {
3367     return static_cast<const ColumnType::packet_tcp_flags&>(columns()[ColumnIndex::packet_tcp_flags]);
3368   }
packet_tcp_flags_str()3369   const TypedColumn<std::optional<StringPool::Id>>& packet_tcp_flags_str() const {
3370     return static_cast<const ColumnType::packet_tcp_flags_str&>(columns()[ColumnIndex::packet_tcp_flags_str]);
3371   }
3372 
mutable_ts()3373   TypedColumn<int64_t>* mutable_ts() {
3374     return static_cast<ColumnType::ts*>(
3375         GetColumn(ColumnIndex::ts));
3376   }
mutable_dur()3377   TypedColumn<int64_t>* mutable_dur() {
3378     return static_cast<ColumnType::dur*>(
3379         GetColumn(ColumnIndex::dur));
3380   }
mutable_track_id()3381   TypedColumn<TrackTable::Id>* mutable_track_id() {
3382     return static_cast<ColumnType::track_id*>(
3383         GetColumn(ColumnIndex::track_id));
3384   }
mutable_category()3385   TypedColumn<std::optional<StringPool::Id>>* mutable_category() {
3386     return static_cast<ColumnType::category*>(
3387         GetColumn(ColumnIndex::category));
3388   }
mutable_name()3389   TypedColumn<std::optional<StringPool::Id>>* mutable_name() {
3390     return static_cast<ColumnType::name*>(
3391         GetColumn(ColumnIndex::name));
3392   }
mutable_depth()3393   TypedColumn<uint32_t>* mutable_depth() {
3394     return static_cast<ColumnType::depth*>(
3395         GetColumn(ColumnIndex::depth));
3396   }
mutable_stack_id()3397   TypedColumn<int64_t>* mutable_stack_id() {
3398     return static_cast<ColumnType::stack_id*>(
3399         GetColumn(ColumnIndex::stack_id));
3400   }
mutable_parent_stack_id()3401   TypedColumn<int64_t>* mutable_parent_stack_id() {
3402     return static_cast<ColumnType::parent_stack_id*>(
3403         GetColumn(ColumnIndex::parent_stack_id));
3404   }
mutable_parent_id()3405   TypedColumn<std::optional<AndroidNetworkPacketsTable::Id>>* mutable_parent_id() {
3406     return static_cast<ColumnType::parent_id*>(
3407         GetColumn(ColumnIndex::parent_id));
3408   }
mutable_arg_set_id()3409   TypedColumn<uint32_t>* mutable_arg_set_id() {
3410     return static_cast<ColumnType::arg_set_id*>(
3411         GetColumn(ColumnIndex::arg_set_id));
3412   }
mutable_thread_ts()3413   TypedColumn<std::optional<int64_t>>* mutable_thread_ts() {
3414     return static_cast<ColumnType::thread_ts*>(
3415         GetColumn(ColumnIndex::thread_ts));
3416   }
mutable_thread_dur()3417   TypedColumn<std::optional<int64_t>>* mutable_thread_dur() {
3418     return static_cast<ColumnType::thread_dur*>(
3419         GetColumn(ColumnIndex::thread_dur));
3420   }
mutable_thread_instruction_count()3421   TypedColumn<std::optional<int64_t>>* mutable_thread_instruction_count() {
3422     return static_cast<ColumnType::thread_instruction_count*>(
3423         GetColumn(ColumnIndex::thread_instruction_count));
3424   }
mutable_thread_instruction_delta()3425   TypedColumn<std::optional<int64_t>>* mutable_thread_instruction_delta() {
3426     return static_cast<ColumnType::thread_instruction_delta*>(
3427         GetColumn(ColumnIndex::thread_instruction_delta));
3428   }
mutable_iface()3429   TypedColumn<StringPool::Id>* mutable_iface() {
3430     return static_cast<ColumnType::iface*>(
3431         GetColumn(ColumnIndex::iface));
3432   }
mutable_direction()3433   TypedColumn<StringPool::Id>* mutable_direction() {
3434     return static_cast<ColumnType::direction*>(
3435         GetColumn(ColumnIndex::direction));
3436   }
mutable_packet_transport()3437   TypedColumn<StringPool::Id>* mutable_packet_transport() {
3438     return static_cast<ColumnType::packet_transport*>(
3439         GetColumn(ColumnIndex::packet_transport));
3440   }
mutable_packet_length()3441   TypedColumn<int64_t>* mutable_packet_length() {
3442     return static_cast<ColumnType::packet_length*>(
3443         GetColumn(ColumnIndex::packet_length));
3444   }
mutable_packet_count()3445   TypedColumn<int64_t>* mutable_packet_count() {
3446     return static_cast<ColumnType::packet_count*>(
3447         GetColumn(ColumnIndex::packet_count));
3448   }
mutable_socket_tag()3449   TypedColumn<uint32_t>* mutable_socket_tag() {
3450     return static_cast<ColumnType::socket_tag*>(
3451         GetColumn(ColumnIndex::socket_tag));
3452   }
mutable_socket_tag_str()3453   TypedColumn<StringPool::Id>* mutable_socket_tag_str() {
3454     return static_cast<ColumnType::socket_tag_str*>(
3455         GetColumn(ColumnIndex::socket_tag_str));
3456   }
mutable_socket_uid()3457   TypedColumn<uint32_t>* mutable_socket_uid() {
3458     return static_cast<ColumnType::socket_uid*>(
3459         GetColumn(ColumnIndex::socket_uid));
3460   }
mutable_local_port()3461   TypedColumn<std::optional<uint32_t>>* mutable_local_port() {
3462     return static_cast<ColumnType::local_port*>(
3463         GetColumn(ColumnIndex::local_port));
3464   }
mutable_remote_port()3465   TypedColumn<std::optional<uint32_t>>* mutable_remote_port() {
3466     return static_cast<ColumnType::remote_port*>(
3467         GetColumn(ColumnIndex::remote_port));
3468   }
mutable_packet_icmp_type()3469   TypedColumn<std::optional<uint32_t>>* mutable_packet_icmp_type() {
3470     return static_cast<ColumnType::packet_icmp_type*>(
3471         GetColumn(ColumnIndex::packet_icmp_type));
3472   }
mutable_packet_icmp_code()3473   TypedColumn<std::optional<uint32_t>>* mutable_packet_icmp_code() {
3474     return static_cast<ColumnType::packet_icmp_code*>(
3475         GetColumn(ColumnIndex::packet_icmp_code));
3476   }
mutable_packet_tcp_flags()3477   TypedColumn<std::optional<uint32_t>>* mutable_packet_tcp_flags() {
3478     return static_cast<ColumnType::packet_tcp_flags*>(
3479         GetColumn(ColumnIndex::packet_tcp_flags));
3480   }
mutable_packet_tcp_flags_str()3481   TypedColumn<std::optional<StringPool::Id>>* mutable_packet_tcp_flags_str() {
3482     return static_cast<ColumnType::packet_tcp_flags_str*>(
3483         GetColumn(ColumnIndex::packet_tcp_flags_str));
3484   }
3485 
3486  private:
AndroidNetworkPacketsTable(StringPool * pool,const SliceTable & parent,const RowMap & parent_overlay,ColumnStorage<ColumnType::iface::stored_type> iface,ColumnStorage<ColumnType::direction::stored_type> direction,ColumnStorage<ColumnType::packet_transport::stored_type> packet_transport,ColumnStorage<ColumnType::packet_length::stored_type> packet_length,ColumnStorage<ColumnType::packet_count::stored_type> packet_count,ColumnStorage<ColumnType::socket_tag::stored_type> socket_tag,ColumnStorage<ColumnType::socket_tag_str::stored_type> socket_tag_str,ColumnStorage<ColumnType::socket_uid::stored_type> socket_uid,ColumnStorage<ColumnType::local_port::stored_type> local_port,ColumnStorage<ColumnType::remote_port::stored_type> remote_port,ColumnStorage<ColumnType::packet_icmp_type::stored_type> packet_icmp_type,ColumnStorage<ColumnType::packet_icmp_code::stored_type> packet_icmp_code,ColumnStorage<ColumnType::packet_tcp_flags::stored_type> packet_tcp_flags,ColumnStorage<ColumnType::packet_tcp_flags_str::stored_type> packet_tcp_flags_str)3487   AndroidNetworkPacketsTable(StringPool* pool,
3488             const SliceTable& parent,
3489             const RowMap& parent_overlay,
3490             ColumnStorage<ColumnType::iface::stored_type> iface
3491 , ColumnStorage<ColumnType::direction::stored_type> direction
3492 , ColumnStorage<ColumnType::packet_transport::stored_type> packet_transport
3493 , ColumnStorage<ColumnType::packet_length::stored_type> packet_length
3494 , ColumnStorage<ColumnType::packet_count::stored_type> packet_count
3495 , ColumnStorage<ColumnType::socket_tag::stored_type> socket_tag
3496 , ColumnStorage<ColumnType::socket_tag_str::stored_type> socket_tag_str
3497 , ColumnStorage<ColumnType::socket_uid::stored_type> socket_uid
3498 , ColumnStorage<ColumnType::local_port::stored_type> local_port
3499 , ColumnStorage<ColumnType::remote_port::stored_type> remote_port
3500 , ColumnStorage<ColumnType::packet_icmp_type::stored_type> packet_icmp_type
3501 , ColumnStorage<ColumnType::packet_icmp_code::stored_type> packet_icmp_code
3502 , ColumnStorage<ColumnType::packet_tcp_flags::stored_type> packet_tcp_flags
3503 , ColumnStorage<ColumnType::packet_tcp_flags_str::stored_type> packet_tcp_flags_str)
3504       : macros_internal::MacroTable(
3505           pool,
3506           GetColumns(this, &parent),
3507           parent,
3508           parent_overlay),
3509           const_parent_(&parent)
3510 ,
3511         iface_storage_layer_(
3512           new column::StringStorage(string_pool(), &iface_.vector())),
3513         direction_storage_layer_(
3514           new column::StringStorage(string_pool(), &direction_.vector())),
3515         packet_transport_storage_layer_(
3516           new column::StringStorage(string_pool(), &packet_transport_.vector())),
3517         packet_length_storage_layer_(
3518         new column::NumericStorage<ColumnType::packet_length::non_optional_stored_type>(
3519           &packet_length_.vector(),
3520           ColumnTypeHelper<ColumnType::packet_length::stored_type>::ToColumnType(),
3521           false)),
3522         packet_count_storage_layer_(
3523         new column::NumericStorage<ColumnType::packet_count::non_optional_stored_type>(
3524           &packet_count_.vector(),
3525           ColumnTypeHelper<ColumnType::packet_count::stored_type>::ToColumnType(),
3526           false)),
3527         socket_tag_storage_layer_(
3528         new column::NumericStorage<ColumnType::socket_tag::non_optional_stored_type>(
3529           &socket_tag_.vector(),
3530           ColumnTypeHelper<ColumnType::socket_tag::stored_type>::ToColumnType(),
3531           false)),
3532         socket_tag_str_storage_layer_(
3533           new column::StringStorage(string_pool(), &socket_tag_str_.vector())),
3534         socket_uid_storage_layer_(
3535         new column::NumericStorage<ColumnType::socket_uid::non_optional_stored_type>(
3536           &socket_uid_.vector(),
3537           ColumnTypeHelper<ColumnType::socket_uid::stored_type>::ToColumnType(),
3538           false)),
3539         local_port_storage_layer_(
3540           new column::NumericStorage<ColumnType::local_port::non_optional_stored_type>(
3541             &local_port_.non_null_vector(),
3542             ColumnTypeHelper<ColumnType::local_port::stored_type>::ToColumnType(),
3543             false)),
3544         remote_port_storage_layer_(
3545           new column::NumericStorage<ColumnType::remote_port::non_optional_stored_type>(
3546             &remote_port_.non_null_vector(),
3547             ColumnTypeHelper<ColumnType::remote_port::stored_type>::ToColumnType(),
3548             false)),
3549         packet_icmp_type_storage_layer_(
3550           new column::NumericStorage<ColumnType::packet_icmp_type::non_optional_stored_type>(
3551             &packet_icmp_type_.non_null_vector(),
3552             ColumnTypeHelper<ColumnType::packet_icmp_type::stored_type>::ToColumnType(),
3553             false)),
3554         packet_icmp_code_storage_layer_(
3555           new column::NumericStorage<ColumnType::packet_icmp_code::non_optional_stored_type>(
3556             &packet_icmp_code_.non_null_vector(),
3557             ColumnTypeHelper<ColumnType::packet_icmp_code::stored_type>::ToColumnType(),
3558             false)),
3559         packet_tcp_flags_storage_layer_(
3560           new column::NumericStorage<ColumnType::packet_tcp_flags::non_optional_stored_type>(
3561             &packet_tcp_flags_.non_null_vector(),
3562             ColumnTypeHelper<ColumnType::packet_tcp_flags::stored_type>::ToColumnType(),
3563             false)),
3564         packet_tcp_flags_str_storage_layer_(
3565           new column::StringStorage(string_pool(), &packet_tcp_flags_str_.vector()))
3566 ,
3567         local_port_null_layer_(new column::NullOverlay(local_port_.bv())),
3568         remote_port_null_layer_(new column::NullOverlay(remote_port_.bv())),
3569         packet_icmp_type_null_layer_(new column::NullOverlay(packet_icmp_type_.bv())),
3570         packet_icmp_code_null_layer_(new column::NullOverlay(packet_icmp_code_.bv())),
3571         packet_tcp_flags_null_layer_(new column::NullOverlay(packet_tcp_flags_.bv())) {
3572     static_assert(
3573         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::iface::stored_type>(
3574           ColumnFlag::iface),
3575         "Column type and flag combination is not valid");
3576       static_assert(
3577         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::direction::stored_type>(
3578           ColumnFlag::direction),
3579         "Column type and flag combination is not valid");
3580       static_assert(
3581         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::packet_transport::stored_type>(
3582           ColumnFlag::packet_transport),
3583         "Column type and flag combination is not valid");
3584       static_assert(
3585         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::packet_length::stored_type>(
3586           ColumnFlag::packet_length),
3587         "Column type and flag combination is not valid");
3588       static_assert(
3589         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::packet_count::stored_type>(
3590           ColumnFlag::packet_count),
3591         "Column type and flag combination is not valid");
3592       static_assert(
3593         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::socket_tag::stored_type>(
3594           ColumnFlag::socket_tag),
3595         "Column type and flag combination is not valid");
3596       static_assert(
3597         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::socket_tag_str::stored_type>(
3598           ColumnFlag::socket_tag_str),
3599         "Column type and flag combination is not valid");
3600       static_assert(
3601         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::socket_uid::stored_type>(
3602           ColumnFlag::socket_uid),
3603         "Column type and flag combination is not valid");
3604       static_assert(
3605         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::local_port::stored_type>(
3606           ColumnFlag::local_port),
3607         "Column type and flag combination is not valid");
3608       static_assert(
3609         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::remote_port::stored_type>(
3610           ColumnFlag::remote_port),
3611         "Column type and flag combination is not valid");
3612       static_assert(
3613         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::packet_icmp_type::stored_type>(
3614           ColumnFlag::packet_icmp_type),
3615         "Column type and flag combination is not valid");
3616       static_assert(
3617         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::packet_icmp_code::stored_type>(
3618           ColumnFlag::packet_icmp_code),
3619         "Column type and flag combination is not valid");
3620       static_assert(
3621         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::packet_tcp_flags::stored_type>(
3622           ColumnFlag::packet_tcp_flags),
3623         "Column type and flag combination is not valid");
3624       static_assert(
3625         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::packet_tcp_flags_str::stored_type>(
3626           ColumnFlag::packet_tcp_flags_str),
3627         "Column type and flag combination is not valid");
3628     PERFETTO_DCHECK(iface.size() == parent_overlay.size());
3629     iface_ = std::move(iface);
3630     PERFETTO_DCHECK(direction.size() == parent_overlay.size());
3631     direction_ = std::move(direction);
3632     PERFETTO_DCHECK(packet_transport.size() == parent_overlay.size());
3633     packet_transport_ = std::move(packet_transport);
3634     PERFETTO_DCHECK(packet_length.size() == parent_overlay.size());
3635     packet_length_ = std::move(packet_length);
3636     PERFETTO_DCHECK(packet_count.size() == parent_overlay.size());
3637     packet_count_ = std::move(packet_count);
3638     PERFETTO_DCHECK(socket_tag.size() == parent_overlay.size());
3639     socket_tag_ = std::move(socket_tag);
3640     PERFETTO_DCHECK(socket_tag_str.size() == parent_overlay.size());
3641     socket_tag_str_ = std::move(socket_tag_str);
3642     PERFETTO_DCHECK(socket_uid.size() == parent_overlay.size());
3643     socket_uid_ = std::move(socket_uid);
3644     PERFETTO_DCHECK(local_port.size() == parent_overlay.size());
3645     local_port_ = std::move(local_port);
3646     PERFETTO_DCHECK(remote_port.size() == parent_overlay.size());
3647     remote_port_ = std::move(remote_port);
3648     PERFETTO_DCHECK(packet_icmp_type.size() == parent_overlay.size());
3649     packet_icmp_type_ = std::move(packet_icmp_type);
3650     PERFETTO_DCHECK(packet_icmp_code.size() == parent_overlay.size());
3651     packet_icmp_code_ = std::move(packet_icmp_code);
3652     PERFETTO_DCHECK(packet_tcp_flags.size() == parent_overlay.size());
3653     packet_tcp_flags_ = std::move(packet_tcp_flags);
3654     PERFETTO_DCHECK(packet_tcp_flags_str.size() == parent_overlay.size());
3655     packet_tcp_flags_str_ = std::move(packet_tcp_flags_str);
3656 
3657     std::vector<RefPtr<column::OverlayLayer>> overlay_layers(OverlayCount(&parent) + 1);
3658     for (uint32_t i = 0; i < overlay_layers.size(); ++i) {
3659       if (overlays()[i].row_map().IsIndexVector()) {
3660         overlay_layers[i].reset(new column::ArrangementOverlay(
3661             overlays()[i].row_map().GetIfIndexVector(),
3662             column::DataLayerChain::Indices::State::kNonmonotonic));
3663       } else if (overlays()[i].row_map().IsBitVector()) {
3664         overlay_layers[i].reset(new column::SelectorOverlay(
3665             overlays()[i].row_map().GetIfBitVector()));
3666       } else if (overlays()[i].row_map().IsRange()) {
3667         overlay_layers[i].reset(new column::RangeOverlay(
3668             overlays()[i].row_map().GetIfIRange()));
3669       }
3670     }
3671 
3672     OnConstructionCompleted(
3673       {const_parent_->storage_layers()[ColumnIndex::id],const_parent_->storage_layers()[ColumnIndex::type],const_parent_->storage_layers()[ColumnIndex::ts],const_parent_->storage_layers()[ColumnIndex::dur],const_parent_->storage_layers()[ColumnIndex::track_id],const_parent_->storage_layers()[ColumnIndex::category],const_parent_->storage_layers()[ColumnIndex::name],const_parent_->storage_layers()[ColumnIndex::depth],const_parent_->storage_layers()[ColumnIndex::stack_id],const_parent_->storage_layers()[ColumnIndex::parent_stack_id],const_parent_->storage_layers()[ColumnIndex::parent_id],const_parent_->storage_layers()[ColumnIndex::arg_set_id],const_parent_->storage_layers()[ColumnIndex::thread_ts],const_parent_->storage_layers()[ColumnIndex::thread_dur],const_parent_->storage_layers()[ColumnIndex::thread_instruction_count],const_parent_->storage_layers()[ColumnIndex::thread_instruction_delta],iface_storage_layer_,direction_storage_layer_,packet_transport_storage_layer_,packet_length_storage_layer_,packet_count_storage_layer_,socket_tag_storage_layer_,socket_tag_str_storage_layer_,socket_uid_storage_layer_,local_port_storage_layer_,remote_port_storage_layer_,packet_icmp_type_storage_layer_,packet_icmp_code_storage_layer_,packet_tcp_flags_storage_layer_,packet_tcp_flags_str_storage_layer_}, {{},{},{},{},{},{},{},{},{},{},const_parent_->null_layers()[ColumnIndex::parent_id],{},const_parent_->null_layers()[ColumnIndex::thread_ts],const_parent_->null_layers()[ColumnIndex::thread_dur],const_parent_->null_layers()[ColumnIndex::thread_instruction_count],const_parent_->null_layers()[ColumnIndex::thread_instruction_delta],{},{},{},{},{},{},{},{},local_port_null_layer_,remote_port_null_layer_,packet_icmp_type_null_layer_,packet_icmp_code_null_layer_,packet_tcp_flags_null_layer_,{}}, std::move(overlay_layers));
3674   }
3675   SliceTable* parent_ = nullptr;
3676   const SliceTable* const_parent_ = nullptr;
3677   ColumnStorage<ColumnType::iface::stored_type> iface_;
3678   ColumnStorage<ColumnType::direction::stored_type> direction_;
3679   ColumnStorage<ColumnType::packet_transport::stored_type> packet_transport_;
3680   ColumnStorage<ColumnType::packet_length::stored_type> packet_length_;
3681   ColumnStorage<ColumnType::packet_count::stored_type> packet_count_;
3682   ColumnStorage<ColumnType::socket_tag::stored_type> socket_tag_;
3683   ColumnStorage<ColumnType::socket_tag_str::stored_type> socket_tag_str_;
3684   ColumnStorage<ColumnType::socket_uid::stored_type> socket_uid_;
3685   ColumnStorage<ColumnType::local_port::stored_type> local_port_;
3686   ColumnStorage<ColumnType::remote_port::stored_type> remote_port_;
3687   ColumnStorage<ColumnType::packet_icmp_type::stored_type> packet_icmp_type_;
3688   ColumnStorage<ColumnType::packet_icmp_code::stored_type> packet_icmp_code_;
3689   ColumnStorage<ColumnType::packet_tcp_flags::stored_type> packet_tcp_flags_;
3690   ColumnStorage<ColumnType::packet_tcp_flags_str::stored_type> packet_tcp_flags_str_;
3691 
3692   RefPtr<column::StorageLayer> iface_storage_layer_;
3693   RefPtr<column::StorageLayer> direction_storage_layer_;
3694   RefPtr<column::StorageLayer> packet_transport_storage_layer_;
3695   RefPtr<column::StorageLayer> packet_length_storage_layer_;
3696   RefPtr<column::StorageLayer> packet_count_storage_layer_;
3697   RefPtr<column::StorageLayer> socket_tag_storage_layer_;
3698   RefPtr<column::StorageLayer> socket_tag_str_storage_layer_;
3699   RefPtr<column::StorageLayer> socket_uid_storage_layer_;
3700   RefPtr<column::StorageLayer> local_port_storage_layer_;
3701   RefPtr<column::StorageLayer> remote_port_storage_layer_;
3702   RefPtr<column::StorageLayer> packet_icmp_type_storage_layer_;
3703   RefPtr<column::StorageLayer> packet_icmp_code_storage_layer_;
3704   RefPtr<column::StorageLayer> packet_tcp_flags_storage_layer_;
3705   RefPtr<column::StorageLayer> packet_tcp_flags_str_storage_layer_;
3706 
3707   RefPtr<column::OverlayLayer> local_port_null_layer_;
3708   RefPtr<column::OverlayLayer> remote_port_null_layer_;
3709   RefPtr<column::OverlayLayer> packet_icmp_type_null_layer_;
3710   RefPtr<column::OverlayLayer> packet_icmp_code_null_layer_;
3711   RefPtr<column::OverlayLayer> packet_tcp_flags_null_layer_;
3712 };
3713 
3714 
3715 class ExpectedFrameTimelineSliceTable : public macros_internal::MacroTable {
3716  public:
3717   static constexpr uint32_t kColumnCount = 20;
3718 
3719   using Id = SliceTable::Id;
3720 
3721   struct ColumnIndex {
3722     static constexpr uint32_t id = 0;
3723     static constexpr uint32_t type = 1;
3724     static constexpr uint32_t ts = 2;
3725     static constexpr uint32_t dur = 3;
3726     static constexpr uint32_t track_id = 4;
3727     static constexpr uint32_t category = 5;
3728     static constexpr uint32_t name = 6;
3729     static constexpr uint32_t depth = 7;
3730     static constexpr uint32_t stack_id = 8;
3731     static constexpr uint32_t parent_stack_id = 9;
3732     static constexpr uint32_t parent_id = 10;
3733     static constexpr uint32_t arg_set_id = 11;
3734     static constexpr uint32_t thread_ts = 12;
3735     static constexpr uint32_t thread_dur = 13;
3736     static constexpr uint32_t thread_instruction_count = 14;
3737     static constexpr uint32_t thread_instruction_delta = 15;
3738     static constexpr uint32_t display_frame_token = 16;
3739     static constexpr uint32_t surface_frame_token = 17;
3740     static constexpr uint32_t upid = 18;
3741     static constexpr uint32_t layer_name = 19;
3742   };
3743   struct ColumnType {
3744     using id = IdColumn<ExpectedFrameTimelineSliceTable::Id>;
3745     using type = TypedColumn<StringPool::Id>;
3746     using ts = TypedColumn<int64_t>;
3747     using dur = TypedColumn<int64_t>;
3748     using track_id = TypedColumn<TrackTable::Id>;
3749     using category = TypedColumn<std::optional<StringPool::Id>>;
3750     using name = TypedColumn<std::optional<StringPool::Id>>;
3751     using depth = TypedColumn<uint32_t>;
3752     using stack_id = TypedColumn<int64_t>;
3753     using parent_stack_id = TypedColumn<int64_t>;
3754     using parent_id = TypedColumn<std::optional<ExpectedFrameTimelineSliceTable::Id>>;
3755     using arg_set_id = TypedColumn<uint32_t>;
3756     using thread_ts = TypedColumn<std::optional<int64_t>>;
3757     using thread_dur = TypedColumn<std::optional<int64_t>>;
3758     using thread_instruction_count = TypedColumn<std::optional<int64_t>>;
3759     using thread_instruction_delta = TypedColumn<std::optional<int64_t>>;
3760     using display_frame_token = TypedColumn<int64_t>;
3761     using surface_frame_token = TypedColumn<int64_t>;
3762     using upid = TypedColumn<uint32_t>;
3763     using layer_name = TypedColumn<StringPool::Id>;
3764   };
3765   struct Row : public SliceTable::Row {
3766     Row(int64_t in_ts = {},
3767         int64_t in_dur = {},
3768         TrackTable::Id in_track_id = {},
3769         std::optional<StringPool::Id> in_category = {},
3770         std::optional<StringPool::Id> in_name = {},
3771         uint32_t in_depth = {},
3772         int64_t in_stack_id = {},
3773         int64_t in_parent_stack_id = {},
3774         std::optional<ExpectedFrameTimelineSliceTable::Id> in_parent_id = {},
3775         uint32_t in_arg_set_id = {},
3776         std::optional<int64_t> in_thread_ts = {},
3777         std::optional<int64_t> in_thread_dur = {},
3778         std::optional<int64_t> in_thread_instruction_count = {},
3779         std::optional<int64_t> in_thread_instruction_delta = {},
3780         int64_t in_display_frame_token = {},
3781         int64_t in_surface_frame_token = {},
3782         uint32_t in_upid = {},
3783         StringPool::Id in_layer_name = {},
3784         std::nullptr_t = nullptr)
RowRow3785         : SliceTable::Row(in_ts, in_dur, in_track_id, in_category, in_name, in_depth, in_stack_id, in_parent_stack_id, in_parent_id, in_arg_set_id, in_thread_ts, in_thread_dur, in_thread_instruction_count, in_thread_instruction_delta),
3786           display_frame_token(in_display_frame_token),
3787           surface_frame_token(in_surface_frame_token),
3788           upid(in_upid),
3789           layer_name(in_layer_name) {
3790       type_ = "expected_frame_timeline_slice";
3791     }
3792     int64_t display_frame_token;
3793     int64_t surface_frame_token;
3794     uint32_t upid;
3795     StringPool::Id layer_name;
3796 
3797     bool operator==(const ExpectedFrameTimelineSliceTable::Row& other) const {
3798       return type() == other.type() && ColumnType::ts::Equals(ts, other.ts) &&
3799        ColumnType::dur::Equals(dur, other.dur) &&
3800        ColumnType::track_id::Equals(track_id, other.track_id) &&
3801        ColumnType::category::Equals(category, other.category) &&
3802        ColumnType::name::Equals(name, other.name) &&
3803        ColumnType::depth::Equals(depth, other.depth) &&
3804        ColumnType::stack_id::Equals(stack_id, other.stack_id) &&
3805        ColumnType::parent_stack_id::Equals(parent_stack_id, other.parent_stack_id) &&
3806        ColumnType::parent_id::Equals(parent_id, other.parent_id) &&
3807        ColumnType::arg_set_id::Equals(arg_set_id, other.arg_set_id) &&
3808        ColumnType::thread_ts::Equals(thread_ts, other.thread_ts) &&
3809        ColumnType::thread_dur::Equals(thread_dur, other.thread_dur) &&
3810        ColumnType::thread_instruction_count::Equals(thread_instruction_count, other.thread_instruction_count) &&
3811        ColumnType::thread_instruction_delta::Equals(thread_instruction_delta, other.thread_instruction_delta) &&
3812        ColumnType::display_frame_token::Equals(display_frame_token, other.display_frame_token) &&
3813        ColumnType::surface_frame_token::Equals(surface_frame_token, other.surface_frame_token) &&
3814        ColumnType::upid::Equals(upid, other.upid) &&
3815        ColumnType::layer_name::Equals(layer_name, other.layer_name);
3816     }
3817   };
3818   struct ColumnFlag {
3819     static constexpr uint32_t display_frame_token = ColumnType::display_frame_token::default_flags();
3820     static constexpr uint32_t surface_frame_token = ColumnType::surface_frame_token::default_flags();
3821     static constexpr uint32_t upid = ColumnType::upid::default_flags();
3822     static constexpr uint32_t layer_name = ColumnType::layer_name::default_flags();
3823   };
3824 
3825   class RowNumber;
3826   class ConstRowReference;
3827   class RowReference;
3828 
3829   class RowNumber : public macros_internal::AbstractRowNumber<
3830       ExpectedFrameTimelineSliceTable, ConstRowReference, RowReference> {
3831    public:
RowNumber(uint32_t row_number)3832     explicit RowNumber(uint32_t row_number)
3833         : AbstractRowNumber(row_number) {}
3834   };
3835   static_assert(std::is_trivially_destructible_v<RowNumber>,
3836                 "Inheritance used without trivial destruction");
3837 
3838   class ConstRowReference : public macros_internal::AbstractConstRowReference<
3839     ExpectedFrameTimelineSliceTable, RowNumber> {
3840    public:
ConstRowReference(const ExpectedFrameTimelineSliceTable * table,uint32_t row_number)3841     ConstRowReference(const ExpectedFrameTimelineSliceTable* table, uint32_t row_number)
3842         : AbstractConstRowReference(table, row_number) {}
3843 
id()3844     ColumnType::id::type id() const {
3845       return table()->id()[row_number_];
3846     }
type()3847     ColumnType::type::type type() const {
3848       return table()->type()[row_number_];
3849     }
ts()3850     ColumnType::ts::type ts() const {
3851       return table()->ts()[row_number_];
3852     }
dur()3853     ColumnType::dur::type dur() const {
3854       return table()->dur()[row_number_];
3855     }
track_id()3856     ColumnType::track_id::type track_id() const {
3857       return table()->track_id()[row_number_];
3858     }
category()3859     ColumnType::category::type category() const {
3860       return table()->category()[row_number_];
3861     }
name()3862     ColumnType::name::type name() const {
3863       return table()->name()[row_number_];
3864     }
depth()3865     ColumnType::depth::type depth() const {
3866       return table()->depth()[row_number_];
3867     }
stack_id()3868     ColumnType::stack_id::type stack_id() const {
3869       return table()->stack_id()[row_number_];
3870     }
parent_stack_id()3871     ColumnType::parent_stack_id::type parent_stack_id() const {
3872       return table()->parent_stack_id()[row_number_];
3873     }
parent_id()3874     ColumnType::parent_id::type parent_id() const {
3875       return table()->parent_id()[row_number_];
3876     }
arg_set_id()3877     ColumnType::arg_set_id::type arg_set_id() const {
3878       return table()->arg_set_id()[row_number_];
3879     }
thread_ts()3880     ColumnType::thread_ts::type thread_ts() const {
3881       return table()->thread_ts()[row_number_];
3882     }
thread_dur()3883     ColumnType::thread_dur::type thread_dur() const {
3884       return table()->thread_dur()[row_number_];
3885     }
thread_instruction_count()3886     ColumnType::thread_instruction_count::type thread_instruction_count() const {
3887       return table()->thread_instruction_count()[row_number_];
3888     }
thread_instruction_delta()3889     ColumnType::thread_instruction_delta::type thread_instruction_delta() const {
3890       return table()->thread_instruction_delta()[row_number_];
3891     }
display_frame_token()3892     ColumnType::display_frame_token::type display_frame_token() const {
3893       return table()->display_frame_token()[row_number_];
3894     }
surface_frame_token()3895     ColumnType::surface_frame_token::type surface_frame_token() const {
3896       return table()->surface_frame_token()[row_number_];
3897     }
upid()3898     ColumnType::upid::type upid() const {
3899       return table()->upid()[row_number_];
3900     }
layer_name()3901     ColumnType::layer_name::type layer_name() const {
3902       return table()->layer_name()[row_number_];
3903     }
3904   };
3905   static_assert(std::is_trivially_destructible_v<ConstRowReference>,
3906                 "Inheritance used without trivial destruction");
3907   class RowReference : public ConstRowReference {
3908    public:
RowReference(const ExpectedFrameTimelineSliceTable * table,uint32_t row_number)3909     RowReference(const ExpectedFrameTimelineSliceTable* table, uint32_t row_number)
3910         : ConstRowReference(table, row_number) {}
3911 
set_ts(ColumnType::ts::non_optional_type v)3912     void set_ts(
3913         ColumnType::ts::non_optional_type v) {
3914       return mutable_table()->mutable_ts()->Set(row_number_, v);
3915     }
set_dur(ColumnType::dur::non_optional_type v)3916     void set_dur(
3917         ColumnType::dur::non_optional_type v) {
3918       return mutable_table()->mutable_dur()->Set(row_number_, v);
3919     }
set_track_id(ColumnType::track_id::non_optional_type v)3920     void set_track_id(
3921         ColumnType::track_id::non_optional_type v) {
3922       return mutable_table()->mutable_track_id()->Set(row_number_, v);
3923     }
set_category(ColumnType::category::non_optional_type v)3924     void set_category(
3925         ColumnType::category::non_optional_type v) {
3926       return mutable_table()->mutable_category()->Set(row_number_, v);
3927     }
set_name(ColumnType::name::non_optional_type v)3928     void set_name(
3929         ColumnType::name::non_optional_type v) {
3930       return mutable_table()->mutable_name()->Set(row_number_, v);
3931     }
set_depth(ColumnType::depth::non_optional_type v)3932     void set_depth(
3933         ColumnType::depth::non_optional_type v) {
3934       return mutable_table()->mutable_depth()->Set(row_number_, v);
3935     }
set_stack_id(ColumnType::stack_id::non_optional_type v)3936     void set_stack_id(
3937         ColumnType::stack_id::non_optional_type v) {
3938       return mutable_table()->mutable_stack_id()->Set(row_number_, v);
3939     }
set_parent_stack_id(ColumnType::parent_stack_id::non_optional_type v)3940     void set_parent_stack_id(
3941         ColumnType::parent_stack_id::non_optional_type v) {
3942       return mutable_table()->mutable_parent_stack_id()->Set(row_number_, v);
3943     }
set_parent_id(ColumnType::parent_id::non_optional_type v)3944     void set_parent_id(
3945         ColumnType::parent_id::non_optional_type v) {
3946       return mutable_table()->mutable_parent_id()->Set(row_number_, v);
3947     }
set_arg_set_id(ColumnType::arg_set_id::non_optional_type v)3948     void set_arg_set_id(
3949         ColumnType::arg_set_id::non_optional_type v) {
3950       return mutable_table()->mutable_arg_set_id()->Set(row_number_, v);
3951     }
set_thread_ts(ColumnType::thread_ts::non_optional_type v)3952     void set_thread_ts(
3953         ColumnType::thread_ts::non_optional_type v) {
3954       return mutable_table()->mutable_thread_ts()->Set(row_number_, v);
3955     }
set_thread_dur(ColumnType::thread_dur::non_optional_type v)3956     void set_thread_dur(
3957         ColumnType::thread_dur::non_optional_type v) {
3958       return mutable_table()->mutable_thread_dur()->Set(row_number_, v);
3959     }
set_thread_instruction_count(ColumnType::thread_instruction_count::non_optional_type v)3960     void set_thread_instruction_count(
3961         ColumnType::thread_instruction_count::non_optional_type v) {
3962       return mutable_table()->mutable_thread_instruction_count()->Set(row_number_, v);
3963     }
set_thread_instruction_delta(ColumnType::thread_instruction_delta::non_optional_type v)3964     void set_thread_instruction_delta(
3965         ColumnType::thread_instruction_delta::non_optional_type v) {
3966       return mutable_table()->mutable_thread_instruction_delta()->Set(row_number_, v);
3967     }
set_display_frame_token(ColumnType::display_frame_token::non_optional_type v)3968     void set_display_frame_token(
3969         ColumnType::display_frame_token::non_optional_type v) {
3970       return mutable_table()->mutable_display_frame_token()->Set(row_number_, v);
3971     }
set_surface_frame_token(ColumnType::surface_frame_token::non_optional_type v)3972     void set_surface_frame_token(
3973         ColumnType::surface_frame_token::non_optional_type v) {
3974       return mutable_table()->mutable_surface_frame_token()->Set(row_number_, v);
3975     }
set_upid(ColumnType::upid::non_optional_type v)3976     void set_upid(
3977         ColumnType::upid::non_optional_type v) {
3978       return mutable_table()->mutable_upid()->Set(row_number_, v);
3979     }
set_layer_name(ColumnType::layer_name::non_optional_type v)3980     void set_layer_name(
3981         ColumnType::layer_name::non_optional_type v) {
3982       return mutable_table()->mutable_layer_name()->Set(row_number_, v);
3983     }
3984 
3985    private:
mutable_table()3986     ExpectedFrameTimelineSliceTable* mutable_table() const {
3987       return const_cast<ExpectedFrameTimelineSliceTable*>(table());
3988     }
3989   };
3990   static_assert(std::is_trivially_destructible_v<RowReference>,
3991                 "Inheritance used without trivial destruction");
3992 
3993   class ConstIterator;
3994   class ConstIterator : public macros_internal::AbstractConstIterator<
3995     ConstIterator, ExpectedFrameTimelineSliceTable, RowNumber, ConstRowReference> {
3996    public:
id()3997     ColumnType::id::type id() const {
3998       const auto& col = table()->id();
3999       return col.GetAtIdx(
4000         iterator_.StorageIndexForColumn(col.index_in_table()));
4001     }
type()4002     ColumnType::type::type type() const {
4003       const auto& col = table()->type();
4004       return col.GetAtIdx(
4005         iterator_.StorageIndexForColumn(col.index_in_table()));
4006     }
ts()4007     ColumnType::ts::type ts() const {
4008       const auto& col = table()->ts();
4009       return col.GetAtIdx(
4010         iterator_.StorageIndexForColumn(col.index_in_table()));
4011     }
dur()4012     ColumnType::dur::type dur() const {
4013       const auto& col = table()->dur();
4014       return col.GetAtIdx(
4015         iterator_.StorageIndexForColumn(col.index_in_table()));
4016     }
track_id()4017     ColumnType::track_id::type track_id() const {
4018       const auto& col = table()->track_id();
4019       return col.GetAtIdx(
4020         iterator_.StorageIndexForColumn(col.index_in_table()));
4021     }
category()4022     ColumnType::category::type category() const {
4023       const auto& col = table()->category();
4024       return col.GetAtIdx(
4025         iterator_.StorageIndexForColumn(col.index_in_table()));
4026     }
name()4027     ColumnType::name::type name() const {
4028       const auto& col = table()->name();
4029       return col.GetAtIdx(
4030         iterator_.StorageIndexForColumn(col.index_in_table()));
4031     }
depth()4032     ColumnType::depth::type depth() const {
4033       const auto& col = table()->depth();
4034       return col.GetAtIdx(
4035         iterator_.StorageIndexForColumn(col.index_in_table()));
4036     }
stack_id()4037     ColumnType::stack_id::type stack_id() const {
4038       const auto& col = table()->stack_id();
4039       return col.GetAtIdx(
4040         iterator_.StorageIndexForColumn(col.index_in_table()));
4041     }
parent_stack_id()4042     ColumnType::parent_stack_id::type parent_stack_id() const {
4043       const auto& col = table()->parent_stack_id();
4044       return col.GetAtIdx(
4045         iterator_.StorageIndexForColumn(col.index_in_table()));
4046     }
parent_id()4047     ColumnType::parent_id::type parent_id() const {
4048       const auto& col = table()->parent_id();
4049       return col.GetAtIdx(
4050         iterator_.StorageIndexForColumn(col.index_in_table()));
4051     }
arg_set_id()4052     ColumnType::arg_set_id::type arg_set_id() const {
4053       const auto& col = table()->arg_set_id();
4054       return col.GetAtIdx(
4055         iterator_.StorageIndexForColumn(col.index_in_table()));
4056     }
thread_ts()4057     ColumnType::thread_ts::type thread_ts() const {
4058       const auto& col = table()->thread_ts();
4059       return col.GetAtIdx(
4060         iterator_.StorageIndexForColumn(col.index_in_table()));
4061     }
thread_dur()4062     ColumnType::thread_dur::type thread_dur() const {
4063       const auto& col = table()->thread_dur();
4064       return col.GetAtIdx(
4065         iterator_.StorageIndexForColumn(col.index_in_table()));
4066     }
thread_instruction_count()4067     ColumnType::thread_instruction_count::type thread_instruction_count() const {
4068       const auto& col = table()->thread_instruction_count();
4069       return col.GetAtIdx(
4070         iterator_.StorageIndexForColumn(col.index_in_table()));
4071     }
thread_instruction_delta()4072     ColumnType::thread_instruction_delta::type thread_instruction_delta() const {
4073       const auto& col = table()->thread_instruction_delta();
4074       return col.GetAtIdx(
4075         iterator_.StorageIndexForColumn(col.index_in_table()));
4076     }
display_frame_token()4077     ColumnType::display_frame_token::type display_frame_token() const {
4078       const auto& col = table()->display_frame_token();
4079       return col.GetAtIdx(
4080         iterator_.StorageIndexForColumn(col.index_in_table()));
4081     }
surface_frame_token()4082     ColumnType::surface_frame_token::type surface_frame_token() const {
4083       const auto& col = table()->surface_frame_token();
4084       return col.GetAtIdx(
4085         iterator_.StorageIndexForColumn(col.index_in_table()));
4086     }
upid()4087     ColumnType::upid::type upid() const {
4088       const auto& col = table()->upid();
4089       return col.GetAtIdx(
4090         iterator_.StorageIndexForColumn(col.index_in_table()));
4091     }
layer_name()4092     ColumnType::layer_name::type layer_name() const {
4093       const auto& col = table()->layer_name();
4094       return col.GetAtIdx(
4095         iterator_.StorageIndexForColumn(col.index_in_table()));
4096     }
4097 
4098    protected:
ConstIterator(const ExpectedFrameTimelineSliceTable * table,Table::Iterator iterator)4099     explicit ConstIterator(const ExpectedFrameTimelineSliceTable* table,
4100                            Table::Iterator iterator)
4101         : AbstractConstIterator(table, std::move(iterator)) {}
4102 
CurrentRowNumber()4103     uint32_t CurrentRowNumber() const {
4104       return iterator_.StorageIndexForLastOverlay();
4105     }
4106 
4107    private:
4108     friend class ExpectedFrameTimelineSliceTable;
4109     friend class macros_internal::AbstractConstIterator<
4110       ConstIterator, ExpectedFrameTimelineSliceTable, RowNumber, ConstRowReference>;
4111   };
4112   class Iterator : public ConstIterator {
4113     public:
row_reference()4114      RowReference row_reference() const {
4115        return {const_cast<ExpectedFrameTimelineSliceTable*>(table()), CurrentRowNumber()};
4116      }
4117 
4118     private:
4119      friend class ExpectedFrameTimelineSliceTable;
4120 
Iterator(ExpectedFrameTimelineSliceTable * table,Table::Iterator iterator)4121      explicit Iterator(ExpectedFrameTimelineSliceTable* table, Table::Iterator iterator)
4122         : ConstIterator(table, std::move(iterator)) {}
4123   };
4124 
4125   struct IdAndRow {
4126     Id id;
4127     uint32_t row;
4128     RowReference row_reference;
4129     RowNumber row_number;
4130   };
4131 
GetColumns(ExpectedFrameTimelineSliceTable * self,const macros_internal::MacroTable * parent)4132   static std::vector<ColumnLegacy> GetColumns(
4133       ExpectedFrameTimelineSliceTable* self,
4134       const macros_internal::MacroTable* parent) {
4135     std::vector<ColumnLegacy> columns =
4136         CopyColumnsFromParentOrAddRootColumns(self, parent);
4137     uint32_t olay_idx = OverlayCount(parent);
4138     AddColumnToVector(columns, "display_frame_token", &self->display_frame_token_, ColumnFlag::display_frame_token,
4139                       static_cast<uint32_t>(columns.size()), olay_idx);
4140     AddColumnToVector(columns, "surface_frame_token", &self->surface_frame_token_, ColumnFlag::surface_frame_token,
4141                       static_cast<uint32_t>(columns.size()), olay_idx);
4142     AddColumnToVector(columns, "upid", &self->upid_, ColumnFlag::upid,
4143                       static_cast<uint32_t>(columns.size()), olay_idx);
4144     AddColumnToVector(columns, "layer_name", &self->layer_name_, ColumnFlag::layer_name,
4145                       static_cast<uint32_t>(columns.size()), olay_idx);
4146     return columns;
4147   }
4148 
ExpectedFrameTimelineSliceTable(StringPool * pool,SliceTable * parent)4149   PERFETTO_NO_INLINE explicit ExpectedFrameTimelineSliceTable(StringPool* pool, SliceTable* parent)
4150       : macros_internal::MacroTable(
4151           pool,
4152           GetColumns(this, parent),
4153           parent),
4154         parent_(parent), const_parent_(parent), display_frame_token_(ColumnStorage<ColumnType::display_frame_token::stored_type>::Create<false>()),
4155         surface_frame_token_(ColumnStorage<ColumnType::surface_frame_token::stored_type>::Create<false>()),
4156         upid_(ColumnStorage<ColumnType::upid::stored_type>::Create<false>()),
4157         layer_name_(ColumnStorage<ColumnType::layer_name::stored_type>::Create<false>())
4158 ,
4159         display_frame_token_storage_layer_(
4160         new column::NumericStorage<ColumnType::display_frame_token::non_optional_stored_type>(
4161           &display_frame_token_.vector(),
4162           ColumnTypeHelper<ColumnType::display_frame_token::stored_type>::ToColumnType(),
4163           false)),
4164         surface_frame_token_storage_layer_(
4165         new column::NumericStorage<ColumnType::surface_frame_token::non_optional_stored_type>(
4166           &surface_frame_token_.vector(),
4167           ColumnTypeHelper<ColumnType::surface_frame_token::stored_type>::ToColumnType(),
4168           false)),
4169         upid_storage_layer_(
4170         new column::NumericStorage<ColumnType::upid::non_optional_stored_type>(
4171           &upid_.vector(),
4172           ColumnTypeHelper<ColumnType::upid::stored_type>::ToColumnType(),
4173           false)),
4174         layer_name_storage_layer_(
4175           new column::StringStorage(string_pool(), &layer_name_.vector()))
4176          {
4177     static_assert(
4178         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::display_frame_token::stored_type>(
4179           ColumnFlag::display_frame_token),
4180         "Column type and flag combination is not valid");
4181       static_assert(
4182         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::surface_frame_token::stored_type>(
4183           ColumnFlag::surface_frame_token),
4184         "Column type and flag combination is not valid");
4185       static_assert(
4186         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::upid::stored_type>(
4187           ColumnFlag::upid),
4188         "Column type and flag combination is not valid");
4189       static_assert(
4190         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::layer_name::stored_type>(
4191           ColumnFlag::layer_name),
4192         "Column type and flag combination is not valid");
4193     OnConstructionCompletedRegularConstructor(
4194       {const_parent_->storage_layers()[ColumnIndex::id],const_parent_->storage_layers()[ColumnIndex::type],const_parent_->storage_layers()[ColumnIndex::ts],const_parent_->storage_layers()[ColumnIndex::dur],const_parent_->storage_layers()[ColumnIndex::track_id],const_parent_->storage_layers()[ColumnIndex::category],const_parent_->storage_layers()[ColumnIndex::name],const_parent_->storage_layers()[ColumnIndex::depth],const_parent_->storage_layers()[ColumnIndex::stack_id],const_parent_->storage_layers()[ColumnIndex::parent_stack_id],const_parent_->storage_layers()[ColumnIndex::parent_id],const_parent_->storage_layers()[ColumnIndex::arg_set_id],const_parent_->storage_layers()[ColumnIndex::thread_ts],const_parent_->storage_layers()[ColumnIndex::thread_dur],const_parent_->storage_layers()[ColumnIndex::thread_instruction_count],const_parent_->storage_layers()[ColumnIndex::thread_instruction_delta],display_frame_token_storage_layer_,surface_frame_token_storage_layer_,upid_storage_layer_,layer_name_storage_layer_},
4195       {{},{},{},{},{},{},{},{},{},{},const_parent_->null_layers()[ColumnIndex::parent_id],{},const_parent_->null_layers()[ColumnIndex::thread_ts],const_parent_->null_layers()[ColumnIndex::thread_dur],const_parent_->null_layers()[ColumnIndex::thread_instruction_count],const_parent_->null_layers()[ColumnIndex::thread_instruction_delta],{},{},{},{}});
4196   }
4197   ~ExpectedFrameTimelineSliceTable() override;
4198 
Name()4199   static const char* Name() { return "expected_frame_timeline_slice"; }
4200 
ComputeStaticSchema()4201   static Table::Schema ComputeStaticSchema() {
4202     Table::Schema schema;
4203     schema.columns.emplace_back(Table::Schema::Column{
4204         "id", SqlValue::Type::kLong, true, true, false, false});
4205     schema.columns.emplace_back(Table::Schema::Column{
4206         "type", SqlValue::Type::kString, false, false, false, false});
4207     schema.columns.emplace_back(Table::Schema::Column{
4208         "ts", ColumnType::ts::SqlValueType(), false,
4209         true,
4210         false,
4211         false});
4212     schema.columns.emplace_back(Table::Schema::Column{
4213         "dur", ColumnType::dur::SqlValueType(), false,
4214         false,
4215         false,
4216         false});
4217     schema.columns.emplace_back(Table::Schema::Column{
4218         "track_id", ColumnType::track_id::SqlValueType(), false,
4219         false,
4220         false,
4221         false});
4222     schema.columns.emplace_back(Table::Schema::Column{
4223         "category", ColumnType::category::SqlValueType(), false,
4224         false,
4225         false,
4226         false});
4227     schema.columns.emplace_back(Table::Schema::Column{
4228         "name", ColumnType::name::SqlValueType(), false,
4229         false,
4230         false,
4231         false});
4232     schema.columns.emplace_back(Table::Schema::Column{
4233         "depth", ColumnType::depth::SqlValueType(), false,
4234         false,
4235         false,
4236         false});
4237     schema.columns.emplace_back(Table::Schema::Column{
4238         "stack_id", ColumnType::stack_id::SqlValueType(), false,
4239         false,
4240         false,
4241         false});
4242     schema.columns.emplace_back(Table::Schema::Column{
4243         "parent_stack_id", ColumnType::parent_stack_id::SqlValueType(), false,
4244         false,
4245         false,
4246         false});
4247     schema.columns.emplace_back(Table::Schema::Column{
4248         "parent_id", ColumnType::parent_id::SqlValueType(), false,
4249         false,
4250         false,
4251         false});
4252     schema.columns.emplace_back(Table::Schema::Column{
4253         "arg_set_id", ColumnType::arg_set_id::SqlValueType(), false,
4254         false,
4255         false,
4256         false});
4257     schema.columns.emplace_back(Table::Schema::Column{
4258         "thread_ts", ColumnType::thread_ts::SqlValueType(), false,
4259         false,
4260         false,
4261         false});
4262     schema.columns.emplace_back(Table::Schema::Column{
4263         "thread_dur", ColumnType::thread_dur::SqlValueType(), false,
4264         false,
4265         false,
4266         false});
4267     schema.columns.emplace_back(Table::Schema::Column{
4268         "thread_instruction_count", ColumnType::thread_instruction_count::SqlValueType(), false,
4269         false,
4270         false,
4271         false});
4272     schema.columns.emplace_back(Table::Schema::Column{
4273         "thread_instruction_delta", ColumnType::thread_instruction_delta::SqlValueType(), false,
4274         false,
4275         false,
4276         false});
4277     schema.columns.emplace_back(Table::Schema::Column{
4278         "display_frame_token", ColumnType::display_frame_token::SqlValueType(), false,
4279         false,
4280         false,
4281         false});
4282     schema.columns.emplace_back(Table::Schema::Column{
4283         "surface_frame_token", ColumnType::surface_frame_token::SqlValueType(), false,
4284         false,
4285         false,
4286         false});
4287     schema.columns.emplace_back(Table::Schema::Column{
4288         "upid", ColumnType::upid::SqlValueType(), false,
4289         false,
4290         false,
4291         false});
4292     schema.columns.emplace_back(Table::Schema::Column{
4293         "layer_name", ColumnType::layer_name::SqlValueType(), false,
4294         false,
4295         false,
4296         false});
4297     return schema;
4298   }
4299 
IterateRows()4300   ConstIterator IterateRows() const {
4301     return ConstIterator(this, Table::IterateRows());
4302   }
4303 
IterateRows()4304   Iterator IterateRows() { return Iterator(this, Table::IterateRows()); }
4305 
FilterToIterator(const Query & q)4306   ConstIterator FilterToIterator(const Query& q) const {
4307     return ConstIterator(this, QueryToIterator(q));
4308   }
4309 
FilterToIterator(const Query & q)4310   Iterator FilterToIterator(const Query& q) {
4311     return Iterator(this, QueryToIterator(q));
4312   }
4313 
ShrinkToFit()4314   void ShrinkToFit() {
4315     display_frame_token_.ShrinkToFit();
4316     surface_frame_token_.ShrinkToFit();
4317     upid_.ShrinkToFit();
4318     layer_name_.ShrinkToFit();
4319   }
4320 
4321   ConstRowReference operator[](uint32_t r) const {
4322     return ConstRowReference(this, r);
4323   }
4324   RowReference operator[](uint32_t r) { return RowReference(this, r); }
4325   ConstRowReference operator[](RowNumber r) const {
4326     return ConstRowReference(this, r.row_number());
4327   }
4328   RowReference operator[](RowNumber r) {
4329     return RowReference(this, r.row_number());
4330   }
4331 
FindById(Id find_id)4332   std::optional<ConstRowReference> FindById(Id find_id) const {
4333     std::optional<uint32_t> row = id().IndexOf(find_id);
4334     return row ? std::make_optional(ConstRowReference(this, *row))
4335                : std::nullopt;
4336   }
4337 
FindById(Id find_id)4338   std::optional<RowReference> FindById(Id find_id) {
4339     std::optional<uint32_t> row = id().IndexOf(find_id);
4340     return row ? std::make_optional(RowReference(this, *row)) : std::nullopt;
4341   }
4342 
Insert(const Row & row)4343   IdAndRow Insert(const Row& row) {
4344     uint32_t row_number = row_count();
4345     Id id = Id{parent_->Insert(row).id};
4346     UpdateOverlaysAfterParentInsert();
4347     mutable_display_frame_token()->Append(row.display_frame_token);
4348     mutable_surface_frame_token()->Append(row.surface_frame_token);
4349     mutable_upid()->Append(row.upid);
4350     mutable_layer_name()->Append(row.layer_name);
4351     UpdateSelfOverlayAfterInsert();
4352     return IdAndRow{id, row_number, RowReference(this, row_number),
4353                      RowNumber(row_number)};
4354   }
4355 
ExtendParent(const SliceTable & parent,ColumnStorage<ColumnType::display_frame_token::stored_type> display_frame_token,ColumnStorage<ColumnType::surface_frame_token::stored_type> surface_frame_token,ColumnStorage<ColumnType::upid::stored_type> upid,ColumnStorage<ColumnType::layer_name::stored_type> layer_name)4356   static std::unique_ptr<ExpectedFrameTimelineSliceTable> ExtendParent(
4357       const SliceTable& parent,
4358       ColumnStorage<ColumnType::display_frame_token::stored_type> display_frame_token
4359 , ColumnStorage<ColumnType::surface_frame_token::stored_type> surface_frame_token
4360 , ColumnStorage<ColumnType::upid::stored_type> upid
4361 , ColumnStorage<ColumnType::layer_name::stored_type> layer_name) {
4362     return std::unique_ptr<ExpectedFrameTimelineSliceTable>(new ExpectedFrameTimelineSliceTable(
4363         parent.string_pool(), parent, RowMap(0, parent.row_count()),
4364         std::move(display_frame_token), std::move(surface_frame_token), std::move(upid), std::move(layer_name)));
4365   }
4366 
SelectAndExtendParent(const SliceTable & parent,std::vector<SliceTable::RowNumber> parent_overlay,ColumnStorage<ColumnType::display_frame_token::stored_type> display_frame_token,ColumnStorage<ColumnType::surface_frame_token::stored_type> surface_frame_token,ColumnStorage<ColumnType::upid::stored_type> upid,ColumnStorage<ColumnType::layer_name::stored_type> layer_name)4367   static std::unique_ptr<ExpectedFrameTimelineSliceTable> SelectAndExtendParent(
4368       const SliceTable& parent,
4369       std::vector<SliceTable::RowNumber> parent_overlay,
4370       ColumnStorage<ColumnType::display_frame_token::stored_type> display_frame_token
4371 , ColumnStorage<ColumnType::surface_frame_token::stored_type> surface_frame_token
4372 , ColumnStorage<ColumnType::upid::stored_type> upid
4373 , ColumnStorage<ColumnType::layer_name::stored_type> layer_name) {
4374     std::vector<uint32_t> prs_untyped(parent_overlay.size());
4375     for (uint32_t i = 0; i < parent_overlay.size(); ++i) {
4376       prs_untyped[i] = parent_overlay[i].row_number();
4377     }
4378     return std::unique_ptr<ExpectedFrameTimelineSliceTable>(new ExpectedFrameTimelineSliceTable(
4379         parent.string_pool(), parent, RowMap(std::move(prs_untyped)),
4380         std::move(display_frame_token), std::move(surface_frame_token), std::move(upid), std::move(layer_name)));
4381   }
4382 
id()4383   const IdColumn<ExpectedFrameTimelineSliceTable::Id>& id() const {
4384     return static_cast<const ColumnType::id&>(columns()[ColumnIndex::id]);
4385   }
type()4386   const TypedColumn<StringPool::Id>& type() const {
4387     return static_cast<const ColumnType::type&>(columns()[ColumnIndex::type]);
4388   }
ts()4389   const TypedColumn<int64_t>& ts() const {
4390     return static_cast<const ColumnType::ts&>(columns()[ColumnIndex::ts]);
4391   }
dur()4392   const TypedColumn<int64_t>& dur() const {
4393     return static_cast<const ColumnType::dur&>(columns()[ColumnIndex::dur]);
4394   }
track_id()4395   const TypedColumn<TrackTable::Id>& track_id() const {
4396     return static_cast<const ColumnType::track_id&>(columns()[ColumnIndex::track_id]);
4397   }
category()4398   const TypedColumn<std::optional<StringPool::Id>>& category() const {
4399     return static_cast<const ColumnType::category&>(columns()[ColumnIndex::category]);
4400   }
name()4401   const TypedColumn<std::optional<StringPool::Id>>& name() const {
4402     return static_cast<const ColumnType::name&>(columns()[ColumnIndex::name]);
4403   }
depth()4404   const TypedColumn<uint32_t>& depth() const {
4405     return static_cast<const ColumnType::depth&>(columns()[ColumnIndex::depth]);
4406   }
stack_id()4407   const TypedColumn<int64_t>& stack_id() const {
4408     return static_cast<const ColumnType::stack_id&>(columns()[ColumnIndex::stack_id]);
4409   }
parent_stack_id()4410   const TypedColumn<int64_t>& parent_stack_id() const {
4411     return static_cast<const ColumnType::parent_stack_id&>(columns()[ColumnIndex::parent_stack_id]);
4412   }
parent_id()4413   const TypedColumn<std::optional<ExpectedFrameTimelineSliceTable::Id>>& parent_id() const {
4414     return static_cast<const ColumnType::parent_id&>(columns()[ColumnIndex::parent_id]);
4415   }
arg_set_id()4416   const TypedColumn<uint32_t>& arg_set_id() const {
4417     return static_cast<const ColumnType::arg_set_id&>(columns()[ColumnIndex::arg_set_id]);
4418   }
thread_ts()4419   const TypedColumn<std::optional<int64_t>>& thread_ts() const {
4420     return static_cast<const ColumnType::thread_ts&>(columns()[ColumnIndex::thread_ts]);
4421   }
thread_dur()4422   const TypedColumn<std::optional<int64_t>>& thread_dur() const {
4423     return static_cast<const ColumnType::thread_dur&>(columns()[ColumnIndex::thread_dur]);
4424   }
thread_instruction_count()4425   const TypedColumn<std::optional<int64_t>>& thread_instruction_count() const {
4426     return static_cast<const ColumnType::thread_instruction_count&>(columns()[ColumnIndex::thread_instruction_count]);
4427   }
thread_instruction_delta()4428   const TypedColumn<std::optional<int64_t>>& thread_instruction_delta() const {
4429     return static_cast<const ColumnType::thread_instruction_delta&>(columns()[ColumnIndex::thread_instruction_delta]);
4430   }
display_frame_token()4431   const TypedColumn<int64_t>& display_frame_token() const {
4432     return static_cast<const ColumnType::display_frame_token&>(columns()[ColumnIndex::display_frame_token]);
4433   }
surface_frame_token()4434   const TypedColumn<int64_t>& surface_frame_token() const {
4435     return static_cast<const ColumnType::surface_frame_token&>(columns()[ColumnIndex::surface_frame_token]);
4436   }
upid()4437   const TypedColumn<uint32_t>& upid() const {
4438     return static_cast<const ColumnType::upid&>(columns()[ColumnIndex::upid]);
4439   }
layer_name()4440   const TypedColumn<StringPool::Id>& layer_name() const {
4441     return static_cast<const ColumnType::layer_name&>(columns()[ColumnIndex::layer_name]);
4442   }
4443 
mutable_ts()4444   TypedColumn<int64_t>* mutable_ts() {
4445     return static_cast<ColumnType::ts*>(
4446         GetColumn(ColumnIndex::ts));
4447   }
mutable_dur()4448   TypedColumn<int64_t>* mutable_dur() {
4449     return static_cast<ColumnType::dur*>(
4450         GetColumn(ColumnIndex::dur));
4451   }
mutable_track_id()4452   TypedColumn<TrackTable::Id>* mutable_track_id() {
4453     return static_cast<ColumnType::track_id*>(
4454         GetColumn(ColumnIndex::track_id));
4455   }
mutable_category()4456   TypedColumn<std::optional<StringPool::Id>>* mutable_category() {
4457     return static_cast<ColumnType::category*>(
4458         GetColumn(ColumnIndex::category));
4459   }
mutable_name()4460   TypedColumn<std::optional<StringPool::Id>>* mutable_name() {
4461     return static_cast<ColumnType::name*>(
4462         GetColumn(ColumnIndex::name));
4463   }
mutable_depth()4464   TypedColumn<uint32_t>* mutable_depth() {
4465     return static_cast<ColumnType::depth*>(
4466         GetColumn(ColumnIndex::depth));
4467   }
mutable_stack_id()4468   TypedColumn<int64_t>* mutable_stack_id() {
4469     return static_cast<ColumnType::stack_id*>(
4470         GetColumn(ColumnIndex::stack_id));
4471   }
mutable_parent_stack_id()4472   TypedColumn<int64_t>* mutable_parent_stack_id() {
4473     return static_cast<ColumnType::parent_stack_id*>(
4474         GetColumn(ColumnIndex::parent_stack_id));
4475   }
mutable_parent_id()4476   TypedColumn<std::optional<ExpectedFrameTimelineSliceTable::Id>>* mutable_parent_id() {
4477     return static_cast<ColumnType::parent_id*>(
4478         GetColumn(ColumnIndex::parent_id));
4479   }
mutable_arg_set_id()4480   TypedColumn<uint32_t>* mutable_arg_set_id() {
4481     return static_cast<ColumnType::arg_set_id*>(
4482         GetColumn(ColumnIndex::arg_set_id));
4483   }
mutable_thread_ts()4484   TypedColumn<std::optional<int64_t>>* mutable_thread_ts() {
4485     return static_cast<ColumnType::thread_ts*>(
4486         GetColumn(ColumnIndex::thread_ts));
4487   }
mutable_thread_dur()4488   TypedColumn<std::optional<int64_t>>* mutable_thread_dur() {
4489     return static_cast<ColumnType::thread_dur*>(
4490         GetColumn(ColumnIndex::thread_dur));
4491   }
mutable_thread_instruction_count()4492   TypedColumn<std::optional<int64_t>>* mutable_thread_instruction_count() {
4493     return static_cast<ColumnType::thread_instruction_count*>(
4494         GetColumn(ColumnIndex::thread_instruction_count));
4495   }
mutable_thread_instruction_delta()4496   TypedColumn<std::optional<int64_t>>* mutable_thread_instruction_delta() {
4497     return static_cast<ColumnType::thread_instruction_delta*>(
4498         GetColumn(ColumnIndex::thread_instruction_delta));
4499   }
mutable_display_frame_token()4500   TypedColumn<int64_t>* mutable_display_frame_token() {
4501     return static_cast<ColumnType::display_frame_token*>(
4502         GetColumn(ColumnIndex::display_frame_token));
4503   }
mutable_surface_frame_token()4504   TypedColumn<int64_t>* mutable_surface_frame_token() {
4505     return static_cast<ColumnType::surface_frame_token*>(
4506         GetColumn(ColumnIndex::surface_frame_token));
4507   }
mutable_upid()4508   TypedColumn<uint32_t>* mutable_upid() {
4509     return static_cast<ColumnType::upid*>(
4510         GetColumn(ColumnIndex::upid));
4511   }
mutable_layer_name()4512   TypedColumn<StringPool::Id>* mutable_layer_name() {
4513     return static_cast<ColumnType::layer_name*>(
4514         GetColumn(ColumnIndex::layer_name));
4515   }
4516 
4517  private:
ExpectedFrameTimelineSliceTable(StringPool * pool,const SliceTable & parent,const RowMap & parent_overlay,ColumnStorage<ColumnType::display_frame_token::stored_type> display_frame_token,ColumnStorage<ColumnType::surface_frame_token::stored_type> surface_frame_token,ColumnStorage<ColumnType::upid::stored_type> upid,ColumnStorage<ColumnType::layer_name::stored_type> layer_name)4518   ExpectedFrameTimelineSliceTable(StringPool* pool,
4519             const SliceTable& parent,
4520             const RowMap& parent_overlay,
4521             ColumnStorage<ColumnType::display_frame_token::stored_type> display_frame_token
4522 , ColumnStorage<ColumnType::surface_frame_token::stored_type> surface_frame_token
4523 , ColumnStorage<ColumnType::upid::stored_type> upid
4524 , ColumnStorage<ColumnType::layer_name::stored_type> layer_name)
4525       : macros_internal::MacroTable(
4526           pool,
4527           GetColumns(this, &parent),
4528           parent,
4529           parent_overlay),
4530           const_parent_(&parent)
4531 ,
4532         display_frame_token_storage_layer_(
4533         new column::NumericStorage<ColumnType::display_frame_token::non_optional_stored_type>(
4534           &display_frame_token_.vector(),
4535           ColumnTypeHelper<ColumnType::display_frame_token::stored_type>::ToColumnType(),
4536           false)),
4537         surface_frame_token_storage_layer_(
4538         new column::NumericStorage<ColumnType::surface_frame_token::non_optional_stored_type>(
4539           &surface_frame_token_.vector(),
4540           ColumnTypeHelper<ColumnType::surface_frame_token::stored_type>::ToColumnType(),
4541           false)),
4542         upid_storage_layer_(
4543         new column::NumericStorage<ColumnType::upid::non_optional_stored_type>(
4544           &upid_.vector(),
4545           ColumnTypeHelper<ColumnType::upid::stored_type>::ToColumnType(),
4546           false)),
4547         layer_name_storage_layer_(
4548           new column::StringStorage(string_pool(), &layer_name_.vector()))
4549          {
4550     static_assert(
4551         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::display_frame_token::stored_type>(
4552           ColumnFlag::display_frame_token),
4553         "Column type and flag combination is not valid");
4554       static_assert(
4555         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::surface_frame_token::stored_type>(
4556           ColumnFlag::surface_frame_token),
4557         "Column type and flag combination is not valid");
4558       static_assert(
4559         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::upid::stored_type>(
4560           ColumnFlag::upid),
4561         "Column type and flag combination is not valid");
4562       static_assert(
4563         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::layer_name::stored_type>(
4564           ColumnFlag::layer_name),
4565         "Column type and flag combination is not valid");
4566     PERFETTO_DCHECK(display_frame_token.size() == parent_overlay.size());
4567     display_frame_token_ = std::move(display_frame_token);
4568     PERFETTO_DCHECK(surface_frame_token.size() == parent_overlay.size());
4569     surface_frame_token_ = std::move(surface_frame_token);
4570     PERFETTO_DCHECK(upid.size() == parent_overlay.size());
4571     upid_ = std::move(upid);
4572     PERFETTO_DCHECK(layer_name.size() == parent_overlay.size());
4573     layer_name_ = std::move(layer_name);
4574 
4575     std::vector<RefPtr<column::OverlayLayer>> overlay_layers(OverlayCount(&parent) + 1);
4576     for (uint32_t i = 0; i < overlay_layers.size(); ++i) {
4577       if (overlays()[i].row_map().IsIndexVector()) {
4578         overlay_layers[i].reset(new column::ArrangementOverlay(
4579             overlays()[i].row_map().GetIfIndexVector(),
4580             column::DataLayerChain::Indices::State::kNonmonotonic));
4581       } else if (overlays()[i].row_map().IsBitVector()) {
4582         overlay_layers[i].reset(new column::SelectorOverlay(
4583             overlays()[i].row_map().GetIfBitVector()));
4584       } else if (overlays()[i].row_map().IsRange()) {
4585         overlay_layers[i].reset(new column::RangeOverlay(
4586             overlays()[i].row_map().GetIfIRange()));
4587       }
4588     }
4589 
4590     OnConstructionCompleted(
4591       {const_parent_->storage_layers()[ColumnIndex::id],const_parent_->storage_layers()[ColumnIndex::type],const_parent_->storage_layers()[ColumnIndex::ts],const_parent_->storage_layers()[ColumnIndex::dur],const_parent_->storage_layers()[ColumnIndex::track_id],const_parent_->storage_layers()[ColumnIndex::category],const_parent_->storage_layers()[ColumnIndex::name],const_parent_->storage_layers()[ColumnIndex::depth],const_parent_->storage_layers()[ColumnIndex::stack_id],const_parent_->storage_layers()[ColumnIndex::parent_stack_id],const_parent_->storage_layers()[ColumnIndex::parent_id],const_parent_->storage_layers()[ColumnIndex::arg_set_id],const_parent_->storage_layers()[ColumnIndex::thread_ts],const_parent_->storage_layers()[ColumnIndex::thread_dur],const_parent_->storage_layers()[ColumnIndex::thread_instruction_count],const_parent_->storage_layers()[ColumnIndex::thread_instruction_delta],display_frame_token_storage_layer_,surface_frame_token_storage_layer_,upid_storage_layer_,layer_name_storage_layer_}, {{},{},{},{},{},{},{},{},{},{},const_parent_->null_layers()[ColumnIndex::parent_id],{},const_parent_->null_layers()[ColumnIndex::thread_ts],const_parent_->null_layers()[ColumnIndex::thread_dur],const_parent_->null_layers()[ColumnIndex::thread_instruction_count],const_parent_->null_layers()[ColumnIndex::thread_instruction_delta],{},{},{},{}}, std::move(overlay_layers));
4592   }
4593   SliceTable* parent_ = nullptr;
4594   const SliceTable* const_parent_ = nullptr;
4595   ColumnStorage<ColumnType::display_frame_token::stored_type> display_frame_token_;
4596   ColumnStorage<ColumnType::surface_frame_token::stored_type> surface_frame_token_;
4597   ColumnStorage<ColumnType::upid::stored_type> upid_;
4598   ColumnStorage<ColumnType::layer_name::stored_type> layer_name_;
4599 
4600   RefPtr<column::StorageLayer> display_frame_token_storage_layer_;
4601   RefPtr<column::StorageLayer> surface_frame_token_storage_layer_;
4602   RefPtr<column::StorageLayer> upid_storage_layer_;
4603   RefPtr<column::StorageLayer> layer_name_storage_layer_;
4604 
4605 
4606 };
4607 
4608 
4609 class ExperimentalFlatSliceTable : public macros_internal::MacroTable {
4610  public:
4611   static constexpr uint32_t kColumnCount = 11;
4612 
4613   struct Id : public BaseId {
4614     Id() = default;
IdId4615     explicit constexpr Id(uint32_t v) : BaseId(v) {}
4616   };
4617   static_assert(std::is_trivially_destructible_v<Id>,
4618                 "Inheritance used without trivial destruction");
4619 
4620   struct ColumnIndex {
4621     static constexpr uint32_t id = 0;
4622     static constexpr uint32_t type = 1;
4623     static constexpr uint32_t ts = 2;
4624     static constexpr uint32_t dur = 3;
4625     static constexpr uint32_t track_id = 4;
4626     static constexpr uint32_t category = 5;
4627     static constexpr uint32_t name = 6;
4628     static constexpr uint32_t arg_set_id = 7;
4629     static constexpr uint32_t source_id = 8;
4630     static constexpr uint32_t start_bound = 9;
4631     static constexpr uint32_t end_bound = 10;
4632   };
4633   struct ColumnType {
4634     using id = IdColumn<ExperimentalFlatSliceTable::Id>;
4635     using type = TypedColumn<StringPool::Id>;
4636     using ts = TypedColumn<int64_t>;
4637     using dur = TypedColumn<int64_t>;
4638     using track_id = TypedColumn<TrackTable::Id>;
4639     using category = TypedColumn<std::optional<StringPool::Id>>;
4640     using name = TypedColumn<std::optional<StringPool::Id>>;
4641     using arg_set_id = TypedColumn<uint32_t>;
4642     using source_id = TypedColumn<std::optional<SliceTable::Id>>;
4643     using start_bound = TypedColumn<int64_t>;
4644     using end_bound = TypedColumn<int64_t>;
4645   };
4646   struct Row : public macros_internal::RootParentTable::Row {
4647     Row(int64_t in_ts = {},
4648         int64_t in_dur = {},
4649         TrackTable::Id in_track_id = {},
4650         std::optional<StringPool::Id> in_category = {},
4651         std::optional<StringPool::Id> in_name = {},
4652         uint32_t in_arg_set_id = {},
4653         std::optional<SliceTable::Id> in_source_id = {},
4654         int64_t in_start_bound = {},
4655         int64_t in_end_bound = {},
4656         std::nullptr_t = nullptr)
RowRow4657         : macros_internal::RootParentTable::Row(),
4658           ts(in_ts),
4659           dur(in_dur),
4660           track_id(in_track_id),
4661           category(in_category),
4662           name(in_name),
4663           arg_set_id(in_arg_set_id),
4664           source_id(in_source_id),
4665           start_bound(in_start_bound),
4666           end_bound(in_end_bound) {
4667       type_ = "experimental_flat_slice";
4668     }
4669     int64_t ts;
4670     int64_t dur;
4671     TrackTable::Id track_id;
4672     std::optional<StringPool::Id> category;
4673     std::optional<StringPool::Id> name;
4674     uint32_t arg_set_id;
4675     std::optional<SliceTable::Id> source_id;
4676     int64_t start_bound;
4677     int64_t end_bound;
4678 
4679     bool operator==(const ExperimentalFlatSliceTable::Row& other) const {
4680       return type() == other.type() && ColumnType::ts::Equals(ts, other.ts) &&
4681        ColumnType::dur::Equals(dur, other.dur) &&
4682        ColumnType::track_id::Equals(track_id, other.track_id) &&
4683        ColumnType::category::Equals(category, other.category) &&
4684        ColumnType::name::Equals(name, other.name) &&
4685        ColumnType::arg_set_id::Equals(arg_set_id, other.arg_set_id) &&
4686        ColumnType::source_id::Equals(source_id, other.source_id) &&
4687        ColumnType::start_bound::Equals(start_bound, other.start_bound) &&
4688        ColumnType::end_bound::Equals(end_bound, other.end_bound);
4689     }
4690   };
4691   struct ColumnFlag {
4692     static constexpr uint32_t ts = ColumnType::ts::default_flags();
4693     static constexpr uint32_t dur = ColumnType::dur::default_flags();
4694     static constexpr uint32_t track_id = ColumnType::track_id::default_flags();
4695     static constexpr uint32_t category = ColumnType::category::default_flags();
4696     static constexpr uint32_t name = ColumnType::name::default_flags();
4697     static constexpr uint32_t arg_set_id = ColumnType::arg_set_id::default_flags();
4698     static constexpr uint32_t source_id = ColumnType::source_id::default_flags();
4699     static constexpr uint32_t start_bound = static_cast<uint32_t>(ColumnLegacy::Flag::kHidden) | ColumnType::start_bound::default_flags();
4700     static constexpr uint32_t end_bound = static_cast<uint32_t>(ColumnLegacy::Flag::kHidden) | ColumnType::end_bound::default_flags();
4701   };
4702 
4703   class RowNumber;
4704   class ConstRowReference;
4705   class RowReference;
4706 
4707   class RowNumber : public macros_internal::AbstractRowNumber<
4708       ExperimentalFlatSliceTable, ConstRowReference, RowReference> {
4709    public:
RowNumber(uint32_t row_number)4710     explicit RowNumber(uint32_t row_number)
4711         : AbstractRowNumber(row_number) {}
4712   };
4713   static_assert(std::is_trivially_destructible_v<RowNumber>,
4714                 "Inheritance used without trivial destruction");
4715 
4716   class ConstRowReference : public macros_internal::AbstractConstRowReference<
4717     ExperimentalFlatSliceTable, RowNumber> {
4718    public:
ConstRowReference(const ExperimentalFlatSliceTable * table,uint32_t row_number)4719     ConstRowReference(const ExperimentalFlatSliceTable* table, uint32_t row_number)
4720         : AbstractConstRowReference(table, row_number) {}
4721 
id()4722     ColumnType::id::type id() const {
4723       return table()->id()[row_number_];
4724     }
type()4725     ColumnType::type::type type() const {
4726       return table()->type()[row_number_];
4727     }
ts()4728     ColumnType::ts::type ts() const {
4729       return table()->ts()[row_number_];
4730     }
dur()4731     ColumnType::dur::type dur() const {
4732       return table()->dur()[row_number_];
4733     }
track_id()4734     ColumnType::track_id::type track_id() const {
4735       return table()->track_id()[row_number_];
4736     }
category()4737     ColumnType::category::type category() const {
4738       return table()->category()[row_number_];
4739     }
name()4740     ColumnType::name::type name() const {
4741       return table()->name()[row_number_];
4742     }
arg_set_id()4743     ColumnType::arg_set_id::type arg_set_id() const {
4744       return table()->arg_set_id()[row_number_];
4745     }
source_id()4746     ColumnType::source_id::type source_id() const {
4747       return table()->source_id()[row_number_];
4748     }
start_bound()4749     ColumnType::start_bound::type start_bound() const {
4750       return table()->start_bound()[row_number_];
4751     }
end_bound()4752     ColumnType::end_bound::type end_bound() const {
4753       return table()->end_bound()[row_number_];
4754     }
4755   };
4756   static_assert(std::is_trivially_destructible_v<ConstRowReference>,
4757                 "Inheritance used without trivial destruction");
4758   class RowReference : public ConstRowReference {
4759    public:
RowReference(const ExperimentalFlatSliceTable * table,uint32_t row_number)4760     RowReference(const ExperimentalFlatSliceTable* table, uint32_t row_number)
4761         : ConstRowReference(table, row_number) {}
4762 
set_ts(ColumnType::ts::non_optional_type v)4763     void set_ts(
4764         ColumnType::ts::non_optional_type v) {
4765       return mutable_table()->mutable_ts()->Set(row_number_, v);
4766     }
set_dur(ColumnType::dur::non_optional_type v)4767     void set_dur(
4768         ColumnType::dur::non_optional_type v) {
4769       return mutable_table()->mutable_dur()->Set(row_number_, v);
4770     }
set_track_id(ColumnType::track_id::non_optional_type v)4771     void set_track_id(
4772         ColumnType::track_id::non_optional_type v) {
4773       return mutable_table()->mutable_track_id()->Set(row_number_, v);
4774     }
set_category(ColumnType::category::non_optional_type v)4775     void set_category(
4776         ColumnType::category::non_optional_type v) {
4777       return mutable_table()->mutable_category()->Set(row_number_, v);
4778     }
set_name(ColumnType::name::non_optional_type v)4779     void set_name(
4780         ColumnType::name::non_optional_type v) {
4781       return mutable_table()->mutable_name()->Set(row_number_, v);
4782     }
set_arg_set_id(ColumnType::arg_set_id::non_optional_type v)4783     void set_arg_set_id(
4784         ColumnType::arg_set_id::non_optional_type v) {
4785       return mutable_table()->mutable_arg_set_id()->Set(row_number_, v);
4786     }
set_source_id(ColumnType::source_id::non_optional_type v)4787     void set_source_id(
4788         ColumnType::source_id::non_optional_type v) {
4789       return mutable_table()->mutable_source_id()->Set(row_number_, v);
4790     }
set_start_bound(ColumnType::start_bound::non_optional_type v)4791     void set_start_bound(
4792         ColumnType::start_bound::non_optional_type v) {
4793       return mutable_table()->mutable_start_bound()->Set(row_number_, v);
4794     }
set_end_bound(ColumnType::end_bound::non_optional_type v)4795     void set_end_bound(
4796         ColumnType::end_bound::non_optional_type v) {
4797       return mutable_table()->mutable_end_bound()->Set(row_number_, v);
4798     }
4799 
4800    private:
mutable_table()4801     ExperimentalFlatSliceTable* mutable_table() const {
4802       return const_cast<ExperimentalFlatSliceTable*>(table());
4803     }
4804   };
4805   static_assert(std::is_trivially_destructible_v<RowReference>,
4806                 "Inheritance used without trivial destruction");
4807 
4808   class ConstIterator;
4809   class ConstIterator : public macros_internal::AbstractConstIterator<
4810     ConstIterator, ExperimentalFlatSliceTable, RowNumber, ConstRowReference> {
4811    public:
id()4812     ColumnType::id::type id() const {
4813       const auto& col = table()->id();
4814       return col.GetAtIdx(
4815         iterator_.StorageIndexForColumn(col.index_in_table()));
4816     }
type()4817     ColumnType::type::type type() const {
4818       const auto& col = table()->type();
4819       return col.GetAtIdx(
4820         iterator_.StorageIndexForColumn(col.index_in_table()));
4821     }
ts()4822     ColumnType::ts::type ts() const {
4823       const auto& col = table()->ts();
4824       return col.GetAtIdx(
4825         iterator_.StorageIndexForColumn(col.index_in_table()));
4826     }
dur()4827     ColumnType::dur::type dur() const {
4828       const auto& col = table()->dur();
4829       return col.GetAtIdx(
4830         iterator_.StorageIndexForColumn(col.index_in_table()));
4831     }
track_id()4832     ColumnType::track_id::type track_id() const {
4833       const auto& col = table()->track_id();
4834       return col.GetAtIdx(
4835         iterator_.StorageIndexForColumn(col.index_in_table()));
4836     }
category()4837     ColumnType::category::type category() const {
4838       const auto& col = table()->category();
4839       return col.GetAtIdx(
4840         iterator_.StorageIndexForColumn(col.index_in_table()));
4841     }
name()4842     ColumnType::name::type name() const {
4843       const auto& col = table()->name();
4844       return col.GetAtIdx(
4845         iterator_.StorageIndexForColumn(col.index_in_table()));
4846     }
arg_set_id()4847     ColumnType::arg_set_id::type arg_set_id() const {
4848       const auto& col = table()->arg_set_id();
4849       return col.GetAtIdx(
4850         iterator_.StorageIndexForColumn(col.index_in_table()));
4851     }
source_id()4852     ColumnType::source_id::type source_id() const {
4853       const auto& col = table()->source_id();
4854       return col.GetAtIdx(
4855         iterator_.StorageIndexForColumn(col.index_in_table()));
4856     }
start_bound()4857     ColumnType::start_bound::type start_bound() const {
4858       const auto& col = table()->start_bound();
4859       return col.GetAtIdx(
4860         iterator_.StorageIndexForColumn(col.index_in_table()));
4861     }
end_bound()4862     ColumnType::end_bound::type end_bound() const {
4863       const auto& col = table()->end_bound();
4864       return col.GetAtIdx(
4865         iterator_.StorageIndexForColumn(col.index_in_table()));
4866     }
4867 
4868    protected:
ConstIterator(const ExperimentalFlatSliceTable * table,Table::Iterator iterator)4869     explicit ConstIterator(const ExperimentalFlatSliceTable* table,
4870                            Table::Iterator iterator)
4871         : AbstractConstIterator(table, std::move(iterator)) {}
4872 
CurrentRowNumber()4873     uint32_t CurrentRowNumber() const {
4874       return iterator_.StorageIndexForLastOverlay();
4875     }
4876 
4877    private:
4878     friend class ExperimentalFlatSliceTable;
4879     friend class macros_internal::AbstractConstIterator<
4880       ConstIterator, ExperimentalFlatSliceTable, RowNumber, ConstRowReference>;
4881   };
4882   class Iterator : public ConstIterator {
4883     public:
row_reference()4884      RowReference row_reference() const {
4885        return {const_cast<ExperimentalFlatSliceTable*>(table()), CurrentRowNumber()};
4886      }
4887 
4888     private:
4889      friend class ExperimentalFlatSliceTable;
4890 
Iterator(ExperimentalFlatSliceTable * table,Table::Iterator iterator)4891      explicit Iterator(ExperimentalFlatSliceTable* table, Table::Iterator iterator)
4892         : ConstIterator(table, std::move(iterator)) {}
4893   };
4894 
4895   struct IdAndRow {
4896     Id id;
4897     uint32_t row;
4898     RowReference row_reference;
4899     RowNumber row_number;
4900   };
4901 
GetColumns(ExperimentalFlatSliceTable * self,const macros_internal::MacroTable * parent)4902   static std::vector<ColumnLegacy> GetColumns(
4903       ExperimentalFlatSliceTable* self,
4904       const macros_internal::MacroTable* parent) {
4905     std::vector<ColumnLegacy> columns =
4906         CopyColumnsFromParentOrAddRootColumns(self, parent);
4907     uint32_t olay_idx = OverlayCount(parent);
4908     AddColumnToVector(columns, "ts", &self->ts_, ColumnFlag::ts,
4909                       static_cast<uint32_t>(columns.size()), olay_idx);
4910     AddColumnToVector(columns, "dur", &self->dur_, ColumnFlag::dur,
4911                       static_cast<uint32_t>(columns.size()), olay_idx);
4912     AddColumnToVector(columns, "track_id", &self->track_id_, ColumnFlag::track_id,
4913                       static_cast<uint32_t>(columns.size()), olay_idx);
4914     AddColumnToVector(columns, "category", &self->category_, ColumnFlag::category,
4915                       static_cast<uint32_t>(columns.size()), olay_idx);
4916     AddColumnToVector(columns, "name", &self->name_, ColumnFlag::name,
4917                       static_cast<uint32_t>(columns.size()), olay_idx);
4918     AddColumnToVector(columns, "arg_set_id", &self->arg_set_id_, ColumnFlag::arg_set_id,
4919                       static_cast<uint32_t>(columns.size()), olay_idx);
4920     AddColumnToVector(columns, "source_id", &self->source_id_, ColumnFlag::source_id,
4921                       static_cast<uint32_t>(columns.size()), olay_idx);
4922     AddColumnToVector(columns, "start_bound", &self->start_bound_, ColumnFlag::start_bound,
4923                       static_cast<uint32_t>(columns.size()), olay_idx);
4924     AddColumnToVector(columns, "end_bound", &self->end_bound_, ColumnFlag::end_bound,
4925                       static_cast<uint32_t>(columns.size()), olay_idx);
4926     return columns;
4927   }
4928 
ExperimentalFlatSliceTable(StringPool * pool)4929   PERFETTO_NO_INLINE explicit ExperimentalFlatSliceTable(StringPool* pool)
4930       : macros_internal::MacroTable(
4931           pool,
4932           GetColumns(this, nullptr),
4933           nullptr),
4934         ts_(ColumnStorage<ColumnType::ts::stored_type>::Create<false>()),
4935         dur_(ColumnStorage<ColumnType::dur::stored_type>::Create<false>()),
4936         track_id_(ColumnStorage<ColumnType::track_id::stored_type>::Create<false>()),
4937         category_(ColumnStorage<ColumnType::category::stored_type>::Create<false>()),
4938         name_(ColumnStorage<ColumnType::name::stored_type>::Create<false>()),
4939         arg_set_id_(ColumnStorage<ColumnType::arg_set_id::stored_type>::Create<false>()),
4940         source_id_(ColumnStorage<ColumnType::source_id::stored_type>::Create<false>()),
4941         start_bound_(ColumnStorage<ColumnType::start_bound::stored_type>::Create<false>()),
4942         end_bound_(ColumnStorage<ColumnType::end_bound::stored_type>::Create<false>())
4943 ,
4944         id_storage_layer_(new column::IdStorage()),
4945         type_storage_layer_(
4946           new column::StringStorage(string_pool(), &type_.vector())),
4947         ts_storage_layer_(
4948         new column::NumericStorage<ColumnType::ts::non_optional_stored_type>(
4949           &ts_.vector(),
4950           ColumnTypeHelper<ColumnType::ts::stored_type>::ToColumnType(),
4951           false)),
4952         dur_storage_layer_(
4953         new column::NumericStorage<ColumnType::dur::non_optional_stored_type>(
4954           &dur_.vector(),
4955           ColumnTypeHelper<ColumnType::dur::stored_type>::ToColumnType(),
4956           false)),
4957         track_id_storage_layer_(
4958         new column::NumericStorage<ColumnType::track_id::non_optional_stored_type>(
4959           &track_id_.vector(),
4960           ColumnTypeHelper<ColumnType::track_id::stored_type>::ToColumnType(),
4961           false)),
4962         category_storage_layer_(
4963           new column::StringStorage(string_pool(), &category_.vector())),
4964         name_storage_layer_(
4965           new column::StringStorage(string_pool(), &name_.vector())),
4966         arg_set_id_storage_layer_(
4967         new column::NumericStorage<ColumnType::arg_set_id::non_optional_stored_type>(
4968           &arg_set_id_.vector(),
4969           ColumnTypeHelper<ColumnType::arg_set_id::stored_type>::ToColumnType(),
4970           false)),
4971         source_id_storage_layer_(
4972           new column::NumericStorage<ColumnType::source_id::non_optional_stored_type>(
4973             &source_id_.non_null_vector(),
4974             ColumnTypeHelper<ColumnType::source_id::stored_type>::ToColumnType(),
4975             false)),
4976         start_bound_storage_layer_(
4977         new column::NumericStorage<ColumnType::start_bound::non_optional_stored_type>(
4978           &start_bound_.vector(),
4979           ColumnTypeHelper<ColumnType::start_bound::stored_type>::ToColumnType(),
4980           false)),
4981         end_bound_storage_layer_(
4982         new column::NumericStorage<ColumnType::end_bound::non_optional_stored_type>(
4983           &end_bound_.vector(),
4984           ColumnTypeHelper<ColumnType::end_bound::stored_type>::ToColumnType(),
4985           false))
4986 ,
4987         source_id_null_layer_(new column::NullOverlay(source_id_.bv())) {
4988     static_assert(
4989         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::ts::stored_type>(
4990           ColumnFlag::ts),
4991         "Column type and flag combination is not valid");
4992       static_assert(
4993         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::dur::stored_type>(
4994           ColumnFlag::dur),
4995         "Column type and flag combination is not valid");
4996       static_assert(
4997         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::track_id::stored_type>(
4998           ColumnFlag::track_id),
4999         "Column type and flag combination is not valid");
5000       static_assert(
5001         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::category::stored_type>(
5002           ColumnFlag::category),
5003         "Column type and flag combination is not valid");
5004       static_assert(
5005         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::name::stored_type>(
5006           ColumnFlag::name),
5007         "Column type and flag combination is not valid");
5008       static_assert(
5009         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::arg_set_id::stored_type>(
5010           ColumnFlag::arg_set_id),
5011         "Column type and flag combination is not valid");
5012       static_assert(
5013         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::source_id::stored_type>(
5014           ColumnFlag::source_id),
5015         "Column type and flag combination is not valid");
5016       static_assert(
5017         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::start_bound::stored_type>(
5018           ColumnFlag::start_bound),
5019         "Column type and flag combination is not valid");
5020       static_assert(
5021         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::end_bound::stored_type>(
5022           ColumnFlag::end_bound),
5023         "Column type and flag combination is not valid");
5024     OnConstructionCompletedRegularConstructor(
5025       {id_storage_layer_,type_storage_layer_,ts_storage_layer_,dur_storage_layer_,track_id_storage_layer_,category_storage_layer_,name_storage_layer_,arg_set_id_storage_layer_,source_id_storage_layer_,start_bound_storage_layer_,end_bound_storage_layer_},
5026       {{},{},{},{},{},{},{},{},source_id_null_layer_,{},{}});
5027   }
5028   ~ExperimentalFlatSliceTable() override;
5029 
Name()5030   static const char* Name() { return "experimental_flat_slice"; }
5031 
ComputeStaticSchema()5032   static Table::Schema ComputeStaticSchema() {
5033     Table::Schema schema;
5034     schema.columns.emplace_back(Table::Schema::Column{
5035         "id", SqlValue::Type::kLong, true, true, false, false});
5036     schema.columns.emplace_back(Table::Schema::Column{
5037         "type", SqlValue::Type::kString, false, false, false, false});
5038     schema.columns.emplace_back(Table::Schema::Column{
5039         "ts", ColumnType::ts::SqlValueType(), false,
5040         false,
5041         false,
5042         false});
5043     schema.columns.emplace_back(Table::Schema::Column{
5044         "dur", ColumnType::dur::SqlValueType(), false,
5045         false,
5046         false,
5047         false});
5048     schema.columns.emplace_back(Table::Schema::Column{
5049         "track_id", ColumnType::track_id::SqlValueType(), false,
5050         false,
5051         false,
5052         false});
5053     schema.columns.emplace_back(Table::Schema::Column{
5054         "category", ColumnType::category::SqlValueType(), false,
5055         false,
5056         false,
5057         false});
5058     schema.columns.emplace_back(Table::Schema::Column{
5059         "name", ColumnType::name::SqlValueType(), false,
5060         false,
5061         false,
5062         false});
5063     schema.columns.emplace_back(Table::Schema::Column{
5064         "arg_set_id", ColumnType::arg_set_id::SqlValueType(), false,
5065         false,
5066         false,
5067         false});
5068     schema.columns.emplace_back(Table::Schema::Column{
5069         "source_id", ColumnType::source_id::SqlValueType(), false,
5070         false,
5071         false,
5072         false});
5073     schema.columns.emplace_back(Table::Schema::Column{
5074         "start_bound", ColumnType::start_bound::SqlValueType(), false,
5075         false,
5076         true,
5077         false});
5078     schema.columns.emplace_back(Table::Schema::Column{
5079         "end_bound", ColumnType::end_bound::SqlValueType(), false,
5080         false,
5081         true,
5082         false});
5083     return schema;
5084   }
5085 
IterateRows()5086   ConstIterator IterateRows() const {
5087     return ConstIterator(this, Table::IterateRows());
5088   }
5089 
IterateRows()5090   Iterator IterateRows() { return Iterator(this, Table::IterateRows()); }
5091 
FilterToIterator(const Query & q)5092   ConstIterator FilterToIterator(const Query& q) const {
5093     return ConstIterator(this, QueryToIterator(q));
5094   }
5095 
FilterToIterator(const Query & q)5096   Iterator FilterToIterator(const Query& q) {
5097     return Iterator(this, QueryToIterator(q));
5098   }
5099 
ShrinkToFit()5100   void ShrinkToFit() {
5101     type_.ShrinkToFit();
5102     ts_.ShrinkToFit();
5103     dur_.ShrinkToFit();
5104     track_id_.ShrinkToFit();
5105     category_.ShrinkToFit();
5106     name_.ShrinkToFit();
5107     arg_set_id_.ShrinkToFit();
5108     source_id_.ShrinkToFit();
5109     start_bound_.ShrinkToFit();
5110     end_bound_.ShrinkToFit();
5111   }
5112 
5113   ConstRowReference operator[](uint32_t r) const {
5114     return ConstRowReference(this, r);
5115   }
5116   RowReference operator[](uint32_t r) { return RowReference(this, r); }
5117   ConstRowReference operator[](RowNumber r) const {
5118     return ConstRowReference(this, r.row_number());
5119   }
5120   RowReference operator[](RowNumber r) {
5121     return RowReference(this, r.row_number());
5122   }
5123 
FindById(Id find_id)5124   std::optional<ConstRowReference> FindById(Id find_id) const {
5125     std::optional<uint32_t> row = id().IndexOf(find_id);
5126     return row ? std::make_optional(ConstRowReference(this, *row))
5127                : std::nullopt;
5128   }
5129 
FindById(Id find_id)5130   std::optional<RowReference> FindById(Id find_id) {
5131     std::optional<uint32_t> row = id().IndexOf(find_id);
5132     return row ? std::make_optional(RowReference(this, *row)) : std::nullopt;
5133   }
5134 
Insert(const Row & row)5135   IdAndRow Insert(const Row& row) {
5136     uint32_t row_number = row_count();
5137     Id id = Id{row_number};
5138     type_.Append(string_pool()->InternString(row.type()));
5139     mutable_ts()->Append(row.ts);
5140     mutable_dur()->Append(row.dur);
5141     mutable_track_id()->Append(row.track_id);
5142     mutable_category()->Append(row.category);
5143     mutable_name()->Append(row.name);
5144     mutable_arg_set_id()->Append(row.arg_set_id);
5145     mutable_source_id()->Append(row.source_id);
5146     mutable_start_bound()->Append(row.start_bound);
5147     mutable_end_bound()->Append(row.end_bound);
5148     UpdateSelfOverlayAfterInsert();
5149     return IdAndRow{id, row_number, RowReference(this, row_number),
5150                      RowNumber(row_number)};
5151   }
5152 
5153 
5154 
id()5155   const IdColumn<ExperimentalFlatSliceTable::Id>& id() const {
5156     return static_cast<const ColumnType::id&>(columns()[ColumnIndex::id]);
5157   }
type()5158   const TypedColumn<StringPool::Id>& type() const {
5159     return static_cast<const ColumnType::type&>(columns()[ColumnIndex::type]);
5160   }
ts()5161   const TypedColumn<int64_t>& ts() const {
5162     return static_cast<const ColumnType::ts&>(columns()[ColumnIndex::ts]);
5163   }
dur()5164   const TypedColumn<int64_t>& dur() const {
5165     return static_cast<const ColumnType::dur&>(columns()[ColumnIndex::dur]);
5166   }
track_id()5167   const TypedColumn<TrackTable::Id>& track_id() const {
5168     return static_cast<const ColumnType::track_id&>(columns()[ColumnIndex::track_id]);
5169   }
category()5170   const TypedColumn<std::optional<StringPool::Id>>& category() const {
5171     return static_cast<const ColumnType::category&>(columns()[ColumnIndex::category]);
5172   }
name()5173   const TypedColumn<std::optional<StringPool::Id>>& name() const {
5174     return static_cast<const ColumnType::name&>(columns()[ColumnIndex::name]);
5175   }
arg_set_id()5176   const TypedColumn<uint32_t>& arg_set_id() const {
5177     return static_cast<const ColumnType::arg_set_id&>(columns()[ColumnIndex::arg_set_id]);
5178   }
source_id()5179   const TypedColumn<std::optional<SliceTable::Id>>& source_id() const {
5180     return static_cast<const ColumnType::source_id&>(columns()[ColumnIndex::source_id]);
5181   }
start_bound()5182   const TypedColumn<int64_t>& start_bound() const {
5183     return static_cast<const ColumnType::start_bound&>(columns()[ColumnIndex::start_bound]);
5184   }
end_bound()5185   const TypedColumn<int64_t>& end_bound() const {
5186     return static_cast<const ColumnType::end_bound&>(columns()[ColumnIndex::end_bound]);
5187   }
5188 
mutable_ts()5189   TypedColumn<int64_t>* mutable_ts() {
5190     return static_cast<ColumnType::ts*>(
5191         GetColumn(ColumnIndex::ts));
5192   }
mutable_dur()5193   TypedColumn<int64_t>* mutable_dur() {
5194     return static_cast<ColumnType::dur*>(
5195         GetColumn(ColumnIndex::dur));
5196   }
mutable_track_id()5197   TypedColumn<TrackTable::Id>* mutable_track_id() {
5198     return static_cast<ColumnType::track_id*>(
5199         GetColumn(ColumnIndex::track_id));
5200   }
mutable_category()5201   TypedColumn<std::optional<StringPool::Id>>* mutable_category() {
5202     return static_cast<ColumnType::category*>(
5203         GetColumn(ColumnIndex::category));
5204   }
mutable_name()5205   TypedColumn<std::optional<StringPool::Id>>* mutable_name() {
5206     return static_cast<ColumnType::name*>(
5207         GetColumn(ColumnIndex::name));
5208   }
mutable_arg_set_id()5209   TypedColumn<uint32_t>* mutable_arg_set_id() {
5210     return static_cast<ColumnType::arg_set_id*>(
5211         GetColumn(ColumnIndex::arg_set_id));
5212   }
mutable_source_id()5213   TypedColumn<std::optional<SliceTable::Id>>* mutable_source_id() {
5214     return static_cast<ColumnType::source_id*>(
5215         GetColumn(ColumnIndex::source_id));
5216   }
mutable_start_bound()5217   TypedColumn<int64_t>* mutable_start_bound() {
5218     return static_cast<ColumnType::start_bound*>(
5219         GetColumn(ColumnIndex::start_bound));
5220   }
mutable_end_bound()5221   TypedColumn<int64_t>* mutable_end_bound() {
5222     return static_cast<ColumnType::end_bound*>(
5223         GetColumn(ColumnIndex::end_bound));
5224   }
5225 
5226  private:
5227 
5228 
5229   ColumnStorage<ColumnType::ts::stored_type> ts_;
5230   ColumnStorage<ColumnType::dur::stored_type> dur_;
5231   ColumnStorage<ColumnType::track_id::stored_type> track_id_;
5232   ColumnStorage<ColumnType::category::stored_type> category_;
5233   ColumnStorage<ColumnType::name::stored_type> name_;
5234   ColumnStorage<ColumnType::arg_set_id::stored_type> arg_set_id_;
5235   ColumnStorage<ColumnType::source_id::stored_type> source_id_;
5236   ColumnStorage<ColumnType::start_bound::stored_type> start_bound_;
5237   ColumnStorage<ColumnType::end_bound::stored_type> end_bound_;
5238 
5239   RefPtr<column::StorageLayer> id_storage_layer_;
5240   RefPtr<column::StorageLayer> type_storage_layer_;
5241   RefPtr<column::StorageLayer> ts_storage_layer_;
5242   RefPtr<column::StorageLayer> dur_storage_layer_;
5243   RefPtr<column::StorageLayer> track_id_storage_layer_;
5244   RefPtr<column::StorageLayer> category_storage_layer_;
5245   RefPtr<column::StorageLayer> name_storage_layer_;
5246   RefPtr<column::StorageLayer> arg_set_id_storage_layer_;
5247   RefPtr<column::StorageLayer> source_id_storage_layer_;
5248   RefPtr<column::StorageLayer> start_bound_storage_layer_;
5249   RefPtr<column::StorageLayer> end_bound_storage_layer_;
5250 
5251   RefPtr<column::OverlayLayer> source_id_null_layer_;
5252 };
5253 
5254 
5255 class GpuSliceTable : public macros_internal::MacroTable {
5256  public:
5257   static constexpr uint32_t kColumnCount = 28;
5258 
5259   using Id = SliceTable::Id;
5260 
5261   struct ColumnIndex {
5262     static constexpr uint32_t id = 0;
5263     static constexpr uint32_t type = 1;
5264     static constexpr uint32_t ts = 2;
5265     static constexpr uint32_t dur = 3;
5266     static constexpr uint32_t track_id = 4;
5267     static constexpr uint32_t category = 5;
5268     static constexpr uint32_t name = 6;
5269     static constexpr uint32_t depth = 7;
5270     static constexpr uint32_t stack_id = 8;
5271     static constexpr uint32_t parent_stack_id = 9;
5272     static constexpr uint32_t parent_id = 10;
5273     static constexpr uint32_t arg_set_id = 11;
5274     static constexpr uint32_t thread_ts = 12;
5275     static constexpr uint32_t thread_dur = 13;
5276     static constexpr uint32_t thread_instruction_count = 14;
5277     static constexpr uint32_t thread_instruction_delta = 15;
5278     static constexpr uint32_t context_id = 16;
5279     static constexpr uint32_t render_target = 17;
5280     static constexpr uint32_t render_target_name = 18;
5281     static constexpr uint32_t render_pass = 19;
5282     static constexpr uint32_t render_pass_name = 20;
5283     static constexpr uint32_t command_buffer = 21;
5284     static constexpr uint32_t command_buffer_name = 22;
5285     static constexpr uint32_t frame_id = 23;
5286     static constexpr uint32_t submission_id = 24;
5287     static constexpr uint32_t hw_queue_id = 25;
5288     static constexpr uint32_t upid = 26;
5289     static constexpr uint32_t render_subpasses = 27;
5290   };
5291   struct ColumnType {
5292     using id = IdColumn<GpuSliceTable::Id>;
5293     using type = TypedColumn<StringPool::Id>;
5294     using ts = TypedColumn<int64_t>;
5295     using dur = TypedColumn<int64_t>;
5296     using track_id = TypedColumn<TrackTable::Id>;
5297     using category = TypedColumn<std::optional<StringPool::Id>>;
5298     using name = TypedColumn<std::optional<StringPool::Id>>;
5299     using depth = TypedColumn<uint32_t>;
5300     using stack_id = TypedColumn<int64_t>;
5301     using parent_stack_id = TypedColumn<int64_t>;
5302     using parent_id = TypedColumn<std::optional<GpuSliceTable::Id>>;
5303     using arg_set_id = TypedColumn<uint32_t>;
5304     using thread_ts = TypedColumn<std::optional<int64_t>>;
5305     using thread_dur = TypedColumn<std::optional<int64_t>>;
5306     using thread_instruction_count = TypedColumn<std::optional<int64_t>>;
5307     using thread_instruction_delta = TypedColumn<std::optional<int64_t>>;
5308     using context_id = TypedColumn<std::optional<int64_t>>;
5309     using render_target = TypedColumn<std::optional<int64_t>>;
5310     using render_target_name = TypedColumn<StringPool::Id>;
5311     using render_pass = TypedColumn<std::optional<int64_t>>;
5312     using render_pass_name = TypedColumn<StringPool::Id>;
5313     using command_buffer = TypedColumn<std::optional<int64_t>>;
5314     using command_buffer_name = TypedColumn<StringPool::Id>;
5315     using frame_id = TypedColumn<std::optional<uint32_t>>;
5316     using submission_id = TypedColumn<std::optional<uint32_t>>;
5317     using hw_queue_id = TypedColumn<std::optional<int64_t>>;
5318     using upid = TypedColumn<std::optional<uint32_t>>;
5319     using render_subpasses = TypedColumn<StringPool::Id>;
5320   };
5321   struct Row : public SliceTable::Row {
5322     Row(int64_t in_ts = {},
5323         int64_t in_dur = {},
5324         TrackTable::Id in_track_id = {},
5325         std::optional<StringPool::Id> in_category = {},
5326         std::optional<StringPool::Id> in_name = {},
5327         uint32_t in_depth = {},
5328         int64_t in_stack_id = {},
5329         int64_t in_parent_stack_id = {},
5330         std::optional<GpuSliceTable::Id> in_parent_id = {},
5331         uint32_t in_arg_set_id = {},
5332         std::optional<int64_t> in_thread_ts = {},
5333         std::optional<int64_t> in_thread_dur = {},
5334         std::optional<int64_t> in_thread_instruction_count = {},
5335         std::optional<int64_t> in_thread_instruction_delta = {},
5336         std::optional<int64_t> in_context_id = {},
5337         std::optional<int64_t> in_render_target = {},
5338         StringPool::Id in_render_target_name = {},
5339         std::optional<int64_t> in_render_pass = {},
5340         StringPool::Id in_render_pass_name = {},
5341         std::optional<int64_t> in_command_buffer = {},
5342         StringPool::Id in_command_buffer_name = {},
5343         std::optional<uint32_t> in_frame_id = {},
5344         std::optional<uint32_t> in_submission_id = {},
5345         std::optional<int64_t> in_hw_queue_id = {},
5346         std::optional<uint32_t> in_upid = {},
5347         StringPool::Id in_render_subpasses = {},
5348         std::nullptr_t = nullptr)
RowRow5349         : SliceTable::Row(in_ts, in_dur, in_track_id, in_category, in_name, in_depth, in_stack_id, in_parent_stack_id, in_parent_id, in_arg_set_id, in_thread_ts, in_thread_dur, in_thread_instruction_count, in_thread_instruction_delta),
5350           context_id(in_context_id),
5351           render_target(in_render_target),
5352           render_target_name(in_render_target_name),
5353           render_pass(in_render_pass),
5354           render_pass_name(in_render_pass_name),
5355           command_buffer(in_command_buffer),
5356           command_buffer_name(in_command_buffer_name),
5357           frame_id(in_frame_id),
5358           submission_id(in_submission_id),
5359           hw_queue_id(in_hw_queue_id),
5360           upid(in_upid),
5361           render_subpasses(in_render_subpasses) {
5362       type_ = "gpu_slice";
5363     }
5364     std::optional<int64_t> context_id;
5365     std::optional<int64_t> render_target;
5366     StringPool::Id render_target_name;
5367     std::optional<int64_t> render_pass;
5368     StringPool::Id render_pass_name;
5369     std::optional<int64_t> command_buffer;
5370     StringPool::Id command_buffer_name;
5371     std::optional<uint32_t> frame_id;
5372     std::optional<uint32_t> submission_id;
5373     std::optional<int64_t> hw_queue_id;
5374     std::optional<uint32_t> upid;
5375     StringPool::Id render_subpasses;
5376 
5377     bool operator==(const GpuSliceTable::Row& other) const {
5378       return type() == other.type() && ColumnType::ts::Equals(ts, other.ts) &&
5379        ColumnType::dur::Equals(dur, other.dur) &&
5380        ColumnType::track_id::Equals(track_id, other.track_id) &&
5381        ColumnType::category::Equals(category, other.category) &&
5382        ColumnType::name::Equals(name, other.name) &&
5383        ColumnType::depth::Equals(depth, other.depth) &&
5384        ColumnType::stack_id::Equals(stack_id, other.stack_id) &&
5385        ColumnType::parent_stack_id::Equals(parent_stack_id, other.parent_stack_id) &&
5386        ColumnType::parent_id::Equals(parent_id, other.parent_id) &&
5387        ColumnType::arg_set_id::Equals(arg_set_id, other.arg_set_id) &&
5388        ColumnType::thread_ts::Equals(thread_ts, other.thread_ts) &&
5389        ColumnType::thread_dur::Equals(thread_dur, other.thread_dur) &&
5390        ColumnType::thread_instruction_count::Equals(thread_instruction_count, other.thread_instruction_count) &&
5391        ColumnType::thread_instruction_delta::Equals(thread_instruction_delta, other.thread_instruction_delta) &&
5392        ColumnType::context_id::Equals(context_id, other.context_id) &&
5393        ColumnType::render_target::Equals(render_target, other.render_target) &&
5394        ColumnType::render_target_name::Equals(render_target_name, other.render_target_name) &&
5395        ColumnType::render_pass::Equals(render_pass, other.render_pass) &&
5396        ColumnType::render_pass_name::Equals(render_pass_name, other.render_pass_name) &&
5397        ColumnType::command_buffer::Equals(command_buffer, other.command_buffer) &&
5398        ColumnType::command_buffer_name::Equals(command_buffer_name, other.command_buffer_name) &&
5399        ColumnType::frame_id::Equals(frame_id, other.frame_id) &&
5400        ColumnType::submission_id::Equals(submission_id, other.submission_id) &&
5401        ColumnType::hw_queue_id::Equals(hw_queue_id, other.hw_queue_id) &&
5402        ColumnType::upid::Equals(upid, other.upid) &&
5403        ColumnType::render_subpasses::Equals(render_subpasses, other.render_subpasses);
5404     }
5405   };
5406   struct ColumnFlag {
5407     static constexpr uint32_t context_id = ColumnType::context_id::default_flags();
5408     static constexpr uint32_t render_target = ColumnType::render_target::default_flags();
5409     static constexpr uint32_t render_target_name = ColumnType::render_target_name::default_flags();
5410     static constexpr uint32_t render_pass = ColumnType::render_pass::default_flags();
5411     static constexpr uint32_t render_pass_name = ColumnType::render_pass_name::default_flags();
5412     static constexpr uint32_t command_buffer = ColumnType::command_buffer::default_flags();
5413     static constexpr uint32_t command_buffer_name = ColumnType::command_buffer_name::default_flags();
5414     static constexpr uint32_t frame_id = ColumnType::frame_id::default_flags();
5415     static constexpr uint32_t submission_id = ColumnType::submission_id::default_flags();
5416     static constexpr uint32_t hw_queue_id = ColumnType::hw_queue_id::default_flags();
5417     static constexpr uint32_t upid = ColumnType::upid::default_flags();
5418     static constexpr uint32_t render_subpasses = ColumnType::render_subpasses::default_flags();
5419   };
5420 
5421   class RowNumber;
5422   class ConstRowReference;
5423   class RowReference;
5424 
5425   class RowNumber : public macros_internal::AbstractRowNumber<
5426       GpuSliceTable, ConstRowReference, RowReference> {
5427    public:
RowNumber(uint32_t row_number)5428     explicit RowNumber(uint32_t row_number)
5429         : AbstractRowNumber(row_number) {}
5430   };
5431   static_assert(std::is_trivially_destructible_v<RowNumber>,
5432                 "Inheritance used without trivial destruction");
5433 
5434   class ConstRowReference : public macros_internal::AbstractConstRowReference<
5435     GpuSliceTable, RowNumber> {
5436    public:
ConstRowReference(const GpuSliceTable * table,uint32_t row_number)5437     ConstRowReference(const GpuSliceTable* table, uint32_t row_number)
5438         : AbstractConstRowReference(table, row_number) {}
5439 
id()5440     ColumnType::id::type id() const {
5441       return table()->id()[row_number_];
5442     }
type()5443     ColumnType::type::type type() const {
5444       return table()->type()[row_number_];
5445     }
ts()5446     ColumnType::ts::type ts() const {
5447       return table()->ts()[row_number_];
5448     }
dur()5449     ColumnType::dur::type dur() const {
5450       return table()->dur()[row_number_];
5451     }
track_id()5452     ColumnType::track_id::type track_id() const {
5453       return table()->track_id()[row_number_];
5454     }
category()5455     ColumnType::category::type category() const {
5456       return table()->category()[row_number_];
5457     }
name()5458     ColumnType::name::type name() const {
5459       return table()->name()[row_number_];
5460     }
depth()5461     ColumnType::depth::type depth() const {
5462       return table()->depth()[row_number_];
5463     }
stack_id()5464     ColumnType::stack_id::type stack_id() const {
5465       return table()->stack_id()[row_number_];
5466     }
parent_stack_id()5467     ColumnType::parent_stack_id::type parent_stack_id() const {
5468       return table()->parent_stack_id()[row_number_];
5469     }
parent_id()5470     ColumnType::parent_id::type parent_id() const {
5471       return table()->parent_id()[row_number_];
5472     }
arg_set_id()5473     ColumnType::arg_set_id::type arg_set_id() const {
5474       return table()->arg_set_id()[row_number_];
5475     }
thread_ts()5476     ColumnType::thread_ts::type thread_ts() const {
5477       return table()->thread_ts()[row_number_];
5478     }
thread_dur()5479     ColumnType::thread_dur::type thread_dur() const {
5480       return table()->thread_dur()[row_number_];
5481     }
thread_instruction_count()5482     ColumnType::thread_instruction_count::type thread_instruction_count() const {
5483       return table()->thread_instruction_count()[row_number_];
5484     }
thread_instruction_delta()5485     ColumnType::thread_instruction_delta::type thread_instruction_delta() const {
5486       return table()->thread_instruction_delta()[row_number_];
5487     }
context_id()5488     ColumnType::context_id::type context_id() const {
5489       return table()->context_id()[row_number_];
5490     }
render_target()5491     ColumnType::render_target::type render_target() const {
5492       return table()->render_target()[row_number_];
5493     }
render_target_name()5494     ColumnType::render_target_name::type render_target_name() const {
5495       return table()->render_target_name()[row_number_];
5496     }
render_pass()5497     ColumnType::render_pass::type render_pass() const {
5498       return table()->render_pass()[row_number_];
5499     }
render_pass_name()5500     ColumnType::render_pass_name::type render_pass_name() const {
5501       return table()->render_pass_name()[row_number_];
5502     }
command_buffer()5503     ColumnType::command_buffer::type command_buffer() const {
5504       return table()->command_buffer()[row_number_];
5505     }
command_buffer_name()5506     ColumnType::command_buffer_name::type command_buffer_name() const {
5507       return table()->command_buffer_name()[row_number_];
5508     }
frame_id()5509     ColumnType::frame_id::type frame_id() const {
5510       return table()->frame_id()[row_number_];
5511     }
submission_id()5512     ColumnType::submission_id::type submission_id() const {
5513       return table()->submission_id()[row_number_];
5514     }
hw_queue_id()5515     ColumnType::hw_queue_id::type hw_queue_id() const {
5516       return table()->hw_queue_id()[row_number_];
5517     }
upid()5518     ColumnType::upid::type upid() const {
5519       return table()->upid()[row_number_];
5520     }
render_subpasses()5521     ColumnType::render_subpasses::type render_subpasses() const {
5522       return table()->render_subpasses()[row_number_];
5523     }
5524   };
5525   static_assert(std::is_trivially_destructible_v<ConstRowReference>,
5526                 "Inheritance used without trivial destruction");
5527   class RowReference : public ConstRowReference {
5528    public:
RowReference(const GpuSliceTable * table,uint32_t row_number)5529     RowReference(const GpuSliceTable* table, uint32_t row_number)
5530         : ConstRowReference(table, row_number) {}
5531 
set_ts(ColumnType::ts::non_optional_type v)5532     void set_ts(
5533         ColumnType::ts::non_optional_type v) {
5534       return mutable_table()->mutable_ts()->Set(row_number_, v);
5535     }
set_dur(ColumnType::dur::non_optional_type v)5536     void set_dur(
5537         ColumnType::dur::non_optional_type v) {
5538       return mutable_table()->mutable_dur()->Set(row_number_, v);
5539     }
set_track_id(ColumnType::track_id::non_optional_type v)5540     void set_track_id(
5541         ColumnType::track_id::non_optional_type v) {
5542       return mutable_table()->mutable_track_id()->Set(row_number_, v);
5543     }
set_category(ColumnType::category::non_optional_type v)5544     void set_category(
5545         ColumnType::category::non_optional_type v) {
5546       return mutable_table()->mutable_category()->Set(row_number_, v);
5547     }
set_name(ColumnType::name::non_optional_type v)5548     void set_name(
5549         ColumnType::name::non_optional_type v) {
5550       return mutable_table()->mutable_name()->Set(row_number_, v);
5551     }
set_depth(ColumnType::depth::non_optional_type v)5552     void set_depth(
5553         ColumnType::depth::non_optional_type v) {
5554       return mutable_table()->mutable_depth()->Set(row_number_, v);
5555     }
set_stack_id(ColumnType::stack_id::non_optional_type v)5556     void set_stack_id(
5557         ColumnType::stack_id::non_optional_type v) {
5558       return mutable_table()->mutable_stack_id()->Set(row_number_, v);
5559     }
set_parent_stack_id(ColumnType::parent_stack_id::non_optional_type v)5560     void set_parent_stack_id(
5561         ColumnType::parent_stack_id::non_optional_type v) {
5562       return mutable_table()->mutable_parent_stack_id()->Set(row_number_, v);
5563     }
set_parent_id(ColumnType::parent_id::non_optional_type v)5564     void set_parent_id(
5565         ColumnType::parent_id::non_optional_type v) {
5566       return mutable_table()->mutable_parent_id()->Set(row_number_, v);
5567     }
set_arg_set_id(ColumnType::arg_set_id::non_optional_type v)5568     void set_arg_set_id(
5569         ColumnType::arg_set_id::non_optional_type v) {
5570       return mutable_table()->mutable_arg_set_id()->Set(row_number_, v);
5571     }
set_thread_ts(ColumnType::thread_ts::non_optional_type v)5572     void set_thread_ts(
5573         ColumnType::thread_ts::non_optional_type v) {
5574       return mutable_table()->mutable_thread_ts()->Set(row_number_, v);
5575     }
set_thread_dur(ColumnType::thread_dur::non_optional_type v)5576     void set_thread_dur(
5577         ColumnType::thread_dur::non_optional_type v) {
5578       return mutable_table()->mutable_thread_dur()->Set(row_number_, v);
5579     }
set_thread_instruction_count(ColumnType::thread_instruction_count::non_optional_type v)5580     void set_thread_instruction_count(
5581         ColumnType::thread_instruction_count::non_optional_type v) {
5582       return mutable_table()->mutable_thread_instruction_count()->Set(row_number_, v);
5583     }
set_thread_instruction_delta(ColumnType::thread_instruction_delta::non_optional_type v)5584     void set_thread_instruction_delta(
5585         ColumnType::thread_instruction_delta::non_optional_type v) {
5586       return mutable_table()->mutable_thread_instruction_delta()->Set(row_number_, v);
5587     }
set_context_id(ColumnType::context_id::non_optional_type v)5588     void set_context_id(
5589         ColumnType::context_id::non_optional_type v) {
5590       return mutable_table()->mutable_context_id()->Set(row_number_, v);
5591     }
set_render_target(ColumnType::render_target::non_optional_type v)5592     void set_render_target(
5593         ColumnType::render_target::non_optional_type v) {
5594       return mutable_table()->mutable_render_target()->Set(row_number_, v);
5595     }
set_render_target_name(ColumnType::render_target_name::non_optional_type v)5596     void set_render_target_name(
5597         ColumnType::render_target_name::non_optional_type v) {
5598       return mutable_table()->mutable_render_target_name()->Set(row_number_, v);
5599     }
set_render_pass(ColumnType::render_pass::non_optional_type v)5600     void set_render_pass(
5601         ColumnType::render_pass::non_optional_type v) {
5602       return mutable_table()->mutable_render_pass()->Set(row_number_, v);
5603     }
set_render_pass_name(ColumnType::render_pass_name::non_optional_type v)5604     void set_render_pass_name(
5605         ColumnType::render_pass_name::non_optional_type v) {
5606       return mutable_table()->mutable_render_pass_name()->Set(row_number_, v);
5607     }
set_command_buffer(ColumnType::command_buffer::non_optional_type v)5608     void set_command_buffer(
5609         ColumnType::command_buffer::non_optional_type v) {
5610       return mutable_table()->mutable_command_buffer()->Set(row_number_, v);
5611     }
set_command_buffer_name(ColumnType::command_buffer_name::non_optional_type v)5612     void set_command_buffer_name(
5613         ColumnType::command_buffer_name::non_optional_type v) {
5614       return mutable_table()->mutable_command_buffer_name()->Set(row_number_, v);
5615     }
set_frame_id(ColumnType::frame_id::non_optional_type v)5616     void set_frame_id(
5617         ColumnType::frame_id::non_optional_type v) {
5618       return mutable_table()->mutable_frame_id()->Set(row_number_, v);
5619     }
set_submission_id(ColumnType::submission_id::non_optional_type v)5620     void set_submission_id(
5621         ColumnType::submission_id::non_optional_type v) {
5622       return mutable_table()->mutable_submission_id()->Set(row_number_, v);
5623     }
set_hw_queue_id(ColumnType::hw_queue_id::non_optional_type v)5624     void set_hw_queue_id(
5625         ColumnType::hw_queue_id::non_optional_type v) {
5626       return mutable_table()->mutable_hw_queue_id()->Set(row_number_, v);
5627     }
set_upid(ColumnType::upid::non_optional_type v)5628     void set_upid(
5629         ColumnType::upid::non_optional_type v) {
5630       return mutable_table()->mutable_upid()->Set(row_number_, v);
5631     }
set_render_subpasses(ColumnType::render_subpasses::non_optional_type v)5632     void set_render_subpasses(
5633         ColumnType::render_subpasses::non_optional_type v) {
5634       return mutable_table()->mutable_render_subpasses()->Set(row_number_, v);
5635     }
5636 
5637    private:
mutable_table()5638     GpuSliceTable* mutable_table() const {
5639       return const_cast<GpuSliceTable*>(table());
5640     }
5641   };
5642   static_assert(std::is_trivially_destructible_v<RowReference>,
5643                 "Inheritance used without trivial destruction");
5644 
5645   class ConstIterator;
5646   class ConstIterator : public macros_internal::AbstractConstIterator<
5647     ConstIterator, GpuSliceTable, RowNumber, ConstRowReference> {
5648    public:
id()5649     ColumnType::id::type id() const {
5650       const auto& col = table()->id();
5651       return col.GetAtIdx(
5652         iterator_.StorageIndexForColumn(col.index_in_table()));
5653     }
type()5654     ColumnType::type::type type() const {
5655       const auto& col = table()->type();
5656       return col.GetAtIdx(
5657         iterator_.StorageIndexForColumn(col.index_in_table()));
5658     }
ts()5659     ColumnType::ts::type ts() const {
5660       const auto& col = table()->ts();
5661       return col.GetAtIdx(
5662         iterator_.StorageIndexForColumn(col.index_in_table()));
5663     }
dur()5664     ColumnType::dur::type dur() const {
5665       const auto& col = table()->dur();
5666       return col.GetAtIdx(
5667         iterator_.StorageIndexForColumn(col.index_in_table()));
5668     }
track_id()5669     ColumnType::track_id::type track_id() const {
5670       const auto& col = table()->track_id();
5671       return col.GetAtIdx(
5672         iterator_.StorageIndexForColumn(col.index_in_table()));
5673     }
category()5674     ColumnType::category::type category() const {
5675       const auto& col = table()->category();
5676       return col.GetAtIdx(
5677         iterator_.StorageIndexForColumn(col.index_in_table()));
5678     }
name()5679     ColumnType::name::type name() const {
5680       const auto& col = table()->name();
5681       return col.GetAtIdx(
5682         iterator_.StorageIndexForColumn(col.index_in_table()));
5683     }
depth()5684     ColumnType::depth::type depth() const {
5685       const auto& col = table()->depth();
5686       return col.GetAtIdx(
5687         iterator_.StorageIndexForColumn(col.index_in_table()));
5688     }
stack_id()5689     ColumnType::stack_id::type stack_id() const {
5690       const auto& col = table()->stack_id();
5691       return col.GetAtIdx(
5692         iterator_.StorageIndexForColumn(col.index_in_table()));
5693     }
parent_stack_id()5694     ColumnType::parent_stack_id::type parent_stack_id() const {
5695       const auto& col = table()->parent_stack_id();
5696       return col.GetAtIdx(
5697         iterator_.StorageIndexForColumn(col.index_in_table()));
5698     }
parent_id()5699     ColumnType::parent_id::type parent_id() const {
5700       const auto& col = table()->parent_id();
5701       return col.GetAtIdx(
5702         iterator_.StorageIndexForColumn(col.index_in_table()));
5703     }
arg_set_id()5704     ColumnType::arg_set_id::type arg_set_id() const {
5705       const auto& col = table()->arg_set_id();
5706       return col.GetAtIdx(
5707         iterator_.StorageIndexForColumn(col.index_in_table()));
5708     }
thread_ts()5709     ColumnType::thread_ts::type thread_ts() const {
5710       const auto& col = table()->thread_ts();
5711       return col.GetAtIdx(
5712         iterator_.StorageIndexForColumn(col.index_in_table()));
5713     }
thread_dur()5714     ColumnType::thread_dur::type thread_dur() const {
5715       const auto& col = table()->thread_dur();
5716       return col.GetAtIdx(
5717         iterator_.StorageIndexForColumn(col.index_in_table()));
5718     }
thread_instruction_count()5719     ColumnType::thread_instruction_count::type thread_instruction_count() const {
5720       const auto& col = table()->thread_instruction_count();
5721       return col.GetAtIdx(
5722         iterator_.StorageIndexForColumn(col.index_in_table()));
5723     }
thread_instruction_delta()5724     ColumnType::thread_instruction_delta::type thread_instruction_delta() const {
5725       const auto& col = table()->thread_instruction_delta();
5726       return col.GetAtIdx(
5727         iterator_.StorageIndexForColumn(col.index_in_table()));
5728     }
context_id()5729     ColumnType::context_id::type context_id() const {
5730       const auto& col = table()->context_id();
5731       return col.GetAtIdx(
5732         iterator_.StorageIndexForColumn(col.index_in_table()));
5733     }
render_target()5734     ColumnType::render_target::type render_target() const {
5735       const auto& col = table()->render_target();
5736       return col.GetAtIdx(
5737         iterator_.StorageIndexForColumn(col.index_in_table()));
5738     }
render_target_name()5739     ColumnType::render_target_name::type render_target_name() const {
5740       const auto& col = table()->render_target_name();
5741       return col.GetAtIdx(
5742         iterator_.StorageIndexForColumn(col.index_in_table()));
5743     }
render_pass()5744     ColumnType::render_pass::type render_pass() const {
5745       const auto& col = table()->render_pass();
5746       return col.GetAtIdx(
5747         iterator_.StorageIndexForColumn(col.index_in_table()));
5748     }
render_pass_name()5749     ColumnType::render_pass_name::type render_pass_name() const {
5750       const auto& col = table()->render_pass_name();
5751       return col.GetAtIdx(
5752         iterator_.StorageIndexForColumn(col.index_in_table()));
5753     }
command_buffer()5754     ColumnType::command_buffer::type command_buffer() const {
5755       const auto& col = table()->command_buffer();
5756       return col.GetAtIdx(
5757         iterator_.StorageIndexForColumn(col.index_in_table()));
5758     }
command_buffer_name()5759     ColumnType::command_buffer_name::type command_buffer_name() const {
5760       const auto& col = table()->command_buffer_name();
5761       return col.GetAtIdx(
5762         iterator_.StorageIndexForColumn(col.index_in_table()));
5763     }
frame_id()5764     ColumnType::frame_id::type frame_id() const {
5765       const auto& col = table()->frame_id();
5766       return col.GetAtIdx(
5767         iterator_.StorageIndexForColumn(col.index_in_table()));
5768     }
submission_id()5769     ColumnType::submission_id::type submission_id() const {
5770       const auto& col = table()->submission_id();
5771       return col.GetAtIdx(
5772         iterator_.StorageIndexForColumn(col.index_in_table()));
5773     }
hw_queue_id()5774     ColumnType::hw_queue_id::type hw_queue_id() const {
5775       const auto& col = table()->hw_queue_id();
5776       return col.GetAtIdx(
5777         iterator_.StorageIndexForColumn(col.index_in_table()));
5778     }
upid()5779     ColumnType::upid::type upid() const {
5780       const auto& col = table()->upid();
5781       return col.GetAtIdx(
5782         iterator_.StorageIndexForColumn(col.index_in_table()));
5783     }
render_subpasses()5784     ColumnType::render_subpasses::type render_subpasses() const {
5785       const auto& col = table()->render_subpasses();
5786       return col.GetAtIdx(
5787         iterator_.StorageIndexForColumn(col.index_in_table()));
5788     }
5789 
5790    protected:
ConstIterator(const GpuSliceTable * table,Table::Iterator iterator)5791     explicit ConstIterator(const GpuSliceTable* table,
5792                            Table::Iterator iterator)
5793         : AbstractConstIterator(table, std::move(iterator)) {}
5794 
CurrentRowNumber()5795     uint32_t CurrentRowNumber() const {
5796       return iterator_.StorageIndexForLastOverlay();
5797     }
5798 
5799    private:
5800     friend class GpuSliceTable;
5801     friend class macros_internal::AbstractConstIterator<
5802       ConstIterator, GpuSliceTable, RowNumber, ConstRowReference>;
5803   };
5804   class Iterator : public ConstIterator {
5805     public:
row_reference()5806      RowReference row_reference() const {
5807        return {const_cast<GpuSliceTable*>(table()), CurrentRowNumber()};
5808      }
5809 
5810     private:
5811      friend class GpuSliceTable;
5812 
Iterator(GpuSliceTable * table,Table::Iterator iterator)5813      explicit Iterator(GpuSliceTable* table, Table::Iterator iterator)
5814         : ConstIterator(table, std::move(iterator)) {}
5815   };
5816 
5817   struct IdAndRow {
5818     Id id;
5819     uint32_t row;
5820     RowReference row_reference;
5821     RowNumber row_number;
5822   };
5823 
GetColumns(GpuSliceTable * self,const macros_internal::MacroTable * parent)5824   static std::vector<ColumnLegacy> GetColumns(
5825       GpuSliceTable* self,
5826       const macros_internal::MacroTable* parent) {
5827     std::vector<ColumnLegacy> columns =
5828         CopyColumnsFromParentOrAddRootColumns(self, parent);
5829     uint32_t olay_idx = OverlayCount(parent);
5830     AddColumnToVector(columns, "context_id", &self->context_id_, ColumnFlag::context_id,
5831                       static_cast<uint32_t>(columns.size()), olay_idx);
5832     AddColumnToVector(columns, "render_target", &self->render_target_, ColumnFlag::render_target,
5833                       static_cast<uint32_t>(columns.size()), olay_idx);
5834     AddColumnToVector(columns, "render_target_name", &self->render_target_name_, ColumnFlag::render_target_name,
5835                       static_cast<uint32_t>(columns.size()), olay_idx);
5836     AddColumnToVector(columns, "render_pass", &self->render_pass_, ColumnFlag::render_pass,
5837                       static_cast<uint32_t>(columns.size()), olay_idx);
5838     AddColumnToVector(columns, "render_pass_name", &self->render_pass_name_, ColumnFlag::render_pass_name,
5839                       static_cast<uint32_t>(columns.size()), olay_idx);
5840     AddColumnToVector(columns, "command_buffer", &self->command_buffer_, ColumnFlag::command_buffer,
5841                       static_cast<uint32_t>(columns.size()), olay_idx);
5842     AddColumnToVector(columns, "command_buffer_name", &self->command_buffer_name_, ColumnFlag::command_buffer_name,
5843                       static_cast<uint32_t>(columns.size()), olay_idx);
5844     AddColumnToVector(columns, "frame_id", &self->frame_id_, ColumnFlag::frame_id,
5845                       static_cast<uint32_t>(columns.size()), olay_idx);
5846     AddColumnToVector(columns, "submission_id", &self->submission_id_, ColumnFlag::submission_id,
5847                       static_cast<uint32_t>(columns.size()), olay_idx);
5848     AddColumnToVector(columns, "hw_queue_id", &self->hw_queue_id_, ColumnFlag::hw_queue_id,
5849                       static_cast<uint32_t>(columns.size()), olay_idx);
5850     AddColumnToVector(columns, "upid", &self->upid_, ColumnFlag::upid,
5851                       static_cast<uint32_t>(columns.size()), olay_idx);
5852     AddColumnToVector(columns, "render_subpasses", &self->render_subpasses_, ColumnFlag::render_subpasses,
5853                       static_cast<uint32_t>(columns.size()), olay_idx);
5854     return columns;
5855   }
5856 
GpuSliceTable(StringPool * pool,SliceTable * parent)5857   PERFETTO_NO_INLINE explicit GpuSliceTable(StringPool* pool, SliceTable* parent)
5858       : macros_internal::MacroTable(
5859           pool,
5860           GetColumns(this, parent),
5861           parent),
5862         parent_(parent), const_parent_(parent), context_id_(ColumnStorage<ColumnType::context_id::stored_type>::Create<false>()),
5863         render_target_(ColumnStorage<ColumnType::render_target::stored_type>::Create<false>()),
5864         render_target_name_(ColumnStorage<ColumnType::render_target_name::stored_type>::Create<false>()),
5865         render_pass_(ColumnStorage<ColumnType::render_pass::stored_type>::Create<false>()),
5866         render_pass_name_(ColumnStorage<ColumnType::render_pass_name::stored_type>::Create<false>()),
5867         command_buffer_(ColumnStorage<ColumnType::command_buffer::stored_type>::Create<false>()),
5868         command_buffer_name_(ColumnStorage<ColumnType::command_buffer_name::stored_type>::Create<false>()),
5869         frame_id_(ColumnStorage<ColumnType::frame_id::stored_type>::Create<false>()),
5870         submission_id_(ColumnStorage<ColumnType::submission_id::stored_type>::Create<false>()),
5871         hw_queue_id_(ColumnStorage<ColumnType::hw_queue_id::stored_type>::Create<false>()),
5872         upid_(ColumnStorage<ColumnType::upid::stored_type>::Create<false>()),
5873         render_subpasses_(ColumnStorage<ColumnType::render_subpasses::stored_type>::Create<false>())
5874 ,
5875         context_id_storage_layer_(
5876           new column::NumericStorage<ColumnType::context_id::non_optional_stored_type>(
5877             &context_id_.non_null_vector(),
5878             ColumnTypeHelper<ColumnType::context_id::stored_type>::ToColumnType(),
5879             false)),
5880         render_target_storage_layer_(
5881           new column::NumericStorage<ColumnType::render_target::non_optional_stored_type>(
5882             &render_target_.non_null_vector(),
5883             ColumnTypeHelper<ColumnType::render_target::stored_type>::ToColumnType(),
5884             false)),
5885         render_target_name_storage_layer_(
5886           new column::StringStorage(string_pool(), &render_target_name_.vector())),
5887         render_pass_storage_layer_(
5888           new column::NumericStorage<ColumnType::render_pass::non_optional_stored_type>(
5889             &render_pass_.non_null_vector(),
5890             ColumnTypeHelper<ColumnType::render_pass::stored_type>::ToColumnType(),
5891             false)),
5892         render_pass_name_storage_layer_(
5893           new column::StringStorage(string_pool(), &render_pass_name_.vector())),
5894         command_buffer_storage_layer_(
5895           new column::NumericStorage<ColumnType::command_buffer::non_optional_stored_type>(
5896             &command_buffer_.non_null_vector(),
5897             ColumnTypeHelper<ColumnType::command_buffer::stored_type>::ToColumnType(),
5898             false)),
5899         command_buffer_name_storage_layer_(
5900           new column::StringStorage(string_pool(), &command_buffer_name_.vector())),
5901         frame_id_storage_layer_(
5902           new column::NumericStorage<ColumnType::frame_id::non_optional_stored_type>(
5903             &frame_id_.non_null_vector(),
5904             ColumnTypeHelper<ColumnType::frame_id::stored_type>::ToColumnType(),
5905             false)),
5906         submission_id_storage_layer_(
5907           new column::NumericStorage<ColumnType::submission_id::non_optional_stored_type>(
5908             &submission_id_.non_null_vector(),
5909             ColumnTypeHelper<ColumnType::submission_id::stored_type>::ToColumnType(),
5910             false)),
5911         hw_queue_id_storage_layer_(
5912           new column::NumericStorage<ColumnType::hw_queue_id::non_optional_stored_type>(
5913             &hw_queue_id_.non_null_vector(),
5914             ColumnTypeHelper<ColumnType::hw_queue_id::stored_type>::ToColumnType(),
5915             false)),
5916         upid_storage_layer_(
5917           new column::NumericStorage<ColumnType::upid::non_optional_stored_type>(
5918             &upid_.non_null_vector(),
5919             ColumnTypeHelper<ColumnType::upid::stored_type>::ToColumnType(),
5920             false)),
5921         render_subpasses_storage_layer_(
5922           new column::StringStorage(string_pool(), &render_subpasses_.vector()))
5923 ,
5924         context_id_null_layer_(new column::NullOverlay(context_id_.bv())),
5925         render_target_null_layer_(new column::NullOverlay(render_target_.bv())),
5926         render_pass_null_layer_(new column::NullOverlay(render_pass_.bv())),
5927         command_buffer_null_layer_(new column::NullOverlay(command_buffer_.bv())),
5928         frame_id_null_layer_(new column::NullOverlay(frame_id_.bv())),
5929         submission_id_null_layer_(new column::NullOverlay(submission_id_.bv())),
5930         hw_queue_id_null_layer_(new column::NullOverlay(hw_queue_id_.bv())),
5931         upid_null_layer_(new column::NullOverlay(upid_.bv())) {
5932     static_assert(
5933         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::context_id::stored_type>(
5934           ColumnFlag::context_id),
5935         "Column type and flag combination is not valid");
5936       static_assert(
5937         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::render_target::stored_type>(
5938           ColumnFlag::render_target),
5939         "Column type and flag combination is not valid");
5940       static_assert(
5941         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::render_target_name::stored_type>(
5942           ColumnFlag::render_target_name),
5943         "Column type and flag combination is not valid");
5944       static_assert(
5945         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::render_pass::stored_type>(
5946           ColumnFlag::render_pass),
5947         "Column type and flag combination is not valid");
5948       static_assert(
5949         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::render_pass_name::stored_type>(
5950           ColumnFlag::render_pass_name),
5951         "Column type and flag combination is not valid");
5952       static_assert(
5953         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::command_buffer::stored_type>(
5954           ColumnFlag::command_buffer),
5955         "Column type and flag combination is not valid");
5956       static_assert(
5957         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::command_buffer_name::stored_type>(
5958           ColumnFlag::command_buffer_name),
5959         "Column type and flag combination is not valid");
5960       static_assert(
5961         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::frame_id::stored_type>(
5962           ColumnFlag::frame_id),
5963         "Column type and flag combination is not valid");
5964       static_assert(
5965         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::submission_id::stored_type>(
5966           ColumnFlag::submission_id),
5967         "Column type and flag combination is not valid");
5968       static_assert(
5969         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::hw_queue_id::stored_type>(
5970           ColumnFlag::hw_queue_id),
5971         "Column type and flag combination is not valid");
5972       static_assert(
5973         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::upid::stored_type>(
5974           ColumnFlag::upid),
5975         "Column type and flag combination is not valid");
5976       static_assert(
5977         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::render_subpasses::stored_type>(
5978           ColumnFlag::render_subpasses),
5979         "Column type and flag combination is not valid");
5980     OnConstructionCompletedRegularConstructor(
5981       {const_parent_->storage_layers()[ColumnIndex::id],const_parent_->storage_layers()[ColumnIndex::type],const_parent_->storage_layers()[ColumnIndex::ts],const_parent_->storage_layers()[ColumnIndex::dur],const_parent_->storage_layers()[ColumnIndex::track_id],const_parent_->storage_layers()[ColumnIndex::category],const_parent_->storage_layers()[ColumnIndex::name],const_parent_->storage_layers()[ColumnIndex::depth],const_parent_->storage_layers()[ColumnIndex::stack_id],const_parent_->storage_layers()[ColumnIndex::parent_stack_id],const_parent_->storage_layers()[ColumnIndex::parent_id],const_parent_->storage_layers()[ColumnIndex::arg_set_id],const_parent_->storage_layers()[ColumnIndex::thread_ts],const_parent_->storage_layers()[ColumnIndex::thread_dur],const_parent_->storage_layers()[ColumnIndex::thread_instruction_count],const_parent_->storage_layers()[ColumnIndex::thread_instruction_delta],context_id_storage_layer_,render_target_storage_layer_,render_target_name_storage_layer_,render_pass_storage_layer_,render_pass_name_storage_layer_,command_buffer_storage_layer_,command_buffer_name_storage_layer_,frame_id_storage_layer_,submission_id_storage_layer_,hw_queue_id_storage_layer_,upid_storage_layer_,render_subpasses_storage_layer_},
5982       {{},{},{},{},{},{},{},{},{},{},const_parent_->null_layers()[ColumnIndex::parent_id],{},const_parent_->null_layers()[ColumnIndex::thread_ts],const_parent_->null_layers()[ColumnIndex::thread_dur],const_parent_->null_layers()[ColumnIndex::thread_instruction_count],const_parent_->null_layers()[ColumnIndex::thread_instruction_delta],context_id_null_layer_,render_target_null_layer_,{},render_pass_null_layer_,{},command_buffer_null_layer_,{},frame_id_null_layer_,submission_id_null_layer_,hw_queue_id_null_layer_,upid_null_layer_,{}});
5983   }
5984   ~GpuSliceTable() override;
5985 
Name()5986   static const char* Name() { return "gpu_slice"; }
5987 
ComputeStaticSchema()5988   static Table::Schema ComputeStaticSchema() {
5989     Table::Schema schema;
5990     schema.columns.emplace_back(Table::Schema::Column{
5991         "id", SqlValue::Type::kLong, true, true, false, false});
5992     schema.columns.emplace_back(Table::Schema::Column{
5993         "type", SqlValue::Type::kString, false, false, false, false});
5994     schema.columns.emplace_back(Table::Schema::Column{
5995         "ts", ColumnType::ts::SqlValueType(), false,
5996         true,
5997         false,
5998         false});
5999     schema.columns.emplace_back(Table::Schema::Column{
6000         "dur", ColumnType::dur::SqlValueType(), false,
6001         false,
6002         false,
6003         false});
6004     schema.columns.emplace_back(Table::Schema::Column{
6005         "track_id", ColumnType::track_id::SqlValueType(), false,
6006         false,
6007         false,
6008         false});
6009     schema.columns.emplace_back(Table::Schema::Column{
6010         "category", ColumnType::category::SqlValueType(), false,
6011         false,
6012         false,
6013         false});
6014     schema.columns.emplace_back(Table::Schema::Column{
6015         "name", ColumnType::name::SqlValueType(), false,
6016         false,
6017         false,
6018         false});
6019     schema.columns.emplace_back(Table::Schema::Column{
6020         "depth", ColumnType::depth::SqlValueType(), false,
6021         false,
6022         false,
6023         false});
6024     schema.columns.emplace_back(Table::Schema::Column{
6025         "stack_id", ColumnType::stack_id::SqlValueType(), false,
6026         false,
6027         false,
6028         false});
6029     schema.columns.emplace_back(Table::Schema::Column{
6030         "parent_stack_id", ColumnType::parent_stack_id::SqlValueType(), false,
6031         false,
6032         false,
6033         false});
6034     schema.columns.emplace_back(Table::Schema::Column{
6035         "parent_id", ColumnType::parent_id::SqlValueType(), false,
6036         false,
6037         false,
6038         false});
6039     schema.columns.emplace_back(Table::Schema::Column{
6040         "arg_set_id", ColumnType::arg_set_id::SqlValueType(), false,
6041         false,
6042         false,
6043         false});
6044     schema.columns.emplace_back(Table::Schema::Column{
6045         "thread_ts", ColumnType::thread_ts::SqlValueType(), false,
6046         false,
6047         false,
6048         false});
6049     schema.columns.emplace_back(Table::Schema::Column{
6050         "thread_dur", ColumnType::thread_dur::SqlValueType(), false,
6051         false,
6052         false,
6053         false});
6054     schema.columns.emplace_back(Table::Schema::Column{
6055         "thread_instruction_count", ColumnType::thread_instruction_count::SqlValueType(), false,
6056         false,
6057         false,
6058         false});
6059     schema.columns.emplace_back(Table::Schema::Column{
6060         "thread_instruction_delta", ColumnType::thread_instruction_delta::SqlValueType(), false,
6061         false,
6062         false,
6063         false});
6064     schema.columns.emplace_back(Table::Schema::Column{
6065         "context_id", ColumnType::context_id::SqlValueType(), false,
6066         false,
6067         false,
6068         false});
6069     schema.columns.emplace_back(Table::Schema::Column{
6070         "render_target", ColumnType::render_target::SqlValueType(), false,
6071         false,
6072         false,
6073         false});
6074     schema.columns.emplace_back(Table::Schema::Column{
6075         "render_target_name", ColumnType::render_target_name::SqlValueType(), false,
6076         false,
6077         false,
6078         false});
6079     schema.columns.emplace_back(Table::Schema::Column{
6080         "render_pass", ColumnType::render_pass::SqlValueType(), false,
6081         false,
6082         false,
6083         false});
6084     schema.columns.emplace_back(Table::Schema::Column{
6085         "render_pass_name", ColumnType::render_pass_name::SqlValueType(), false,
6086         false,
6087         false,
6088         false});
6089     schema.columns.emplace_back(Table::Schema::Column{
6090         "command_buffer", ColumnType::command_buffer::SqlValueType(), false,
6091         false,
6092         false,
6093         false});
6094     schema.columns.emplace_back(Table::Schema::Column{
6095         "command_buffer_name", ColumnType::command_buffer_name::SqlValueType(), false,
6096         false,
6097         false,
6098         false});
6099     schema.columns.emplace_back(Table::Schema::Column{
6100         "frame_id", ColumnType::frame_id::SqlValueType(), false,
6101         false,
6102         false,
6103         false});
6104     schema.columns.emplace_back(Table::Schema::Column{
6105         "submission_id", ColumnType::submission_id::SqlValueType(), false,
6106         false,
6107         false,
6108         false});
6109     schema.columns.emplace_back(Table::Schema::Column{
6110         "hw_queue_id", ColumnType::hw_queue_id::SqlValueType(), false,
6111         false,
6112         false,
6113         false});
6114     schema.columns.emplace_back(Table::Schema::Column{
6115         "upid", ColumnType::upid::SqlValueType(), false,
6116         false,
6117         false,
6118         false});
6119     schema.columns.emplace_back(Table::Schema::Column{
6120         "render_subpasses", ColumnType::render_subpasses::SqlValueType(), false,
6121         false,
6122         false,
6123         false});
6124     return schema;
6125   }
6126 
IterateRows()6127   ConstIterator IterateRows() const {
6128     return ConstIterator(this, Table::IterateRows());
6129   }
6130 
IterateRows()6131   Iterator IterateRows() { return Iterator(this, Table::IterateRows()); }
6132 
FilterToIterator(const Query & q)6133   ConstIterator FilterToIterator(const Query& q) const {
6134     return ConstIterator(this, QueryToIterator(q));
6135   }
6136 
FilterToIterator(const Query & q)6137   Iterator FilterToIterator(const Query& q) {
6138     return Iterator(this, QueryToIterator(q));
6139   }
6140 
ShrinkToFit()6141   void ShrinkToFit() {
6142     context_id_.ShrinkToFit();
6143     render_target_.ShrinkToFit();
6144     render_target_name_.ShrinkToFit();
6145     render_pass_.ShrinkToFit();
6146     render_pass_name_.ShrinkToFit();
6147     command_buffer_.ShrinkToFit();
6148     command_buffer_name_.ShrinkToFit();
6149     frame_id_.ShrinkToFit();
6150     submission_id_.ShrinkToFit();
6151     hw_queue_id_.ShrinkToFit();
6152     upid_.ShrinkToFit();
6153     render_subpasses_.ShrinkToFit();
6154   }
6155 
6156   ConstRowReference operator[](uint32_t r) const {
6157     return ConstRowReference(this, r);
6158   }
6159   RowReference operator[](uint32_t r) { return RowReference(this, r); }
6160   ConstRowReference operator[](RowNumber r) const {
6161     return ConstRowReference(this, r.row_number());
6162   }
6163   RowReference operator[](RowNumber r) {
6164     return RowReference(this, r.row_number());
6165   }
6166 
FindById(Id find_id)6167   std::optional<ConstRowReference> FindById(Id find_id) const {
6168     std::optional<uint32_t> row = id().IndexOf(find_id);
6169     return row ? std::make_optional(ConstRowReference(this, *row))
6170                : std::nullopt;
6171   }
6172 
FindById(Id find_id)6173   std::optional<RowReference> FindById(Id find_id) {
6174     std::optional<uint32_t> row = id().IndexOf(find_id);
6175     return row ? std::make_optional(RowReference(this, *row)) : std::nullopt;
6176   }
6177 
Insert(const Row & row)6178   IdAndRow Insert(const Row& row) {
6179     uint32_t row_number = row_count();
6180     Id id = Id{parent_->Insert(row).id};
6181     UpdateOverlaysAfterParentInsert();
6182     mutable_context_id()->Append(row.context_id);
6183     mutable_render_target()->Append(row.render_target);
6184     mutable_render_target_name()->Append(row.render_target_name);
6185     mutable_render_pass()->Append(row.render_pass);
6186     mutable_render_pass_name()->Append(row.render_pass_name);
6187     mutable_command_buffer()->Append(row.command_buffer);
6188     mutable_command_buffer_name()->Append(row.command_buffer_name);
6189     mutable_frame_id()->Append(row.frame_id);
6190     mutable_submission_id()->Append(row.submission_id);
6191     mutable_hw_queue_id()->Append(row.hw_queue_id);
6192     mutable_upid()->Append(row.upid);
6193     mutable_render_subpasses()->Append(row.render_subpasses);
6194     UpdateSelfOverlayAfterInsert();
6195     return IdAndRow{id, row_number, RowReference(this, row_number),
6196                      RowNumber(row_number)};
6197   }
6198 
ExtendParent(const SliceTable & parent,ColumnStorage<ColumnType::context_id::stored_type> context_id,ColumnStorage<ColumnType::render_target::stored_type> render_target,ColumnStorage<ColumnType::render_target_name::stored_type> render_target_name,ColumnStorage<ColumnType::render_pass::stored_type> render_pass,ColumnStorage<ColumnType::render_pass_name::stored_type> render_pass_name,ColumnStorage<ColumnType::command_buffer::stored_type> command_buffer,ColumnStorage<ColumnType::command_buffer_name::stored_type> command_buffer_name,ColumnStorage<ColumnType::frame_id::stored_type> frame_id,ColumnStorage<ColumnType::submission_id::stored_type> submission_id,ColumnStorage<ColumnType::hw_queue_id::stored_type> hw_queue_id,ColumnStorage<ColumnType::upid::stored_type> upid,ColumnStorage<ColumnType::render_subpasses::stored_type> render_subpasses)6199   static std::unique_ptr<GpuSliceTable> ExtendParent(
6200       const SliceTable& parent,
6201       ColumnStorage<ColumnType::context_id::stored_type> context_id
6202 , ColumnStorage<ColumnType::render_target::stored_type> render_target
6203 , ColumnStorage<ColumnType::render_target_name::stored_type> render_target_name
6204 , ColumnStorage<ColumnType::render_pass::stored_type> render_pass
6205 , ColumnStorage<ColumnType::render_pass_name::stored_type> render_pass_name
6206 , ColumnStorage<ColumnType::command_buffer::stored_type> command_buffer
6207 , ColumnStorage<ColumnType::command_buffer_name::stored_type> command_buffer_name
6208 , ColumnStorage<ColumnType::frame_id::stored_type> frame_id
6209 , ColumnStorage<ColumnType::submission_id::stored_type> submission_id
6210 , ColumnStorage<ColumnType::hw_queue_id::stored_type> hw_queue_id
6211 , ColumnStorage<ColumnType::upid::stored_type> upid
6212 , ColumnStorage<ColumnType::render_subpasses::stored_type> render_subpasses) {
6213     return std::unique_ptr<GpuSliceTable>(new GpuSliceTable(
6214         parent.string_pool(), parent, RowMap(0, parent.row_count()),
6215         std::move(context_id), std::move(render_target), std::move(render_target_name), std::move(render_pass), std::move(render_pass_name), std::move(command_buffer), std::move(command_buffer_name), std::move(frame_id), std::move(submission_id), std::move(hw_queue_id), std::move(upid), std::move(render_subpasses)));
6216   }
6217 
SelectAndExtendParent(const SliceTable & parent,std::vector<SliceTable::RowNumber> parent_overlay,ColumnStorage<ColumnType::context_id::stored_type> context_id,ColumnStorage<ColumnType::render_target::stored_type> render_target,ColumnStorage<ColumnType::render_target_name::stored_type> render_target_name,ColumnStorage<ColumnType::render_pass::stored_type> render_pass,ColumnStorage<ColumnType::render_pass_name::stored_type> render_pass_name,ColumnStorage<ColumnType::command_buffer::stored_type> command_buffer,ColumnStorage<ColumnType::command_buffer_name::stored_type> command_buffer_name,ColumnStorage<ColumnType::frame_id::stored_type> frame_id,ColumnStorage<ColumnType::submission_id::stored_type> submission_id,ColumnStorage<ColumnType::hw_queue_id::stored_type> hw_queue_id,ColumnStorage<ColumnType::upid::stored_type> upid,ColumnStorage<ColumnType::render_subpasses::stored_type> render_subpasses)6218   static std::unique_ptr<GpuSliceTable> SelectAndExtendParent(
6219       const SliceTable& parent,
6220       std::vector<SliceTable::RowNumber> parent_overlay,
6221       ColumnStorage<ColumnType::context_id::stored_type> context_id
6222 , ColumnStorage<ColumnType::render_target::stored_type> render_target
6223 , ColumnStorage<ColumnType::render_target_name::stored_type> render_target_name
6224 , ColumnStorage<ColumnType::render_pass::stored_type> render_pass
6225 , ColumnStorage<ColumnType::render_pass_name::stored_type> render_pass_name
6226 , ColumnStorage<ColumnType::command_buffer::stored_type> command_buffer
6227 , ColumnStorage<ColumnType::command_buffer_name::stored_type> command_buffer_name
6228 , ColumnStorage<ColumnType::frame_id::stored_type> frame_id
6229 , ColumnStorage<ColumnType::submission_id::stored_type> submission_id
6230 , ColumnStorage<ColumnType::hw_queue_id::stored_type> hw_queue_id
6231 , ColumnStorage<ColumnType::upid::stored_type> upid
6232 , ColumnStorage<ColumnType::render_subpasses::stored_type> render_subpasses) {
6233     std::vector<uint32_t> prs_untyped(parent_overlay.size());
6234     for (uint32_t i = 0; i < parent_overlay.size(); ++i) {
6235       prs_untyped[i] = parent_overlay[i].row_number();
6236     }
6237     return std::unique_ptr<GpuSliceTable>(new GpuSliceTable(
6238         parent.string_pool(), parent, RowMap(std::move(prs_untyped)),
6239         std::move(context_id), std::move(render_target), std::move(render_target_name), std::move(render_pass), std::move(render_pass_name), std::move(command_buffer), std::move(command_buffer_name), std::move(frame_id), std::move(submission_id), std::move(hw_queue_id), std::move(upid), std::move(render_subpasses)));
6240   }
6241 
id()6242   const IdColumn<GpuSliceTable::Id>& id() const {
6243     return static_cast<const ColumnType::id&>(columns()[ColumnIndex::id]);
6244   }
type()6245   const TypedColumn<StringPool::Id>& type() const {
6246     return static_cast<const ColumnType::type&>(columns()[ColumnIndex::type]);
6247   }
ts()6248   const TypedColumn<int64_t>& ts() const {
6249     return static_cast<const ColumnType::ts&>(columns()[ColumnIndex::ts]);
6250   }
dur()6251   const TypedColumn<int64_t>& dur() const {
6252     return static_cast<const ColumnType::dur&>(columns()[ColumnIndex::dur]);
6253   }
track_id()6254   const TypedColumn<TrackTable::Id>& track_id() const {
6255     return static_cast<const ColumnType::track_id&>(columns()[ColumnIndex::track_id]);
6256   }
category()6257   const TypedColumn<std::optional<StringPool::Id>>& category() const {
6258     return static_cast<const ColumnType::category&>(columns()[ColumnIndex::category]);
6259   }
name()6260   const TypedColumn<std::optional<StringPool::Id>>& name() const {
6261     return static_cast<const ColumnType::name&>(columns()[ColumnIndex::name]);
6262   }
depth()6263   const TypedColumn<uint32_t>& depth() const {
6264     return static_cast<const ColumnType::depth&>(columns()[ColumnIndex::depth]);
6265   }
stack_id()6266   const TypedColumn<int64_t>& stack_id() const {
6267     return static_cast<const ColumnType::stack_id&>(columns()[ColumnIndex::stack_id]);
6268   }
parent_stack_id()6269   const TypedColumn<int64_t>& parent_stack_id() const {
6270     return static_cast<const ColumnType::parent_stack_id&>(columns()[ColumnIndex::parent_stack_id]);
6271   }
parent_id()6272   const TypedColumn<std::optional<GpuSliceTable::Id>>& parent_id() const {
6273     return static_cast<const ColumnType::parent_id&>(columns()[ColumnIndex::parent_id]);
6274   }
arg_set_id()6275   const TypedColumn<uint32_t>& arg_set_id() const {
6276     return static_cast<const ColumnType::arg_set_id&>(columns()[ColumnIndex::arg_set_id]);
6277   }
thread_ts()6278   const TypedColumn<std::optional<int64_t>>& thread_ts() const {
6279     return static_cast<const ColumnType::thread_ts&>(columns()[ColumnIndex::thread_ts]);
6280   }
thread_dur()6281   const TypedColumn<std::optional<int64_t>>& thread_dur() const {
6282     return static_cast<const ColumnType::thread_dur&>(columns()[ColumnIndex::thread_dur]);
6283   }
thread_instruction_count()6284   const TypedColumn<std::optional<int64_t>>& thread_instruction_count() const {
6285     return static_cast<const ColumnType::thread_instruction_count&>(columns()[ColumnIndex::thread_instruction_count]);
6286   }
thread_instruction_delta()6287   const TypedColumn<std::optional<int64_t>>& thread_instruction_delta() const {
6288     return static_cast<const ColumnType::thread_instruction_delta&>(columns()[ColumnIndex::thread_instruction_delta]);
6289   }
context_id()6290   const TypedColumn<std::optional<int64_t>>& context_id() const {
6291     return static_cast<const ColumnType::context_id&>(columns()[ColumnIndex::context_id]);
6292   }
render_target()6293   const TypedColumn<std::optional<int64_t>>& render_target() const {
6294     return static_cast<const ColumnType::render_target&>(columns()[ColumnIndex::render_target]);
6295   }
render_target_name()6296   const TypedColumn<StringPool::Id>& render_target_name() const {
6297     return static_cast<const ColumnType::render_target_name&>(columns()[ColumnIndex::render_target_name]);
6298   }
render_pass()6299   const TypedColumn<std::optional<int64_t>>& render_pass() const {
6300     return static_cast<const ColumnType::render_pass&>(columns()[ColumnIndex::render_pass]);
6301   }
render_pass_name()6302   const TypedColumn<StringPool::Id>& render_pass_name() const {
6303     return static_cast<const ColumnType::render_pass_name&>(columns()[ColumnIndex::render_pass_name]);
6304   }
command_buffer()6305   const TypedColumn<std::optional<int64_t>>& command_buffer() const {
6306     return static_cast<const ColumnType::command_buffer&>(columns()[ColumnIndex::command_buffer]);
6307   }
command_buffer_name()6308   const TypedColumn<StringPool::Id>& command_buffer_name() const {
6309     return static_cast<const ColumnType::command_buffer_name&>(columns()[ColumnIndex::command_buffer_name]);
6310   }
frame_id()6311   const TypedColumn<std::optional<uint32_t>>& frame_id() const {
6312     return static_cast<const ColumnType::frame_id&>(columns()[ColumnIndex::frame_id]);
6313   }
submission_id()6314   const TypedColumn<std::optional<uint32_t>>& submission_id() const {
6315     return static_cast<const ColumnType::submission_id&>(columns()[ColumnIndex::submission_id]);
6316   }
hw_queue_id()6317   const TypedColumn<std::optional<int64_t>>& hw_queue_id() const {
6318     return static_cast<const ColumnType::hw_queue_id&>(columns()[ColumnIndex::hw_queue_id]);
6319   }
upid()6320   const TypedColumn<std::optional<uint32_t>>& upid() const {
6321     return static_cast<const ColumnType::upid&>(columns()[ColumnIndex::upid]);
6322   }
render_subpasses()6323   const TypedColumn<StringPool::Id>& render_subpasses() const {
6324     return static_cast<const ColumnType::render_subpasses&>(columns()[ColumnIndex::render_subpasses]);
6325   }
6326 
mutable_ts()6327   TypedColumn<int64_t>* mutable_ts() {
6328     return static_cast<ColumnType::ts*>(
6329         GetColumn(ColumnIndex::ts));
6330   }
mutable_dur()6331   TypedColumn<int64_t>* mutable_dur() {
6332     return static_cast<ColumnType::dur*>(
6333         GetColumn(ColumnIndex::dur));
6334   }
mutable_track_id()6335   TypedColumn<TrackTable::Id>* mutable_track_id() {
6336     return static_cast<ColumnType::track_id*>(
6337         GetColumn(ColumnIndex::track_id));
6338   }
mutable_category()6339   TypedColumn<std::optional<StringPool::Id>>* mutable_category() {
6340     return static_cast<ColumnType::category*>(
6341         GetColumn(ColumnIndex::category));
6342   }
mutable_name()6343   TypedColumn<std::optional<StringPool::Id>>* mutable_name() {
6344     return static_cast<ColumnType::name*>(
6345         GetColumn(ColumnIndex::name));
6346   }
mutable_depth()6347   TypedColumn<uint32_t>* mutable_depth() {
6348     return static_cast<ColumnType::depth*>(
6349         GetColumn(ColumnIndex::depth));
6350   }
mutable_stack_id()6351   TypedColumn<int64_t>* mutable_stack_id() {
6352     return static_cast<ColumnType::stack_id*>(
6353         GetColumn(ColumnIndex::stack_id));
6354   }
mutable_parent_stack_id()6355   TypedColumn<int64_t>* mutable_parent_stack_id() {
6356     return static_cast<ColumnType::parent_stack_id*>(
6357         GetColumn(ColumnIndex::parent_stack_id));
6358   }
mutable_parent_id()6359   TypedColumn<std::optional<GpuSliceTable::Id>>* mutable_parent_id() {
6360     return static_cast<ColumnType::parent_id*>(
6361         GetColumn(ColumnIndex::parent_id));
6362   }
mutable_arg_set_id()6363   TypedColumn<uint32_t>* mutable_arg_set_id() {
6364     return static_cast<ColumnType::arg_set_id*>(
6365         GetColumn(ColumnIndex::arg_set_id));
6366   }
mutable_thread_ts()6367   TypedColumn<std::optional<int64_t>>* mutable_thread_ts() {
6368     return static_cast<ColumnType::thread_ts*>(
6369         GetColumn(ColumnIndex::thread_ts));
6370   }
mutable_thread_dur()6371   TypedColumn<std::optional<int64_t>>* mutable_thread_dur() {
6372     return static_cast<ColumnType::thread_dur*>(
6373         GetColumn(ColumnIndex::thread_dur));
6374   }
mutable_thread_instruction_count()6375   TypedColumn<std::optional<int64_t>>* mutable_thread_instruction_count() {
6376     return static_cast<ColumnType::thread_instruction_count*>(
6377         GetColumn(ColumnIndex::thread_instruction_count));
6378   }
mutable_thread_instruction_delta()6379   TypedColumn<std::optional<int64_t>>* mutable_thread_instruction_delta() {
6380     return static_cast<ColumnType::thread_instruction_delta*>(
6381         GetColumn(ColumnIndex::thread_instruction_delta));
6382   }
mutable_context_id()6383   TypedColumn<std::optional<int64_t>>* mutable_context_id() {
6384     return static_cast<ColumnType::context_id*>(
6385         GetColumn(ColumnIndex::context_id));
6386   }
mutable_render_target()6387   TypedColumn<std::optional<int64_t>>* mutable_render_target() {
6388     return static_cast<ColumnType::render_target*>(
6389         GetColumn(ColumnIndex::render_target));
6390   }
mutable_render_target_name()6391   TypedColumn<StringPool::Id>* mutable_render_target_name() {
6392     return static_cast<ColumnType::render_target_name*>(
6393         GetColumn(ColumnIndex::render_target_name));
6394   }
mutable_render_pass()6395   TypedColumn<std::optional<int64_t>>* mutable_render_pass() {
6396     return static_cast<ColumnType::render_pass*>(
6397         GetColumn(ColumnIndex::render_pass));
6398   }
mutable_render_pass_name()6399   TypedColumn<StringPool::Id>* mutable_render_pass_name() {
6400     return static_cast<ColumnType::render_pass_name*>(
6401         GetColumn(ColumnIndex::render_pass_name));
6402   }
mutable_command_buffer()6403   TypedColumn<std::optional<int64_t>>* mutable_command_buffer() {
6404     return static_cast<ColumnType::command_buffer*>(
6405         GetColumn(ColumnIndex::command_buffer));
6406   }
mutable_command_buffer_name()6407   TypedColumn<StringPool::Id>* mutable_command_buffer_name() {
6408     return static_cast<ColumnType::command_buffer_name*>(
6409         GetColumn(ColumnIndex::command_buffer_name));
6410   }
mutable_frame_id()6411   TypedColumn<std::optional<uint32_t>>* mutable_frame_id() {
6412     return static_cast<ColumnType::frame_id*>(
6413         GetColumn(ColumnIndex::frame_id));
6414   }
mutable_submission_id()6415   TypedColumn<std::optional<uint32_t>>* mutable_submission_id() {
6416     return static_cast<ColumnType::submission_id*>(
6417         GetColumn(ColumnIndex::submission_id));
6418   }
mutable_hw_queue_id()6419   TypedColumn<std::optional<int64_t>>* mutable_hw_queue_id() {
6420     return static_cast<ColumnType::hw_queue_id*>(
6421         GetColumn(ColumnIndex::hw_queue_id));
6422   }
mutable_upid()6423   TypedColumn<std::optional<uint32_t>>* mutable_upid() {
6424     return static_cast<ColumnType::upid*>(
6425         GetColumn(ColumnIndex::upid));
6426   }
mutable_render_subpasses()6427   TypedColumn<StringPool::Id>* mutable_render_subpasses() {
6428     return static_cast<ColumnType::render_subpasses*>(
6429         GetColumn(ColumnIndex::render_subpasses));
6430   }
6431 
6432  private:
GpuSliceTable(StringPool * pool,const SliceTable & parent,const RowMap & parent_overlay,ColumnStorage<ColumnType::context_id::stored_type> context_id,ColumnStorage<ColumnType::render_target::stored_type> render_target,ColumnStorage<ColumnType::render_target_name::stored_type> render_target_name,ColumnStorage<ColumnType::render_pass::stored_type> render_pass,ColumnStorage<ColumnType::render_pass_name::stored_type> render_pass_name,ColumnStorage<ColumnType::command_buffer::stored_type> command_buffer,ColumnStorage<ColumnType::command_buffer_name::stored_type> command_buffer_name,ColumnStorage<ColumnType::frame_id::stored_type> frame_id,ColumnStorage<ColumnType::submission_id::stored_type> submission_id,ColumnStorage<ColumnType::hw_queue_id::stored_type> hw_queue_id,ColumnStorage<ColumnType::upid::stored_type> upid,ColumnStorage<ColumnType::render_subpasses::stored_type> render_subpasses)6433   GpuSliceTable(StringPool* pool,
6434             const SliceTable& parent,
6435             const RowMap& parent_overlay,
6436             ColumnStorage<ColumnType::context_id::stored_type> context_id
6437 , ColumnStorage<ColumnType::render_target::stored_type> render_target
6438 , ColumnStorage<ColumnType::render_target_name::stored_type> render_target_name
6439 , ColumnStorage<ColumnType::render_pass::stored_type> render_pass
6440 , ColumnStorage<ColumnType::render_pass_name::stored_type> render_pass_name
6441 , ColumnStorage<ColumnType::command_buffer::stored_type> command_buffer
6442 , ColumnStorage<ColumnType::command_buffer_name::stored_type> command_buffer_name
6443 , ColumnStorage<ColumnType::frame_id::stored_type> frame_id
6444 , ColumnStorage<ColumnType::submission_id::stored_type> submission_id
6445 , ColumnStorage<ColumnType::hw_queue_id::stored_type> hw_queue_id
6446 , ColumnStorage<ColumnType::upid::stored_type> upid
6447 , ColumnStorage<ColumnType::render_subpasses::stored_type> render_subpasses)
6448       : macros_internal::MacroTable(
6449           pool,
6450           GetColumns(this, &parent),
6451           parent,
6452           parent_overlay),
6453           const_parent_(&parent)
6454 ,
6455         context_id_storage_layer_(
6456           new column::NumericStorage<ColumnType::context_id::non_optional_stored_type>(
6457             &context_id_.non_null_vector(),
6458             ColumnTypeHelper<ColumnType::context_id::stored_type>::ToColumnType(),
6459             false)),
6460         render_target_storage_layer_(
6461           new column::NumericStorage<ColumnType::render_target::non_optional_stored_type>(
6462             &render_target_.non_null_vector(),
6463             ColumnTypeHelper<ColumnType::render_target::stored_type>::ToColumnType(),
6464             false)),
6465         render_target_name_storage_layer_(
6466           new column::StringStorage(string_pool(), &render_target_name_.vector())),
6467         render_pass_storage_layer_(
6468           new column::NumericStorage<ColumnType::render_pass::non_optional_stored_type>(
6469             &render_pass_.non_null_vector(),
6470             ColumnTypeHelper<ColumnType::render_pass::stored_type>::ToColumnType(),
6471             false)),
6472         render_pass_name_storage_layer_(
6473           new column::StringStorage(string_pool(), &render_pass_name_.vector())),
6474         command_buffer_storage_layer_(
6475           new column::NumericStorage<ColumnType::command_buffer::non_optional_stored_type>(
6476             &command_buffer_.non_null_vector(),
6477             ColumnTypeHelper<ColumnType::command_buffer::stored_type>::ToColumnType(),
6478             false)),
6479         command_buffer_name_storage_layer_(
6480           new column::StringStorage(string_pool(), &command_buffer_name_.vector())),
6481         frame_id_storage_layer_(
6482           new column::NumericStorage<ColumnType::frame_id::non_optional_stored_type>(
6483             &frame_id_.non_null_vector(),
6484             ColumnTypeHelper<ColumnType::frame_id::stored_type>::ToColumnType(),
6485             false)),
6486         submission_id_storage_layer_(
6487           new column::NumericStorage<ColumnType::submission_id::non_optional_stored_type>(
6488             &submission_id_.non_null_vector(),
6489             ColumnTypeHelper<ColumnType::submission_id::stored_type>::ToColumnType(),
6490             false)),
6491         hw_queue_id_storage_layer_(
6492           new column::NumericStorage<ColumnType::hw_queue_id::non_optional_stored_type>(
6493             &hw_queue_id_.non_null_vector(),
6494             ColumnTypeHelper<ColumnType::hw_queue_id::stored_type>::ToColumnType(),
6495             false)),
6496         upid_storage_layer_(
6497           new column::NumericStorage<ColumnType::upid::non_optional_stored_type>(
6498             &upid_.non_null_vector(),
6499             ColumnTypeHelper<ColumnType::upid::stored_type>::ToColumnType(),
6500             false)),
6501         render_subpasses_storage_layer_(
6502           new column::StringStorage(string_pool(), &render_subpasses_.vector()))
6503 ,
6504         context_id_null_layer_(new column::NullOverlay(context_id_.bv())),
6505         render_target_null_layer_(new column::NullOverlay(render_target_.bv())),
6506         render_pass_null_layer_(new column::NullOverlay(render_pass_.bv())),
6507         command_buffer_null_layer_(new column::NullOverlay(command_buffer_.bv())),
6508         frame_id_null_layer_(new column::NullOverlay(frame_id_.bv())),
6509         submission_id_null_layer_(new column::NullOverlay(submission_id_.bv())),
6510         hw_queue_id_null_layer_(new column::NullOverlay(hw_queue_id_.bv())),
6511         upid_null_layer_(new column::NullOverlay(upid_.bv())) {
6512     static_assert(
6513         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::context_id::stored_type>(
6514           ColumnFlag::context_id),
6515         "Column type and flag combination is not valid");
6516       static_assert(
6517         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::render_target::stored_type>(
6518           ColumnFlag::render_target),
6519         "Column type and flag combination is not valid");
6520       static_assert(
6521         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::render_target_name::stored_type>(
6522           ColumnFlag::render_target_name),
6523         "Column type and flag combination is not valid");
6524       static_assert(
6525         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::render_pass::stored_type>(
6526           ColumnFlag::render_pass),
6527         "Column type and flag combination is not valid");
6528       static_assert(
6529         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::render_pass_name::stored_type>(
6530           ColumnFlag::render_pass_name),
6531         "Column type and flag combination is not valid");
6532       static_assert(
6533         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::command_buffer::stored_type>(
6534           ColumnFlag::command_buffer),
6535         "Column type and flag combination is not valid");
6536       static_assert(
6537         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::command_buffer_name::stored_type>(
6538           ColumnFlag::command_buffer_name),
6539         "Column type and flag combination is not valid");
6540       static_assert(
6541         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::frame_id::stored_type>(
6542           ColumnFlag::frame_id),
6543         "Column type and flag combination is not valid");
6544       static_assert(
6545         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::submission_id::stored_type>(
6546           ColumnFlag::submission_id),
6547         "Column type and flag combination is not valid");
6548       static_assert(
6549         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::hw_queue_id::stored_type>(
6550           ColumnFlag::hw_queue_id),
6551         "Column type and flag combination is not valid");
6552       static_assert(
6553         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::upid::stored_type>(
6554           ColumnFlag::upid),
6555         "Column type and flag combination is not valid");
6556       static_assert(
6557         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::render_subpasses::stored_type>(
6558           ColumnFlag::render_subpasses),
6559         "Column type and flag combination is not valid");
6560     PERFETTO_DCHECK(context_id.size() == parent_overlay.size());
6561     context_id_ = std::move(context_id);
6562     PERFETTO_DCHECK(render_target.size() == parent_overlay.size());
6563     render_target_ = std::move(render_target);
6564     PERFETTO_DCHECK(render_target_name.size() == parent_overlay.size());
6565     render_target_name_ = std::move(render_target_name);
6566     PERFETTO_DCHECK(render_pass.size() == parent_overlay.size());
6567     render_pass_ = std::move(render_pass);
6568     PERFETTO_DCHECK(render_pass_name.size() == parent_overlay.size());
6569     render_pass_name_ = std::move(render_pass_name);
6570     PERFETTO_DCHECK(command_buffer.size() == parent_overlay.size());
6571     command_buffer_ = std::move(command_buffer);
6572     PERFETTO_DCHECK(command_buffer_name.size() == parent_overlay.size());
6573     command_buffer_name_ = std::move(command_buffer_name);
6574     PERFETTO_DCHECK(frame_id.size() == parent_overlay.size());
6575     frame_id_ = std::move(frame_id);
6576     PERFETTO_DCHECK(submission_id.size() == parent_overlay.size());
6577     submission_id_ = std::move(submission_id);
6578     PERFETTO_DCHECK(hw_queue_id.size() == parent_overlay.size());
6579     hw_queue_id_ = std::move(hw_queue_id);
6580     PERFETTO_DCHECK(upid.size() == parent_overlay.size());
6581     upid_ = std::move(upid);
6582     PERFETTO_DCHECK(render_subpasses.size() == parent_overlay.size());
6583     render_subpasses_ = std::move(render_subpasses);
6584 
6585     std::vector<RefPtr<column::OverlayLayer>> overlay_layers(OverlayCount(&parent) + 1);
6586     for (uint32_t i = 0; i < overlay_layers.size(); ++i) {
6587       if (overlays()[i].row_map().IsIndexVector()) {
6588         overlay_layers[i].reset(new column::ArrangementOverlay(
6589             overlays()[i].row_map().GetIfIndexVector(),
6590             column::DataLayerChain::Indices::State::kNonmonotonic));
6591       } else if (overlays()[i].row_map().IsBitVector()) {
6592         overlay_layers[i].reset(new column::SelectorOverlay(
6593             overlays()[i].row_map().GetIfBitVector()));
6594       } else if (overlays()[i].row_map().IsRange()) {
6595         overlay_layers[i].reset(new column::RangeOverlay(
6596             overlays()[i].row_map().GetIfIRange()));
6597       }
6598     }
6599 
6600     OnConstructionCompleted(
6601       {const_parent_->storage_layers()[ColumnIndex::id],const_parent_->storage_layers()[ColumnIndex::type],const_parent_->storage_layers()[ColumnIndex::ts],const_parent_->storage_layers()[ColumnIndex::dur],const_parent_->storage_layers()[ColumnIndex::track_id],const_parent_->storage_layers()[ColumnIndex::category],const_parent_->storage_layers()[ColumnIndex::name],const_parent_->storage_layers()[ColumnIndex::depth],const_parent_->storage_layers()[ColumnIndex::stack_id],const_parent_->storage_layers()[ColumnIndex::parent_stack_id],const_parent_->storage_layers()[ColumnIndex::parent_id],const_parent_->storage_layers()[ColumnIndex::arg_set_id],const_parent_->storage_layers()[ColumnIndex::thread_ts],const_parent_->storage_layers()[ColumnIndex::thread_dur],const_parent_->storage_layers()[ColumnIndex::thread_instruction_count],const_parent_->storage_layers()[ColumnIndex::thread_instruction_delta],context_id_storage_layer_,render_target_storage_layer_,render_target_name_storage_layer_,render_pass_storage_layer_,render_pass_name_storage_layer_,command_buffer_storage_layer_,command_buffer_name_storage_layer_,frame_id_storage_layer_,submission_id_storage_layer_,hw_queue_id_storage_layer_,upid_storage_layer_,render_subpasses_storage_layer_}, {{},{},{},{},{},{},{},{},{},{},const_parent_->null_layers()[ColumnIndex::parent_id],{},const_parent_->null_layers()[ColumnIndex::thread_ts],const_parent_->null_layers()[ColumnIndex::thread_dur],const_parent_->null_layers()[ColumnIndex::thread_instruction_count],const_parent_->null_layers()[ColumnIndex::thread_instruction_delta],context_id_null_layer_,render_target_null_layer_,{},render_pass_null_layer_,{},command_buffer_null_layer_,{},frame_id_null_layer_,submission_id_null_layer_,hw_queue_id_null_layer_,upid_null_layer_,{}}, std::move(overlay_layers));
6602   }
6603   SliceTable* parent_ = nullptr;
6604   const SliceTable* const_parent_ = nullptr;
6605   ColumnStorage<ColumnType::context_id::stored_type> context_id_;
6606   ColumnStorage<ColumnType::render_target::stored_type> render_target_;
6607   ColumnStorage<ColumnType::render_target_name::stored_type> render_target_name_;
6608   ColumnStorage<ColumnType::render_pass::stored_type> render_pass_;
6609   ColumnStorage<ColumnType::render_pass_name::stored_type> render_pass_name_;
6610   ColumnStorage<ColumnType::command_buffer::stored_type> command_buffer_;
6611   ColumnStorage<ColumnType::command_buffer_name::stored_type> command_buffer_name_;
6612   ColumnStorage<ColumnType::frame_id::stored_type> frame_id_;
6613   ColumnStorage<ColumnType::submission_id::stored_type> submission_id_;
6614   ColumnStorage<ColumnType::hw_queue_id::stored_type> hw_queue_id_;
6615   ColumnStorage<ColumnType::upid::stored_type> upid_;
6616   ColumnStorage<ColumnType::render_subpasses::stored_type> render_subpasses_;
6617 
6618   RefPtr<column::StorageLayer> context_id_storage_layer_;
6619   RefPtr<column::StorageLayer> render_target_storage_layer_;
6620   RefPtr<column::StorageLayer> render_target_name_storage_layer_;
6621   RefPtr<column::StorageLayer> render_pass_storage_layer_;
6622   RefPtr<column::StorageLayer> render_pass_name_storage_layer_;
6623   RefPtr<column::StorageLayer> command_buffer_storage_layer_;
6624   RefPtr<column::StorageLayer> command_buffer_name_storage_layer_;
6625   RefPtr<column::StorageLayer> frame_id_storage_layer_;
6626   RefPtr<column::StorageLayer> submission_id_storage_layer_;
6627   RefPtr<column::StorageLayer> hw_queue_id_storage_layer_;
6628   RefPtr<column::StorageLayer> upid_storage_layer_;
6629   RefPtr<column::StorageLayer> render_subpasses_storage_layer_;
6630 
6631   RefPtr<column::OverlayLayer> context_id_null_layer_;
6632   RefPtr<column::OverlayLayer> render_target_null_layer_;
6633   RefPtr<column::OverlayLayer> render_pass_null_layer_;
6634   RefPtr<column::OverlayLayer> command_buffer_null_layer_;
6635   RefPtr<column::OverlayLayer> frame_id_null_layer_;
6636   RefPtr<column::OverlayLayer> submission_id_null_layer_;
6637   RefPtr<column::OverlayLayer> hw_queue_id_null_layer_;
6638   RefPtr<column::OverlayLayer> upid_null_layer_;
6639 };
6640 
6641 
6642 class GraphicsFrameSliceTable : public macros_internal::MacroTable {
6643  public:
6644   static constexpr uint32_t kColumnCount = 21;
6645 
6646   using Id = SliceTable::Id;
6647 
6648   struct ColumnIndex {
6649     static constexpr uint32_t id = 0;
6650     static constexpr uint32_t type = 1;
6651     static constexpr uint32_t ts = 2;
6652     static constexpr uint32_t dur = 3;
6653     static constexpr uint32_t track_id = 4;
6654     static constexpr uint32_t category = 5;
6655     static constexpr uint32_t name = 6;
6656     static constexpr uint32_t depth = 7;
6657     static constexpr uint32_t stack_id = 8;
6658     static constexpr uint32_t parent_stack_id = 9;
6659     static constexpr uint32_t parent_id = 10;
6660     static constexpr uint32_t arg_set_id = 11;
6661     static constexpr uint32_t thread_ts = 12;
6662     static constexpr uint32_t thread_dur = 13;
6663     static constexpr uint32_t thread_instruction_count = 14;
6664     static constexpr uint32_t thread_instruction_delta = 15;
6665     static constexpr uint32_t frame_number = 16;
6666     static constexpr uint32_t layer_name = 17;
6667     static constexpr uint32_t queue_to_acquire_time = 18;
6668     static constexpr uint32_t acquire_to_latch_time = 19;
6669     static constexpr uint32_t latch_to_present_time = 20;
6670   };
6671   struct ColumnType {
6672     using id = IdColumn<GraphicsFrameSliceTable::Id>;
6673     using type = TypedColumn<StringPool::Id>;
6674     using ts = TypedColumn<int64_t>;
6675     using dur = TypedColumn<int64_t>;
6676     using track_id = TypedColumn<TrackTable::Id>;
6677     using category = TypedColumn<std::optional<StringPool::Id>>;
6678     using name = TypedColumn<std::optional<StringPool::Id>>;
6679     using depth = TypedColumn<uint32_t>;
6680     using stack_id = TypedColumn<int64_t>;
6681     using parent_stack_id = TypedColumn<int64_t>;
6682     using parent_id = TypedColumn<std::optional<GraphicsFrameSliceTable::Id>>;
6683     using arg_set_id = TypedColumn<uint32_t>;
6684     using thread_ts = TypedColumn<std::optional<int64_t>>;
6685     using thread_dur = TypedColumn<std::optional<int64_t>>;
6686     using thread_instruction_count = TypedColumn<std::optional<int64_t>>;
6687     using thread_instruction_delta = TypedColumn<std::optional<int64_t>>;
6688     using frame_number = TypedColumn<uint32_t>;
6689     using layer_name = TypedColumn<StringPool::Id>;
6690     using queue_to_acquire_time = TypedColumn<int64_t>;
6691     using acquire_to_latch_time = TypedColumn<int64_t>;
6692     using latch_to_present_time = TypedColumn<int64_t>;
6693   };
6694   struct Row : public SliceTable::Row {
6695     Row(int64_t in_ts = {},
6696         int64_t in_dur = {},
6697         TrackTable::Id in_track_id = {},
6698         std::optional<StringPool::Id> in_category = {},
6699         std::optional<StringPool::Id> in_name = {},
6700         uint32_t in_depth = {},
6701         int64_t in_stack_id = {},
6702         int64_t in_parent_stack_id = {},
6703         std::optional<GraphicsFrameSliceTable::Id> in_parent_id = {},
6704         uint32_t in_arg_set_id = {},
6705         std::optional<int64_t> in_thread_ts = {},
6706         std::optional<int64_t> in_thread_dur = {},
6707         std::optional<int64_t> in_thread_instruction_count = {},
6708         std::optional<int64_t> in_thread_instruction_delta = {},
6709         uint32_t in_frame_number = {},
6710         StringPool::Id in_layer_name = {},
6711         int64_t in_queue_to_acquire_time = {},
6712         int64_t in_acquire_to_latch_time = {},
6713         int64_t in_latch_to_present_time = {},
6714         std::nullptr_t = nullptr)
RowRow6715         : SliceTable::Row(in_ts, in_dur, in_track_id, in_category, in_name, in_depth, in_stack_id, in_parent_stack_id, in_parent_id, in_arg_set_id, in_thread_ts, in_thread_dur, in_thread_instruction_count, in_thread_instruction_delta),
6716           frame_number(in_frame_number),
6717           layer_name(in_layer_name),
6718           queue_to_acquire_time(in_queue_to_acquire_time),
6719           acquire_to_latch_time(in_acquire_to_latch_time),
6720           latch_to_present_time(in_latch_to_present_time) {
6721       type_ = "frame_slice";
6722     }
6723     uint32_t frame_number;
6724     StringPool::Id layer_name;
6725     int64_t queue_to_acquire_time;
6726     int64_t acquire_to_latch_time;
6727     int64_t latch_to_present_time;
6728 
6729     bool operator==(const GraphicsFrameSliceTable::Row& other) const {
6730       return type() == other.type() && ColumnType::ts::Equals(ts, other.ts) &&
6731        ColumnType::dur::Equals(dur, other.dur) &&
6732        ColumnType::track_id::Equals(track_id, other.track_id) &&
6733        ColumnType::category::Equals(category, other.category) &&
6734        ColumnType::name::Equals(name, other.name) &&
6735        ColumnType::depth::Equals(depth, other.depth) &&
6736        ColumnType::stack_id::Equals(stack_id, other.stack_id) &&
6737        ColumnType::parent_stack_id::Equals(parent_stack_id, other.parent_stack_id) &&
6738        ColumnType::parent_id::Equals(parent_id, other.parent_id) &&
6739        ColumnType::arg_set_id::Equals(arg_set_id, other.arg_set_id) &&
6740        ColumnType::thread_ts::Equals(thread_ts, other.thread_ts) &&
6741        ColumnType::thread_dur::Equals(thread_dur, other.thread_dur) &&
6742        ColumnType::thread_instruction_count::Equals(thread_instruction_count, other.thread_instruction_count) &&
6743        ColumnType::thread_instruction_delta::Equals(thread_instruction_delta, other.thread_instruction_delta) &&
6744        ColumnType::frame_number::Equals(frame_number, other.frame_number) &&
6745        ColumnType::layer_name::Equals(layer_name, other.layer_name) &&
6746        ColumnType::queue_to_acquire_time::Equals(queue_to_acquire_time, other.queue_to_acquire_time) &&
6747        ColumnType::acquire_to_latch_time::Equals(acquire_to_latch_time, other.acquire_to_latch_time) &&
6748        ColumnType::latch_to_present_time::Equals(latch_to_present_time, other.latch_to_present_time);
6749     }
6750   };
6751   struct ColumnFlag {
6752     static constexpr uint32_t frame_number = ColumnType::frame_number::default_flags();
6753     static constexpr uint32_t layer_name = ColumnType::layer_name::default_flags();
6754     static constexpr uint32_t queue_to_acquire_time = ColumnType::queue_to_acquire_time::default_flags();
6755     static constexpr uint32_t acquire_to_latch_time = ColumnType::acquire_to_latch_time::default_flags();
6756     static constexpr uint32_t latch_to_present_time = ColumnType::latch_to_present_time::default_flags();
6757   };
6758 
6759   class RowNumber;
6760   class ConstRowReference;
6761   class RowReference;
6762 
6763   class RowNumber : public macros_internal::AbstractRowNumber<
6764       GraphicsFrameSliceTable, ConstRowReference, RowReference> {
6765    public:
RowNumber(uint32_t row_number)6766     explicit RowNumber(uint32_t row_number)
6767         : AbstractRowNumber(row_number) {}
6768   };
6769   static_assert(std::is_trivially_destructible_v<RowNumber>,
6770                 "Inheritance used without trivial destruction");
6771 
6772   class ConstRowReference : public macros_internal::AbstractConstRowReference<
6773     GraphicsFrameSliceTable, RowNumber> {
6774    public:
ConstRowReference(const GraphicsFrameSliceTable * table,uint32_t row_number)6775     ConstRowReference(const GraphicsFrameSliceTable* table, uint32_t row_number)
6776         : AbstractConstRowReference(table, row_number) {}
6777 
id()6778     ColumnType::id::type id() const {
6779       return table()->id()[row_number_];
6780     }
type()6781     ColumnType::type::type type() const {
6782       return table()->type()[row_number_];
6783     }
ts()6784     ColumnType::ts::type ts() const {
6785       return table()->ts()[row_number_];
6786     }
dur()6787     ColumnType::dur::type dur() const {
6788       return table()->dur()[row_number_];
6789     }
track_id()6790     ColumnType::track_id::type track_id() const {
6791       return table()->track_id()[row_number_];
6792     }
category()6793     ColumnType::category::type category() const {
6794       return table()->category()[row_number_];
6795     }
name()6796     ColumnType::name::type name() const {
6797       return table()->name()[row_number_];
6798     }
depth()6799     ColumnType::depth::type depth() const {
6800       return table()->depth()[row_number_];
6801     }
stack_id()6802     ColumnType::stack_id::type stack_id() const {
6803       return table()->stack_id()[row_number_];
6804     }
parent_stack_id()6805     ColumnType::parent_stack_id::type parent_stack_id() const {
6806       return table()->parent_stack_id()[row_number_];
6807     }
parent_id()6808     ColumnType::parent_id::type parent_id() const {
6809       return table()->parent_id()[row_number_];
6810     }
arg_set_id()6811     ColumnType::arg_set_id::type arg_set_id() const {
6812       return table()->arg_set_id()[row_number_];
6813     }
thread_ts()6814     ColumnType::thread_ts::type thread_ts() const {
6815       return table()->thread_ts()[row_number_];
6816     }
thread_dur()6817     ColumnType::thread_dur::type thread_dur() const {
6818       return table()->thread_dur()[row_number_];
6819     }
thread_instruction_count()6820     ColumnType::thread_instruction_count::type thread_instruction_count() const {
6821       return table()->thread_instruction_count()[row_number_];
6822     }
thread_instruction_delta()6823     ColumnType::thread_instruction_delta::type thread_instruction_delta() const {
6824       return table()->thread_instruction_delta()[row_number_];
6825     }
frame_number()6826     ColumnType::frame_number::type frame_number() const {
6827       return table()->frame_number()[row_number_];
6828     }
layer_name()6829     ColumnType::layer_name::type layer_name() const {
6830       return table()->layer_name()[row_number_];
6831     }
queue_to_acquire_time()6832     ColumnType::queue_to_acquire_time::type queue_to_acquire_time() const {
6833       return table()->queue_to_acquire_time()[row_number_];
6834     }
acquire_to_latch_time()6835     ColumnType::acquire_to_latch_time::type acquire_to_latch_time() const {
6836       return table()->acquire_to_latch_time()[row_number_];
6837     }
latch_to_present_time()6838     ColumnType::latch_to_present_time::type latch_to_present_time() const {
6839       return table()->latch_to_present_time()[row_number_];
6840     }
6841   };
6842   static_assert(std::is_trivially_destructible_v<ConstRowReference>,
6843                 "Inheritance used without trivial destruction");
6844   class RowReference : public ConstRowReference {
6845    public:
RowReference(const GraphicsFrameSliceTable * table,uint32_t row_number)6846     RowReference(const GraphicsFrameSliceTable* table, uint32_t row_number)
6847         : ConstRowReference(table, row_number) {}
6848 
set_ts(ColumnType::ts::non_optional_type v)6849     void set_ts(
6850         ColumnType::ts::non_optional_type v) {
6851       return mutable_table()->mutable_ts()->Set(row_number_, v);
6852     }
set_dur(ColumnType::dur::non_optional_type v)6853     void set_dur(
6854         ColumnType::dur::non_optional_type v) {
6855       return mutable_table()->mutable_dur()->Set(row_number_, v);
6856     }
set_track_id(ColumnType::track_id::non_optional_type v)6857     void set_track_id(
6858         ColumnType::track_id::non_optional_type v) {
6859       return mutable_table()->mutable_track_id()->Set(row_number_, v);
6860     }
set_category(ColumnType::category::non_optional_type v)6861     void set_category(
6862         ColumnType::category::non_optional_type v) {
6863       return mutable_table()->mutable_category()->Set(row_number_, v);
6864     }
set_name(ColumnType::name::non_optional_type v)6865     void set_name(
6866         ColumnType::name::non_optional_type v) {
6867       return mutable_table()->mutable_name()->Set(row_number_, v);
6868     }
set_depth(ColumnType::depth::non_optional_type v)6869     void set_depth(
6870         ColumnType::depth::non_optional_type v) {
6871       return mutable_table()->mutable_depth()->Set(row_number_, v);
6872     }
set_stack_id(ColumnType::stack_id::non_optional_type v)6873     void set_stack_id(
6874         ColumnType::stack_id::non_optional_type v) {
6875       return mutable_table()->mutable_stack_id()->Set(row_number_, v);
6876     }
set_parent_stack_id(ColumnType::parent_stack_id::non_optional_type v)6877     void set_parent_stack_id(
6878         ColumnType::parent_stack_id::non_optional_type v) {
6879       return mutable_table()->mutable_parent_stack_id()->Set(row_number_, v);
6880     }
set_parent_id(ColumnType::parent_id::non_optional_type v)6881     void set_parent_id(
6882         ColumnType::parent_id::non_optional_type v) {
6883       return mutable_table()->mutable_parent_id()->Set(row_number_, v);
6884     }
set_arg_set_id(ColumnType::arg_set_id::non_optional_type v)6885     void set_arg_set_id(
6886         ColumnType::arg_set_id::non_optional_type v) {
6887       return mutable_table()->mutable_arg_set_id()->Set(row_number_, v);
6888     }
set_thread_ts(ColumnType::thread_ts::non_optional_type v)6889     void set_thread_ts(
6890         ColumnType::thread_ts::non_optional_type v) {
6891       return mutable_table()->mutable_thread_ts()->Set(row_number_, v);
6892     }
set_thread_dur(ColumnType::thread_dur::non_optional_type v)6893     void set_thread_dur(
6894         ColumnType::thread_dur::non_optional_type v) {
6895       return mutable_table()->mutable_thread_dur()->Set(row_number_, v);
6896     }
set_thread_instruction_count(ColumnType::thread_instruction_count::non_optional_type v)6897     void set_thread_instruction_count(
6898         ColumnType::thread_instruction_count::non_optional_type v) {
6899       return mutable_table()->mutable_thread_instruction_count()->Set(row_number_, v);
6900     }
set_thread_instruction_delta(ColumnType::thread_instruction_delta::non_optional_type v)6901     void set_thread_instruction_delta(
6902         ColumnType::thread_instruction_delta::non_optional_type v) {
6903       return mutable_table()->mutable_thread_instruction_delta()->Set(row_number_, v);
6904     }
set_frame_number(ColumnType::frame_number::non_optional_type v)6905     void set_frame_number(
6906         ColumnType::frame_number::non_optional_type v) {
6907       return mutable_table()->mutable_frame_number()->Set(row_number_, v);
6908     }
set_layer_name(ColumnType::layer_name::non_optional_type v)6909     void set_layer_name(
6910         ColumnType::layer_name::non_optional_type v) {
6911       return mutable_table()->mutable_layer_name()->Set(row_number_, v);
6912     }
set_queue_to_acquire_time(ColumnType::queue_to_acquire_time::non_optional_type v)6913     void set_queue_to_acquire_time(
6914         ColumnType::queue_to_acquire_time::non_optional_type v) {
6915       return mutable_table()->mutable_queue_to_acquire_time()->Set(row_number_, v);
6916     }
set_acquire_to_latch_time(ColumnType::acquire_to_latch_time::non_optional_type v)6917     void set_acquire_to_latch_time(
6918         ColumnType::acquire_to_latch_time::non_optional_type v) {
6919       return mutable_table()->mutable_acquire_to_latch_time()->Set(row_number_, v);
6920     }
set_latch_to_present_time(ColumnType::latch_to_present_time::non_optional_type v)6921     void set_latch_to_present_time(
6922         ColumnType::latch_to_present_time::non_optional_type v) {
6923       return mutable_table()->mutable_latch_to_present_time()->Set(row_number_, v);
6924     }
6925 
6926    private:
mutable_table()6927     GraphicsFrameSliceTable* mutable_table() const {
6928       return const_cast<GraphicsFrameSliceTable*>(table());
6929     }
6930   };
6931   static_assert(std::is_trivially_destructible_v<RowReference>,
6932                 "Inheritance used without trivial destruction");
6933 
6934   class ConstIterator;
6935   class ConstIterator : public macros_internal::AbstractConstIterator<
6936     ConstIterator, GraphicsFrameSliceTable, RowNumber, ConstRowReference> {
6937    public:
id()6938     ColumnType::id::type id() const {
6939       const auto& col = table()->id();
6940       return col.GetAtIdx(
6941         iterator_.StorageIndexForColumn(col.index_in_table()));
6942     }
type()6943     ColumnType::type::type type() const {
6944       const auto& col = table()->type();
6945       return col.GetAtIdx(
6946         iterator_.StorageIndexForColumn(col.index_in_table()));
6947     }
ts()6948     ColumnType::ts::type ts() const {
6949       const auto& col = table()->ts();
6950       return col.GetAtIdx(
6951         iterator_.StorageIndexForColumn(col.index_in_table()));
6952     }
dur()6953     ColumnType::dur::type dur() const {
6954       const auto& col = table()->dur();
6955       return col.GetAtIdx(
6956         iterator_.StorageIndexForColumn(col.index_in_table()));
6957     }
track_id()6958     ColumnType::track_id::type track_id() const {
6959       const auto& col = table()->track_id();
6960       return col.GetAtIdx(
6961         iterator_.StorageIndexForColumn(col.index_in_table()));
6962     }
category()6963     ColumnType::category::type category() const {
6964       const auto& col = table()->category();
6965       return col.GetAtIdx(
6966         iterator_.StorageIndexForColumn(col.index_in_table()));
6967     }
name()6968     ColumnType::name::type name() const {
6969       const auto& col = table()->name();
6970       return col.GetAtIdx(
6971         iterator_.StorageIndexForColumn(col.index_in_table()));
6972     }
depth()6973     ColumnType::depth::type depth() const {
6974       const auto& col = table()->depth();
6975       return col.GetAtIdx(
6976         iterator_.StorageIndexForColumn(col.index_in_table()));
6977     }
stack_id()6978     ColumnType::stack_id::type stack_id() const {
6979       const auto& col = table()->stack_id();
6980       return col.GetAtIdx(
6981         iterator_.StorageIndexForColumn(col.index_in_table()));
6982     }
parent_stack_id()6983     ColumnType::parent_stack_id::type parent_stack_id() const {
6984       const auto& col = table()->parent_stack_id();
6985       return col.GetAtIdx(
6986         iterator_.StorageIndexForColumn(col.index_in_table()));
6987     }
parent_id()6988     ColumnType::parent_id::type parent_id() const {
6989       const auto& col = table()->parent_id();
6990       return col.GetAtIdx(
6991         iterator_.StorageIndexForColumn(col.index_in_table()));
6992     }
arg_set_id()6993     ColumnType::arg_set_id::type arg_set_id() const {
6994       const auto& col = table()->arg_set_id();
6995       return col.GetAtIdx(
6996         iterator_.StorageIndexForColumn(col.index_in_table()));
6997     }
thread_ts()6998     ColumnType::thread_ts::type thread_ts() const {
6999       const auto& col = table()->thread_ts();
7000       return col.GetAtIdx(
7001         iterator_.StorageIndexForColumn(col.index_in_table()));
7002     }
thread_dur()7003     ColumnType::thread_dur::type thread_dur() const {
7004       const auto& col = table()->thread_dur();
7005       return col.GetAtIdx(
7006         iterator_.StorageIndexForColumn(col.index_in_table()));
7007     }
thread_instruction_count()7008     ColumnType::thread_instruction_count::type thread_instruction_count() const {
7009       const auto& col = table()->thread_instruction_count();
7010       return col.GetAtIdx(
7011         iterator_.StorageIndexForColumn(col.index_in_table()));
7012     }
thread_instruction_delta()7013     ColumnType::thread_instruction_delta::type thread_instruction_delta() const {
7014       const auto& col = table()->thread_instruction_delta();
7015       return col.GetAtIdx(
7016         iterator_.StorageIndexForColumn(col.index_in_table()));
7017     }
frame_number()7018     ColumnType::frame_number::type frame_number() const {
7019       const auto& col = table()->frame_number();
7020       return col.GetAtIdx(
7021         iterator_.StorageIndexForColumn(col.index_in_table()));
7022     }
layer_name()7023     ColumnType::layer_name::type layer_name() const {
7024       const auto& col = table()->layer_name();
7025       return col.GetAtIdx(
7026         iterator_.StorageIndexForColumn(col.index_in_table()));
7027     }
queue_to_acquire_time()7028     ColumnType::queue_to_acquire_time::type queue_to_acquire_time() const {
7029       const auto& col = table()->queue_to_acquire_time();
7030       return col.GetAtIdx(
7031         iterator_.StorageIndexForColumn(col.index_in_table()));
7032     }
acquire_to_latch_time()7033     ColumnType::acquire_to_latch_time::type acquire_to_latch_time() const {
7034       const auto& col = table()->acquire_to_latch_time();
7035       return col.GetAtIdx(
7036         iterator_.StorageIndexForColumn(col.index_in_table()));
7037     }
latch_to_present_time()7038     ColumnType::latch_to_present_time::type latch_to_present_time() const {
7039       const auto& col = table()->latch_to_present_time();
7040       return col.GetAtIdx(
7041         iterator_.StorageIndexForColumn(col.index_in_table()));
7042     }
7043 
7044    protected:
ConstIterator(const GraphicsFrameSliceTable * table,Table::Iterator iterator)7045     explicit ConstIterator(const GraphicsFrameSliceTable* table,
7046                            Table::Iterator iterator)
7047         : AbstractConstIterator(table, std::move(iterator)) {}
7048 
CurrentRowNumber()7049     uint32_t CurrentRowNumber() const {
7050       return iterator_.StorageIndexForLastOverlay();
7051     }
7052 
7053    private:
7054     friend class GraphicsFrameSliceTable;
7055     friend class macros_internal::AbstractConstIterator<
7056       ConstIterator, GraphicsFrameSliceTable, RowNumber, ConstRowReference>;
7057   };
7058   class Iterator : public ConstIterator {
7059     public:
row_reference()7060      RowReference row_reference() const {
7061        return {const_cast<GraphicsFrameSliceTable*>(table()), CurrentRowNumber()};
7062      }
7063 
7064     private:
7065      friend class GraphicsFrameSliceTable;
7066 
Iterator(GraphicsFrameSliceTable * table,Table::Iterator iterator)7067      explicit Iterator(GraphicsFrameSliceTable* table, Table::Iterator iterator)
7068         : ConstIterator(table, std::move(iterator)) {}
7069   };
7070 
7071   struct IdAndRow {
7072     Id id;
7073     uint32_t row;
7074     RowReference row_reference;
7075     RowNumber row_number;
7076   };
7077 
GetColumns(GraphicsFrameSliceTable * self,const macros_internal::MacroTable * parent)7078   static std::vector<ColumnLegacy> GetColumns(
7079       GraphicsFrameSliceTable* self,
7080       const macros_internal::MacroTable* parent) {
7081     std::vector<ColumnLegacy> columns =
7082         CopyColumnsFromParentOrAddRootColumns(self, parent);
7083     uint32_t olay_idx = OverlayCount(parent);
7084     AddColumnToVector(columns, "frame_number", &self->frame_number_, ColumnFlag::frame_number,
7085                       static_cast<uint32_t>(columns.size()), olay_idx);
7086     AddColumnToVector(columns, "layer_name", &self->layer_name_, ColumnFlag::layer_name,
7087                       static_cast<uint32_t>(columns.size()), olay_idx);
7088     AddColumnToVector(columns, "queue_to_acquire_time", &self->queue_to_acquire_time_, ColumnFlag::queue_to_acquire_time,
7089                       static_cast<uint32_t>(columns.size()), olay_idx);
7090     AddColumnToVector(columns, "acquire_to_latch_time", &self->acquire_to_latch_time_, ColumnFlag::acquire_to_latch_time,
7091                       static_cast<uint32_t>(columns.size()), olay_idx);
7092     AddColumnToVector(columns, "latch_to_present_time", &self->latch_to_present_time_, ColumnFlag::latch_to_present_time,
7093                       static_cast<uint32_t>(columns.size()), olay_idx);
7094     return columns;
7095   }
7096 
GraphicsFrameSliceTable(StringPool * pool,SliceTable * parent)7097   PERFETTO_NO_INLINE explicit GraphicsFrameSliceTable(StringPool* pool, SliceTable* parent)
7098       : macros_internal::MacroTable(
7099           pool,
7100           GetColumns(this, parent),
7101           parent),
7102         parent_(parent), const_parent_(parent), frame_number_(ColumnStorage<ColumnType::frame_number::stored_type>::Create<false>()),
7103         layer_name_(ColumnStorage<ColumnType::layer_name::stored_type>::Create<false>()),
7104         queue_to_acquire_time_(ColumnStorage<ColumnType::queue_to_acquire_time::stored_type>::Create<false>()),
7105         acquire_to_latch_time_(ColumnStorage<ColumnType::acquire_to_latch_time::stored_type>::Create<false>()),
7106         latch_to_present_time_(ColumnStorage<ColumnType::latch_to_present_time::stored_type>::Create<false>())
7107 ,
7108         frame_number_storage_layer_(
7109         new column::NumericStorage<ColumnType::frame_number::non_optional_stored_type>(
7110           &frame_number_.vector(),
7111           ColumnTypeHelper<ColumnType::frame_number::stored_type>::ToColumnType(),
7112           false)),
7113         layer_name_storage_layer_(
7114           new column::StringStorage(string_pool(), &layer_name_.vector())),
7115         queue_to_acquire_time_storage_layer_(
7116         new column::NumericStorage<ColumnType::queue_to_acquire_time::non_optional_stored_type>(
7117           &queue_to_acquire_time_.vector(),
7118           ColumnTypeHelper<ColumnType::queue_to_acquire_time::stored_type>::ToColumnType(),
7119           false)),
7120         acquire_to_latch_time_storage_layer_(
7121         new column::NumericStorage<ColumnType::acquire_to_latch_time::non_optional_stored_type>(
7122           &acquire_to_latch_time_.vector(),
7123           ColumnTypeHelper<ColumnType::acquire_to_latch_time::stored_type>::ToColumnType(),
7124           false)),
7125         latch_to_present_time_storage_layer_(
7126         new column::NumericStorage<ColumnType::latch_to_present_time::non_optional_stored_type>(
7127           &latch_to_present_time_.vector(),
7128           ColumnTypeHelper<ColumnType::latch_to_present_time::stored_type>::ToColumnType(),
7129           false))
7130          {
7131     static_assert(
7132         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::frame_number::stored_type>(
7133           ColumnFlag::frame_number),
7134         "Column type and flag combination is not valid");
7135       static_assert(
7136         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::layer_name::stored_type>(
7137           ColumnFlag::layer_name),
7138         "Column type and flag combination is not valid");
7139       static_assert(
7140         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::queue_to_acquire_time::stored_type>(
7141           ColumnFlag::queue_to_acquire_time),
7142         "Column type and flag combination is not valid");
7143       static_assert(
7144         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::acquire_to_latch_time::stored_type>(
7145           ColumnFlag::acquire_to_latch_time),
7146         "Column type and flag combination is not valid");
7147       static_assert(
7148         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::latch_to_present_time::stored_type>(
7149           ColumnFlag::latch_to_present_time),
7150         "Column type and flag combination is not valid");
7151     OnConstructionCompletedRegularConstructor(
7152       {const_parent_->storage_layers()[ColumnIndex::id],const_parent_->storage_layers()[ColumnIndex::type],const_parent_->storage_layers()[ColumnIndex::ts],const_parent_->storage_layers()[ColumnIndex::dur],const_parent_->storage_layers()[ColumnIndex::track_id],const_parent_->storage_layers()[ColumnIndex::category],const_parent_->storage_layers()[ColumnIndex::name],const_parent_->storage_layers()[ColumnIndex::depth],const_parent_->storage_layers()[ColumnIndex::stack_id],const_parent_->storage_layers()[ColumnIndex::parent_stack_id],const_parent_->storage_layers()[ColumnIndex::parent_id],const_parent_->storage_layers()[ColumnIndex::arg_set_id],const_parent_->storage_layers()[ColumnIndex::thread_ts],const_parent_->storage_layers()[ColumnIndex::thread_dur],const_parent_->storage_layers()[ColumnIndex::thread_instruction_count],const_parent_->storage_layers()[ColumnIndex::thread_instruction_delta],frame_number_storage_layer_,layer_name_storage_layer_,queue_to_acquire_time_storage_layer_,acquire_to_latch_time_storage_layer_,latch_to_present_time_storage_layer_},
7153       {{},{},{},{},{},{},{},{},{},{},const_parent_->null_layers()[ColumnIndex::parent_id],{},const_parent_->null_layers()[ColumnIndex::thread_ts],const_parent_->null_layers()[ColumnIndex::thread_dur],const_parent_->null_layers()[ColumnIndex::thread_instruction_count],const_parent_->null_layers()[ColumnIndex::thread_instruction_delta],{},{},{},{},{}});
7154   }
7155   ~GraphicsFrameSliceTable() override;
7156 
Name()7157   static const char* Name() { return "frame_slice"; }
7158 
ComputeStaticSchema()7159   static Table::Schema ComputeStaticSchema() {
7160     Table::Schema schema;
7161     schema.columns.emplace_back(Table::Schema::Column{
7162         "id", SqlValue::Type::kLong, true, true, false, false});
7163     schema.columns.emplace_back(Table::Schema::Column{
7164         "type", SqlValue::Type::kString, false, false, false, false});
7165     schema.columns.emplace_back(Table::Schema::Column{
7166         "ts", ColumnType::ts::SqlValueType(), false,
7167         true,
7168         false,
7169         false});
7170     schema.columns.emplace_back(Table::Schema::Column{
7171         "dur", ColumnType::dur::SqlValueType(), false,
7172         false,
7173         false,
7174         false});
7175     schema.columns.emplace_back(Table::Schema::Column{
7176         "track_id", ColumnType::track_id::SqlValueType(), false,
7177         false,
7178         false,
7179         false});
7180     schema.columns.emplace_back(Table::Schema::Column{
7181         "category", ColumnType::category::SqlValueType(), false,
7182         false,
7183         false,
7184         false});
7185     schema.columns.emplace_back(Table::Schema::Column{
7186         "name", ColumnType::name::SqlValueType(), false,
7187         false,
7188         false,
7189         false});
7190     schema.columns.emplace_back(Table::Schema::Column{
7191         "depth", ColumnType::depth::SqlValueType(), false,
7192         false,
7193         false,
7194         false});
7195     schema.columns.emplace_back(Table::Schema::Column{
7196         "stack_id", ColumnType::stack_id::SqlValueType(), false,
7197         false,
7198         false,
7199         false});
7200     schema.columns.emplace_back(Table::Schema::Column{
7201         "parent_stack_id", ColumnType::parent_stack_id::SqlValueType(), false,
7202         false,
7203         false,
7204         false});
7205     schema.columns.emplace_back(Table::Schema::Column{
7206         "parent_id", ColumnType::parent_id::SqlValueType(), false,
7207         false,
7208         false,
7209         false});
7210     schema.columns.emplace_back(Table::Schema::Column{
7211         "arg_set_id", ColumnType::arg_set_id::SqlValueType(), false,
7212         false,
7213         false,
7214         false});
7215     schema.columns.emplace_back(Table::Schema::Column{
7216         "thread_ts", ColumnType::thread_ts::SqlValueType(), false,
7217         false,
7218         false,
7219         false});
7220     schema.columns.emplace_back(Table::Schema::Column{
7221         "thread_dur", ColumnType::thread_dur::SqlValueType(), false,
7222         false,
7223         false,
7224         false});
7225     schema.columns.emplace_back(Table::Schema::Column{
7226         "thread_instruction_count", ColumnType::thread_instruction_count::SqlValueType(), false,
7227         false,
7228         false,
7229         false});
7230     schema.columns.emplace_back(Table::Schema::Column{
7231         "thread_instruction_delta", ColumnType::thread_instruction_delta::SqlValueType(), false,
7232         false,
7233         false,
7234         false});
7235     schema.columns.emplace_back(Table::Schema::Column{
7236         "frame_number", ColumnType::frame_number::SqlValueType(), false,
7237         false,
7238         false,
7239         false});
7240     schema.columns.emplace_back(Table::Schema::Column{
7241         "layer_name", ColumnType::layer_name::SqlValueType(), false,
7242         false,
7243         false,
7244         false});
7245     schema.columns.emplace_back(Table::Schema::Column{
7246         "queue_to_acquire_time", ColumnType::queue_to_acquire_time::SqlValueType(), false,
7247         false,
7248         false,
7249         false});
7250     schema.columns.emplace_back(Table::Schema::Column{
7251         "acquire_to_latch_time", ColumnType::acquire_to_latch_time::SqlValueType(), false,
7252         false,
7253         false,
7254         false});
7255     schema.columns.emplace_back(Table::Schema::Column{
7256         "latch_to_present_time", ColumnType::latch_to_present_time::SqlValueType(), false,
7257         false,
7258         false,
7259         false});
7260     return schema;
7261   }
7262 
IterateRows()7263   ConstIterator IterateRows() const {
7264     return ConstIterator(this, Table::IterateRows());
7265   }
7266 
IterateRows()7267   Iterator IterateRows() { return Iterator(this, Table::IterateRows()); }
7268 
FilterToIterator(const Query & q)7269   ConstIterator FilterToIterator(const Query& q) const {
7270     return ConstIterator(this, QueryToIterator(q));
7271   }
7272 
FilterToIterator(const Query & q)7273   Iterator FilterToIterator(const Query& q) {
7274     return Iterator(this, QueryToIterator(q));
7275   }
7276 
ShrinkToFit()7277   void ShrinkToFit() {
7278     frame_number_.ShrinkToFit();
7279     layer_name_.ShrinkToFit();
7280     queue_to_acquire_time_.ShrinkToFit();
7281     acquire_to_latch_time_.ShrinkToFit();
7282     latch_to_present_time_.ShrinkToFit();
7283   }
7284 
7285   ConstRowReference operator[](uint32_t r) const {
7286     return ConstRowReference(this, r);
7287   }
7288   RowReference operator[](uint32_t r) { return RowReference(this, r); }
7289   ConstRowReference operator[](RowNumber r) const {
7290     return ConstRowReference(this, r.row_number());
7291   }
7292   RowReference operator[](RowNumber r) {
7293     return RowReference(this, r.row_number());
7294   }
7295 
FindById(Id find_id)7296   std::optional<ConstRowReference> FindById(Id find_id) const {
7297     std::optional<uint32_t> row = id().IndexOf(find_id);
7298     return row ? std::make_optional(ConstRowReference(this, *row))
7299                : std::nullopt;
7300   }
7301 
FindById(Id find_id)7302   std::optional<RowReference> FindById(Id find_id) {
7303     std::optional<uint32_t> row = id().IndexOf(find_id);
7304     return row ? std::make_optional(RowReference(this, *row)) : std::nullopt;
7305   }
7306 
Insert(const Row & row)7307   IdAndRow Insert(const Row& row) {
7308     uint32_t row_number = row_count();
7309     Id id = Id{parent_->Insert(row).id};
7310     UpdateOverlaysAfterParentInsert();
7311     mutable_frame_number()->Append(row.frame_number);
7312     mutable_layer_name()->Append(row.layer_name);
7313     mutable_queue_to_acquire_time()->Append(row.queue_to_acquire_time);
7314     mutable_acquire_to_latch_time()->Append(row.acquire_to_latch_time);
7315     mutable_latch_to_present_time()->Append(row.latch_to_present_time);
7316     UpdateSelfOverlayAfterInsert();
7317     return IdAndRow{id, row_number, RowReference(this, row_number),
7318                      RowNumber(row_number)};
7319   }
7320 
ExtendParent(const SliceTable & parent,ColumnStorage<ColumnType::frame_number::stored_type> frame_number,ColumnStorage<ColumnType::layer_name::stored_type> layer_name,ColumnStorage<ColumnType::queue_to_acquire_time::stored_type> queue_to_acquire_time,ColumnStorage<ColumnType::acquire_to_latch_time::stored_type> acquire_to_latch_time,ColumnStorage<ColumnType::latch_to_present_time::stored_type> latch_to_present_time)7321   static std::unique_ptr<GraphicsFrameSliceTable> ExtendParent(
7322       const SliceTable& parent,
7323       ColumnStorage<ColumnType::frame_number::stored_type> frame_number
7324 , ColumnStorage<ColumnType::layer_name::stored_type> layer_name
7325 , ColumnStorage<ColumnType::queue_to_acquire_time::stored_type> queue_to_acquire_time
7326 , ColumnStorage<ColumnType::acquire_to_latch_time::stored_type> acquire_to_latch_time
7327 , ColumnStorage<ColumnType::latch_to_present_time::stored_type> latch_to_present_time) {
7328     return std::unique_ptr<GraphicsFrameSliceTable>(new GraphicsFrameSliceTable(
7329         parent.string_pool(), parent, RowMap(0, parent.row_count()),
7330         std::move(frame_number), std::move(layer_name), std::move(queue_to_acquire_time), std::move(acquire_to_latch_time), std::move(latch_to_present_time)));
7331   }
7332 
SelectAndExtendParent(const SliceTable & parent,std::vector<SliceTable::RowNumber> parent_overlay,ColumnStorage<ColumnType::frame_number::stored_type> frame_number,ColumnStorage<ColumnType::layer_name::stored_type> layer_name,ColumnStorage<ColumnType::queue_to_acquire_time::stored_type> queue_to_acquire_time,ColumnStorage<ColumnType::acquire_to_latch_time::stored_type> acquire_to_latch_time,ColumnStorage<ColumnType::latch_to_present_time::stored_type> latch_to_present_time)7333   static std::unique_ptr<GraphicsFrameSliceTable> SelectAndExtendParent(
7334       const SliceTable& parent,
7335       std::vector<SliceTable::RowNumber> parent_overlay,
7336       ColumnStorage<ColumnType::frame_number::stored_type> frame_number
7337 , ColumnStorage<ColumnType::layer_name::stored_type> layer_name
7338 , ColumnStorage<ColumnType::queue_to_acquire_time::stored_type> queue_to_acquire_time
7339 , ColumnStorage<ColumnType::acquire_to_latch_time::stored_type> acquire_to_latch_time
7340 , ColumnStorage<ColumnType::latch_to_present_time::stored_type> latch_to_present_time) {
7341     std::vector<uint32_t> prs_untyped(parent_overlay.size());
7342     for (uint32_t i = 0; i < parent_overlay.size(); ++i) {
7343       prs_untyped[i] = parent_overlay[i].row_number();
7344     }
7345     return std::unique_ptr<GraphicsFrameSliceTable>(new GraphicsFrameSliceTable(
7346         parent.string_pool(), parent, RowMap(std::move(prs_untyped)),
7347         std::move(frame_number), std::move(layer_name), std::move(queue_to_acquire_time), std::move(acquire_to_latch_time), std::move(latch_to_present_time)));
7348   }
7349 
id()7350   const IdColumn<GraphicsFrameSliceTable::Id>& id() const {
7351     return static_cast<const ColumnType::id&>(columns()[ColumnIndex::id]);
7352   }
type()7353   const TypedColumn<StringPool::Id>& type() const {
7354     return static_cast<const ColumnType::type&>(columns()[ColumnIndex::type]);
7355   }
ts()7356   const TypedColumn<int64_t>& ts() const {
7357     return static_cast<const ColumnType::ts&>(columns()[ColumnIndex::ts]);
7358   }
dur()7359   const TypedColumn<int64_t>& dur() const {
7360     return static_cast<const ColumnType::dur&>(columns()[ColumnIndex::dur]);
7361   }
track_id()7362   const TypedColumn<TrackTable::Id>& track_id() const {
7363     return static_cast<const ColumnType::track_id&>(columns()[ColumnIndex::track_id]);
7364   }
category()7365   const TypedColumn<std::optional<StringPool::Id>>& category() const {
7366     return static_cast<const ColumnType::category&>(columns()[ColumnIndex::category]);
7367   }
name()7368   const TypedColumn<std::optional<StringPool::Id>>& name() const {
7369     return static_cast<const ColumnType::name&>(columns()[ColumnIndex::name]);
7370   }
depth()7371   const TypedColumn<uint32_t>& depth() const {
7372     return static_cast<const ColumnType::depth&>(columns()[ColumnIndex::depth]);
7373   }
stack_id()7374   const TypedColumn<int64_t>& stack_id() const {
7375     return static_cast<const ColumnType::stack_id&>(columns()[ColumnIndex::stack_id]);
7376   }
parent_stack_id()7377   const TypedColumn<int64_t>& parent_stack_id() const {
7378     return static_cast<const ColumnType::parent_stack_id&>(columns()[ColumnIndex::parent_stack_id]);
7379   }
parent_id()7380   const TypedColumn<std::optional<GraphicsFrameSliceTable::Id>>& parent_id() const {
7381     return static_cast<const ColumnType::parent_id&>(columns()[ColumnIndex::parent_id]);
7382   }
arg_set_id()7383   const TypedColumn<uint32_t>& arg_set_id() const {
7384     return static_cast<const ColumnType::arg_set_id&>(columns()[ColumnIndex::arg_set_id]);
7385   }
thread_ts()7386   const TypedColumn<std::optional<int64_t>>& thread_ts() const {
7387     return static_cast<const ColumnType::thread_ts&>(columns()[ColumnIndex::thread_ts]);
7388   }
thread_dur()7389   const TypedColumn<std::optional<int64_t>>& thread_dur() const {
7390     return static_cast<const ColumnType::thread_dur&>(columns()[ColumnIndex::thread_dur]);
7391   }
thread_instruction_count()7392   const TypedColumn<std::optional<int64_t>>& thread_instruction_count() const {
7393     return static_cast<const ColumnType::thread_instruction_count&>(columns()[ColumnIndex::thread_instruction_count]);
7394   }
thread_instruction_delta()7395   const TypedColumn<std::optional<int64_t>>& thread_instruction_delta() const {
7396     return static_cast<const ColumnType::thread_instruction_delta&>(columns()[ColumnIndex::thread_instruction_delta]);
7397   }
frame_number()7398   const TypedColumn<uint32_t>& frame_number() const {
7399     return static_cast<const ColumnType::frame_number&>(columns()[ColumnIndex::frame_number]);
7400   }
layer_name()7401   const TypedColumn<StringPool::Id>& layer_name() const {
7402     return static_cast<const ColumnType::layer_name&>(columns()[ColumnIndex::layer_name]);
7403   }
queue_to_acquire_time()7404   const TypedColumn<int64_t>& queue_to_acquire_time() const {
7405     return static_cast<const ColumnType::queue_to_acquire_time&>(columns()[ColumnIndex::queue_to_acquire_time]);
7406   }
acquire_to_latch_time()7407   const TypedColumn<int64_t>& acquire_to_latch_time() const {
7408     return static_cast<const ColumnType::acquire_to_latch_time&>(columns()[ColumnIndex::acquire_to_latch_time]);
7409   }
latch_to_present_time()7410   const TypedColumn<int64_t>& latch_to_present_time() const {
7411     return static_cast<const ColumnType::latch_to_present_time&>(columns()[ColumnIndex::latch_to_present_time]);
7412   }
7413 
mutable_ts()7414   TypedColumn<int64_t>* mutable_ts() {
7415     return static_cast<ColumnType::ts*>(
7416         GetColumn(ColumnIndex::ts));
7417   }
mutable_dur()7418   TypedColumn<int64_t>* mutable_dur() {
7419     return static_cast<ColumnType::dur*>(
7420         GetColumn(ColumnIndex::dur));
7421   }
mutable_track_id()7422   TypedColumn<TrackTable::Id>* mutable_track_id() {
7423     return static_cast<ColumnType::track_id*>(
7424         GetColumn(ColumnIndex::track_id));
7425   }
mutable_category()7426   TypedColumn<std::optional<StringPool::Id>>* mutable_category() {
7427     return static_cast<ColumnType::category*>(
7428         GetColumn(ColumnIndex::category));
7429   }
mutable_name()7430   TypedColumn<std::optional<StringPool::Id>>* mutable_name() {
7431     return static_cast<ColumnType::name*>(
7432         GetColumn(ColumnIndex::name));
7433   }
mutable_depth()7434   TypedColumn<uint32_t>* mutable_depth() {
7435     return static_cast<ColumnType::depth*>(
7436         GetColumn(ColumnIndex::depth));
7437   }
mutable_stack_id()7438   TypedColumn<int64_t>* mutable_stack_id() {
7439     return static_cast<ColumnType::stack_id*>(
7440         GetColumn(ColumnIndex::stack_id));
7441   }
mutable_parent_stack_id()7442   TypedColumn<int64_t>* mutable_parent_stack_id() {
7443     return static_cast<ColumnType::parent_stack_id*>(
7444         GetColumn(ColumnIndex::parent_stack_id));
7445   }
mutable_parent_id()7446   TypedColumn<std::optional<GraphicsFrameSliceTable::Id>>* mutable_parent_id() {
7447     return static_cast<ColumnType::parent_id*>(
7448         GetColumn(ColumnIndex::parent_id));
7449   }
mutable_arg_set_id()7450   TypedColumn<uint32_t>* mutable_arg_set_id() {
7451     return static_cast<ColumnType::arg_set_id*>(
7452         GetColumn(ColumnIndex::arg_set_id));
7453   }
mutable_thread_ts()7454   TypedColumn<std::optional<int64_t>>* mutable_thread_ts() {
7455     return static_cast<ColumnType::thread_ts*>(
7456         GetColumn(ColumnIndex::thread_ts));
7457   }
mutable_thread_dur()7458   TypedColumn<std::optional<int64_t>>* mutable_thread_dur() {
7459     return static_cast<ColumnType::thread_dur*>(
7460         GetColumn(ColumnIndex::thread_dur));
7461   }
mutable_thread_instruction_count()7462   TypedColumn<std::optional<int64_t>>* mutable_thread_instruction_count() {
7463     return static_cast<ColumnType::thread_instruction_count*>(
7464         GetColumn(ColumnIndex::thread_instruction_count));
7465   }
mutable_thread_instruction_delta()7466   TypedColumn<std::optional<int64_t>>* mutable_thread_instruction_delta() {
7467     return static_cast<ColumnType::thread_instruction_delta*>(
7468         GetColumn(ColumnIndex::thread_instruction_delta));
7469   }
mutable_frame_number()7470   TypedColumn<uint32_t>* mutable_frame_number() {
7471     return static_cast<ColumnType::frame_number*>(
7472         GetColumn(ColumnIndex::frame_number));
7473   }
mutable_layer_name()7474   TypedColumn<StringPool::Id>* mutable_layer_name() {
7475     return static_cast<ColumnType::layer_name*>(
7476         GetColumn(ColumnIndex::layer_name));
7477   }
mutable_queue_to_acquire_time()7478   TypedColumn<int64_t>* mutable_queue_to_acquire_time() {
7479     return static_cast<ColumnType::queue_to_acquire_time*>(
7480         GetColumn(ColumnIndex::queue_to_acquire_time));
7481   }
mutable_acquire_to_latch_time()7482   TypedColumn<int64_t>* mutable_acquire_to_latch_time() {
7483     return static_cast<ColumnType::acquire_to_latch_time*>(
7484         GetColumn(ColumnIndex::acquire_to_latch_time));
7485   }
mutable_latch_to_present_time()7486   TypedColumn<int64_t>* mutable_latch_to_present_time() {
7487     return static_cast<ColumnType::latch_to_present_time*>(
7488         GetColumn(ColumnIndex::latch_to_present_time));
7489   }
7490 
7491  private:
GraphicsFrameSliceTable(StringPool * pool,const SliceTable & parent,const RowMap & parent_overlay,ColumnStorage<ColumnType::frame_number::stored_type> frame_number,ColumnStorage<ColumnType::layer_name::stored_type> layer_name,ColumnStorage<ColumnType::queue_to_acquire_time::stored_type> queue_to_acquire_time,ColumnStorage<ColumnType::acquire_to_latch_time::stored_type> acquire_to_latch_time,ColumnStorage<ColumnType::latch_to_present_time::stored_type> latch_to_present_time)7492   GraphicsFrameSliceTable(StringPool* pool,
7493             const SliceTable& parent,
7494             const RowMap& parent_overlay,
7495             ColumnStorage<ColumnType::frame_number::stored_type> frame_number
7496 , ColumnStorage<ColumnType::layer_name::stored_type> layer_name
7497 , ColumnStorage<ColumnType::queue_to_acquire_time::stored_type> queue_to_acquire_time
7498 , ColumnStorage<ColumnType::acquire_to_latch_time::stored_type> acquire_to_latch_time
7499 , ColumnStorage<ColumnType::latch_to_present_time::stored_type> latch_to_present_time)
7500       : macros_internal::MacroTable(
7501           pool,
7502           GetColumns(this, &parent),
7503           parent,
7504           parent_overlay),
7505           const_parent_(&parent)
7506 ,
7507         frame_number_storage_layer_(
7508         new column::NumericStorage<ColumnType::frame_number::non_optional_stored_type>(
7509           &frame_number_.vector(),
7510           ColumnTypeHelper<ColumnType::frame_number::stored_type>::ToColumnType(),
7511           false)),
7512         layer_name_storage_layer_(
7513           new column::StringStorage(string_pool(), &layer_name_.vector())),
7514         queue_to_acquire_time_storage_layer_(
7515         new column::NumericStorage<ColumnType::queue_to_acquire_time::non_optional_stored_type>(
7516           &queue_to_acquire_time_.vector(),
7517           ColumnTypeHelper<ColumnType::queue_to_acquire_time::stored_type>::ToColumnType(),
7518           false)),
7519         acquire_to_latch_time_storage_layer_(
7520         new column::NumericStorage<ColumnType::acquire_to_latch_time::non_optional_stored_type>(
7521           &acquire_to_latch_time_.vector(),
7522           ColumnTypeHelper<ColumnType::acquire_to_latch_time::stored_type>::ToColumnType(),
7523           false)),
7524         latch_to_present_time_storage_layer_(
7525         new column::NumericStorage<ColumnType::latch_to_present_time::non_optional_stored_type>(
7526           &latch_to_present_time_.vector(),
7527           ColumnTypeHelper<ColumnType::latch_to_present_time::stored_type>::ToColumnType(),
7528           false))
7529          {
7530     static_assert(
7531         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::frame_number::stored_type>(
7532           ColumnFlag::frame_number),
7533         "Column type and flag combination is not valid");
7534       static_assert(
7535         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::layer_name::stored_type>(
7536           ColumnFlag::layer_name),
7537         "Column type and flag combination is not valid");
7538       static_assert(
7539         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::queue_to_acquire_time::stored_type>(
7540           ColumnFlag::queue_to_acquire_time),
7541         "Column type and flag combination is not valid");
7542       static_assert(
7543         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::acquire_to_latch_time::stored_type>(
7544           ColumnFlag::acquire_to_latch_time),
7545         "Column type and flag combination is not valid");
7546       static_assert(
7547         ColumnLegacy::IsFlagsAndTypeValid<ColumnType::latch_to_present_time::stored_type>(
7548           ColumnFlag::latch_to_present_time),
7549         "Column type and flag combination is not valid");
7550     PERFETTO_DCHECK(frame_number.size() == parent_overlay.size());
7551     frame_number_ = std::move(frame_number);
7552     PERFETTO_DCHECK(layer_name.size() == parent_overlay.size());
7553     layer_name_ = std::move(layer_name);
7554     PERFETTO_DCHECK(queue_to_acquire_time.size() == parent_overlay.size());
7555     queue_to_acquire_time_ = std::move(queue_to_acquire_time);
7556     PERFETTO_DCHECK(acquire_to_latch_time.size() == parent_overlay.size());
7557     acquire_to_latch_time_ = std::move(acquire_to_latch_time);
7558     PERFETTO_DCHECK(latch_to_present_time.size() == parent_overlay.size());
7559     latch_to_present_time_ = std::move(latch_to_present_time);
7560 
7561     std::vector<RefPtr<column::OverlayLayer>> overlay_layers(OverlayCount(&parent) + 1);
7562     for (uint32_t i = 0; i < overlay_layers.size(); ++i) {
7563       if (overlays()[i].row_map().IsIndexVector()) {
7564         overlay_layers[i].reset(new column::ArrangementOverlay(
7565             overlays()[i].row_map().GetIfIndexVector(),
7566             column::DataLayerChain::Indices::State::kNonmonotonic));
7567       } else if (overlays()[i].row_map().IsBitVector()) {
7568         overlay_layers[i].reset(new column::SelectorOverlay(
7569             overlays()[i].row_map().GetIfBitVector()));
7570       } else if (overlays()[i].row_map().IsRange()) {
7571         overlay_layers[i].reset(new column::RangeOverlay(
7572             overlays()[i].row_map().GetIfIRange()));
7573       }
7574     }
7575 
7576     OnConstructionCompleted(
7577       {const_parent_->storage_layers()[ColumnIndex::id],const_parent_->storage_layers()[ColumnIndex::type],const_parent_->storage_layers()[ColumnIndex::ts],const_parent_->storage_layers()[ColumnIndex::dur],const_parent_->storage_layers()[ColumnIndex::track_id],const_parent_->storage_layers()[ColumnIndex::category],const_parent_->storage_layers()[ColumnIndex::name],const_parent_->storage_layers()[ColumnIndex::depth],const_parent_->storage_layers()[ColumnIndex::stack_id],const_parent_->storage_layers()[ColumnIndex::parent_stack_id],const_parent_->storage_layers()[ColumnIndex::parent_id],const_parent_->storage_layers()[ColumnIndex::arg_set_id],const_parent_->storage_layers()[ColumnIndex::thread_ts],const_parent_->storage_layers()[ColumnIndex::thread_dur],const_parent_->storage_layers()[ColumnIndex::thread_instruction_count],const_parent_->storage_layers()[ColumnIndex::thread_instruction_delta],frame_number_storage_layer_,layer_name_storage_layer_,queue_to_acquire_time_storage_layer_,acquire_to_latch_time_storage_layer_,latch_to_present_time_storage_layer_}, {{},{},{},{},{},{},{},{},{},{},const_parent_->null_layers()[ColumnIndex::parent_id],{},const_parent_->null_layers()[ColumnIndex::thread_ts],const_parent_->null_layers()[ColumnIndex::thread_dur],const_parent_->null_layers()[ColumnIndex::thread_instruction_count],const_parent_->null_layers()[ColumnIndex::thread_instruction_delta],{},{},{},{},{}}, std::move(overlay_layers));
7578   }
7579   SliceTable* parent_ = nullptr;
7580   const SliceTable* const_parent_ = nullptr;
7581   ColumnStorage<ColumnType::frame_number::stored_type> frame_number_;
7582   ColumnStorage<ColumnType::layer_name::stored_type> layer_name_;
7583   ColumnStorage<ColumnType::queue_to_acquire_time::stored_type> queue_to_acquire_time_;
7584   ColumnStorage<ColumnType::acquire_to_latch_time::stored_type> acquire_to_latch_time_;
7585   ColumnStorage<ColumnType::latch_to_present_time::stored_type> latch_to_present_time_;
7586 
7587   RefPtr<column::StorageLayer> frame_number_storage_layer_;
7588   RefPtr<column::StorageLayer> layer_name_storage_layer_;
7589   RefPtr<column::StorageLayer> queue_to_acquire_time_storage_layer_;
7590   RefPtr<column::StorageLayer> acquire_to_latch_time_storage_layer_;
7591   RefPtr<column::StorageLayer> latch_to_present_time_storage_layer_;
7592 
7593 
7594 };
7595 
7596 }  // namespace perfetto
7597 
7598 #endif  // SRC_TRACE_PROCESSOR_TABLES_SLICE_TABLES_PY_H_
7599