1 /* 2 * Copyright (C) 2020 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_PERFETTO_SQL_INTRINSICS_TABLE_FUNCTIONS_EXPERIMENTAL_SCHED_UPID_H_ 18 #define SRC_TRACE_PROCESSOR_PERFETTO_SQL_INTRINSICS_TABLE_FUNCTIONS_EXPERIMENTAL_SCHED_UPID_H_ 19 20 #include <cstdint> 21 #include <memory> 22 #include <optional> 23 #include <string> 24 #include <vector> 25 26 #include "perfetto/ext/base/status_or.h" 27 #include "perfetto/trace_processor/basic_types.h" 28 #include "src/trace_processor/db/column_storage.h" 29 #include "src/trace_processor/db/table.h" 30 #include "src/trace_processor/perfetto_sql/intrinsics/table_functions/static_table_function.h" 31 #include "src/trace_processor/storage/trace_storage.h" 32 #include "src/trace_processor/tables/metadata_tables_py.h" 33 #include "src/trace_processor/tables/sched_tables_py.h" 34 35 namespace perfetto::trace_processor { 36 37 class ExperimentalSchedUpid : public StaticTableFunction { 38 public: 39 ExperimentalSchedUpid(const tables::SchedSliceTable&, 40 const tables::ThreadTable&); 41 virtual ~ExperimentalSchedUpid() override; 42 43 Table::Schema CreateSchema() override; 44 std::string TableName() override; 45 uint32_t EstimateRowCount() override; 46 base::StatusOr<std::unique_ptr<Table>> ComputeTable( 47 const std::vector<SqlValue>& arguments) override; 48 49 private: 50 ColumnStorage<std::optional<UniquePid>> ComputeUpidColumn(); 51 52 const tables::SchedSliceTable* sched_slice_table_; 53 const tables::ThreadTable* thread_table_; 54 std::unique_ptr<Table> sched_upid_table_; 55 }; 56 57 } // namespace perfetto::trace_processor 58 59 #endif // SRC_TRACE_PROCESSOR_PERFETTO_SQL_INTRINSICS_TABLE_FUNCTIONS_EXPERIMENTAL_SCHED_UPID_H_ 60