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_PRELUDE_TABLE_FUNCTIONS_CONNECTED_FLOW_H_ 18 #define SRC_TRACE_PROCESSOR_PRELUDE_TABLE_FUNCTIONS_CONNECTED_FLOW_H_ 19 20 #include "src/trace_processor/prelude/table_functions/table_function.h" 21 #include "src/trace_processor/prelude/table_functions/tables_py.h" 22 #include "src/trace_processor/storage/trace_storage.h" 23 24 #include <queue> 25 #include <set> 26 27 namespace perfetto { 28 namespace trace_processor { 29 30 class TraceProcessorContext; 31 32 // Implementation of tables: 33 // - DIRECTLY_CONNECTED_FLOW 34 // - PRECEDING_FLOW 35 // - FOLLOWING_FLOW 36 class ConnectedFlow : public TableFunction { 37 public: 38 enum class Mode { 39 // Directly connected slices through the same flow ID given by the trace 40 // writer. 41 kDirectlyConnectedFlow, 42 // Flow events which can be reached from the given slice by going over 43 // incoming flow events or to parent slices. 44 kPrecedingFlow, 45 // Flow events which can be reached from the given slice by going over 46 // outgoing flow events or to child slices. 47 kFollowingFlow, 48 }; 49 50 ConnectedFlow(Mode mode, const TraceStorage*); 51 ~ConnectedFlow() override; 52 53 Table::Schema CreateSchema() override; 54 std::string TableName() override; 55 uint32_t EstimateRowCount() override; 56 base::Status ValidateConstraints(const QueryConstraints&) override; 57 base::Status ComputeTable(const std::vector<Constraint>& cs, 58 const std::vector<Order>& ob, 59 const BitVector& cols_used, 60 std::unique_ptr<Table>& table_return) override; 61 62 private: 63 Mode mode_; 64 const TraceStorage* storage_ = nullptr; 65 }; 66 67 } // namespace trace_processor 68 } // namespace perfetto 69 70 #endif // SRC_TRACE_PROCESSOR_PRELUDE_TABLE_FUNCTIONS_CONNECTED_FLOW_H_ 71