liming30 commented on a change in pull request #13109: URL: https://github.com/apache/flink/pull/13109#discussion_r478431177
########## File path: flink-streaming-java/src/main/java/org/apache/flink/streaming/api/collector/selector/SelectedOutputsCollectorImpl.java ########## @@ -0,0 +1,61 @@ +package org.apache.flink.streaming.api.collector.selector; + +import org.apache.flink.streaming.api.operators.Output; +import org.apache.flink.streaming.runtime.streamrecord.StreamRecord; + +import java.util.Map; + +/** + * The selected outputs collector will send records to the default output, + * and output matching outputNames. + * + * @param <T> The type of the elements that can be emitted. + */ +public class SelectedOutputsCollectorImpl<T> implements SelectedOutputsCollector<T> { + + private final Output<StreamRecord<T>>[] selectAllOutputs; + private final Map<String, Output<StreamRecord<T>>[]> outputMap; + + private final boolean objectReuse; + + public SelectedOutputsCollectorImpl( + Output<StreamRecord<T>>[] selectAllOutputs, + Map<String, Output<StreamRecord<T>>[]> outputMap, + boolean objectReuse) { + this.selectAllOutputs = selectAllOutputs; + this.outputMap = outputMap; + this.objectReuse = objectReuse; + } + + @Override + public boolean collect(Iterable<String> outputNames, StreamRecord<T> record) { + boolean emitted = false; + + if (selectAllOutputs.length > 0) { + collect(selectAllOutputs, record); + emitted = true; + } + + for (String outputName : outputNames) { + Output<StreamRecord<T>>[] outputList = outputMap.get(outputName); + if (outputList != null && outputList.length > 0) { + collect(outputList, record); + emitted = true; + } + } Review comment: In the old implementation via `set`, even if the same `output` appears multiple times in `outputNames`, it will only be sent once. Now it will send multiple times and I am not sure if this behavior is correct. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org