+ def _compute_stream_intersections(self):
+ # Pre-compute the trimmer range to use for each port in the graph, when
+ # stream intersection mode is enabled.
+ self._stream_inter_port_to_range = {}
+
+ for src_comp_and_spec in self._src_comps_and_specs:
+ # query the port's component for the `babeltrace.trace-info`
+ # object which contains the range for each stream, from which we can
+ # compute the intersection of the streams in each trace.
+ query_exec = bt2.QueryExecutor(
+ src_comp_and_spec.spec.component_class,
+ 'babeltrace.trace-info',
+ src_comp_and_spec.spec.params,
+ )
+ trace_infos = query_exec.query()
+
+ for trace_info in trace_infos:
+ begin = max(
+ [stream['range-ns']['begin'] for stream in trace_info['streams']]
+ )
+ end = min(
+ [stream['range-ns']['end'] for stream in trace_info['streams']]
+ )
+
+ # Each port associated to this trace will have this computed
+ # range.
+ for stream in trace_info['streams']:
+ # A port name is unique within a component, but not
+ # necessarily across all components. Use a component
+ # and port name pair to make it unique across the graph.
+ port_name = str(stream['port-name'])
+ key = (src_comp_and_spec.comp.addr, port_name)
+ self._stream_inter_port_to_range[key] = (begin, end)
+