/* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef SRC_TRACE_PROCESSOR_PERFETTO_SQL_INTRINSICS_OPERATORS_SPAN_JOIN_OPERATOR_H_ #define SRC_TRACE_PROCESSOR_PERFETTO_SQL_INTRINSICS_OPERATORS_SPAN_JOIN_OPERATOR_H_ #include <cstddef> #include <cstdint> #include <limits> #include <optional> #include <string> #include <utility> #include <vector> #include "perfetto/base/logging.h" #include "perfetto/base/status.h" #include "perfetto/ext/base/flat_hash_map.h" #include "perfetto/ext/base/string_splitter.h" #include "perfetto/ext/base/string_utils.h" #include "perfetto/trace_processor/basic_types.h" #include "src/trace_processor/sqlite/bindings/sqlite_module.h" #include "src/trace_processor/sqlite/module_lifecycle_manager.h" #include "src/trace_processor/sqlite/sqlite_engine.h" namespace perfetto::trace_processor { class PerfettoSqlEngine; struct SpanJoinOperatorModule; // Implements the SPAN JOIN operation between two tables on a particular column. // // Span: // A span is a row with a timestamp and a duration. It is used to model // operations which run for a particular *span* of time. // // We draw spans like so (time on the x-axis): // start of span->[ time where opertion is running ]<- end of span // // Multiple spans can happen in parallel: // [ ] // [ ] // [ ] // [ ] // // The above for example, models scheduling activity on a 4-core computer for a // short period of time. // // Span join: // The span join operation can be thought of as the intersection of span tables. // That is, the join table has a span for each pair of spans in the child tables // where the spans overlap. Because many spans are possible in parallel, an // extra metadata column (labelled the "join column") is used to distinguish // between the spanned tables. // // For a given join key suppose these were the two span tables: // Table 1: [ ] [ ] [ ] // Table 2: [ ] [ ] [ ] // Output : [ ] [ ] [] // // All other columns apart from timestamp (ts), duration (dur) and the join key // are passed through unchanged. struct SpanJoinOperatorModule : public sqlite::Module<SpanJoinOperatorModule> { … }; } // namespace perfetto::trace_processor #endif // SRC_TRACE_PROCESSOR_PERFETTO_SQL_INTRINSICS_OPERATORS_SPAN_JOIN_OPERATOR_H_