• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef SRC_TRACE_PROCESSOR_ARGS_TABLE_H_
18 #define SRC_TRACE_PROCESSOR_ARGS_TABLE_H_
19 
20 #include "src/trace_processor/storage_table.h"
21 #include "src/trace_processor/trace_storage.h"
22 
23 namespace perfetto {
24 namespace trace_processor {
25 
26 class ArgsTable : public StorageTable {
27  public:
28   using VariadicType = TraceStorage::Args::Variadic::Type;
29 
30   static void RegisterTable(sqlite3* db, const TraceStorage* storage);
31 
32   ArgsTable(sqlite3*, const TraceStorage*);
33 
34   // StorageTable implementation.
35   StorageSchema CreateStorageSchema() override;
36   uint32_t RowCount() override;
37   int BestIndex(const QueryConstraints&, BestIndexInfo*) override;
38 
39  private:
40   class ValueColumn final : public StorageColumn {
41    public:
42     ValueColumn(std::string col_name,
43                 VariadicType type,
44                 const TraceStorage* storage);
45 
46     void ReportResult(sqlite3_context* ctx, uint32_t row) const override;
47 
48     Bounds BoundFilter(int op, sqlite3_value* sqlite_val) const override;
49 
50     void Filter(int op, sqlite3_value* value, FilteredRowIndex*) const override;
51 
52     Comparator Sort(const QueryConstraints::OrderBy& ob) const override;
53 
HasOrdering()54     bool HasOrdering() const override { return false; }
55 
GetType()56     Table::ColumnType GetType() const override {
57       switch (type_) {
58         case VariadicType::kInt:
59           return Table::ColumnType::kLong;
60         case VariadicType::kReal:
61           return Table::ColumnType::kDouble;
62         case VariadicType::kString:
63           return Table::ColumnType::kString;
64       }
65       PERFETTO_FATAL("Not reached");  // For gcc
66     }
67 
68    private:
69     int CompareRefsAsc(uint32_t f, uint32_t s) const;
70 
71     TraceStorage::Args::Variadic::Type type_;
72     const TraceStorage* storage_ = nullptr;
73   };
74 
75   const TraceStorage* const storage_;
76 };
77 
78 }  // namespace trace_processor
79 }  // namespace perfetto
80 
81 #endif  // SRC_TRACE_PROCESSOR_ARGS_TABLE_H_
82