[GitHub] [flink] liming30 commented on a change in pull request #13109: [FLINK-18808][runtime/metrics] Include side outputs in numRecordsOut metric.

2020-08-27 Thread GitBox


liming30 commented on a change in pull request #13109:
URL: https://github.com/apache/flink/pull/13109#discussion_r478836972



##
File path: 
flink-streaming-java/src/main/java/org/apache/flink/streaming/api/collector/selector/DirectedOutputsCollector.java
##
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+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  The type of the elements that can be emitted.
+ */
+public class DirectedOutputsCollector implements 
SelectedOutputsCollector {
+
+   private final Output>[] selectAllOutputs;
+   private final Map>[]> outputMap;
+
+   public DirectedOutputsCollector(
+   Output>[] selectAllOutputs,
+   Map>[]> outputMap) {
+   this.selectAllOutputs = selectAllOutputs;
+   this.outputMap = outputMap;
+   }
+
+   @Override
+   public boolean collect(Iterable outputNames, StreamRecord 
record) {
+   boolean emitted = false;
+
+   if (selectAllOutputs.length > 0) {
+   collect(selectAllOutputs, record);
+   emitted = true;
+   }
+
+   for (String outputName : outputNames) {
+   Output>[] 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




[GitHub] [flink] liming30 commented on a change in pull request #13109: [FLINK-18808][runtime/metrics] Include side outputs in numRecordsOut metric.

2020-08-27 Thread GitBox


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  The type of the elements that can be emitted.
+ */
+public class SelectedOutputsCollectorImpl implements 
SelectedOutputsCollector {
+
+   private final Output>[] selectAllOutputs;
+   private final Map>[]> outputMap;
+
+   private final boolean objectReuse;
+
+   public SelectedOutputsCollectorImpl(
+   Output>[] selectAllOutputs,
+   Map>[]> outputMap,
+   boolean objectReuse) {
+   this.selectAllOutputs = selectAllOutputs;
+   this.outputMap = outputMap;
+   this.objectReuse = objectReuse;
+   }
+
+   @Override
+   public boolean collect(Iterable outputNames, StreamRecord 
record) {
+   boolean emitted = false;
+
+   if (selectAllOutputs.length > 0) {
+   collect(selectAllOutputs, record);
+   emitted = true;
+   }
+
+   for (String outputName : outputNames) {
+   Output>[] 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




[GitHub] [flink] liming30 commented on a change in pull request #13109: [FLINK-18808][runtime/metrics] Include side outputs in numRecordsOut metric.

2020-08-27 Thread GitBox


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  The type of the elements that can be emitted.
+ */
+public class SelectedOutputsCollectorImpl implements 
SelectedOutputsCollector {
+
+   private final Output>[] selectAllOutputs;
+   private final Map>[]> outputMap;
+
+   private final boolean objectReuse;
+
+   public SelectedOutputsCollectorImpl(
+   Output>[] selectAllOutputs,
+   Map>[]> outputMap,
+   boolean objectReuse) {
+   this.selectAllOutputs = selectAllOutputs;
+   this.outputMap = outputMap;
+   this.objectReuse = objectReuse;
+   }
+
+   @Override
+   public boolean collect(Iterable outputNames, StreamRecord 
record) {
+   boolean emitted = false;
+
+   if (selectAllOutputs.length > 0) {
+   collect(selectAllOutputs, record);
+   emitted = true;
+   }
+
+   for (String outputName : outputNames) {
+   Output>[] 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




[GitHub] [flink] liming30 commented on a change in pull request #13109: [FLINK-18808][runtime/metrics] Include side outputs in numRecordsOut metric.

2020-08-27 Thread GitBox


liming30 commented on a change in pull request #13109:
URL: https://github.com/apache/flink/pull/13109#discussion_r478424895



##
File path: 
flink-streaming-java/src/main/java/org/apache/flink/streaming/api/collector/selector/SelectedOutputsCollectorImpl.java
##
@@ -0,0 +1,62 @@
+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  The type of the elements that can be emitted.
+ */
+public class SelectedOutputsCollectorImpl implements 
SelectedOutputsCollector {
+
+   private final Output>[] selectAllOutputs;
+   private final Map>[]> outputMap;
+
+   private final boolean objectReuse;
+
+   public SelectedOutputsCollectorImpl(
+   Output>[] selectAllOutputs,
+   Map>[]> outputMap,
+   boolean objectReuse) {
+   this.selectAllOutputs = selectAllOutputs;
+   this.outputMap = outputMap;
+   this.objectReuse = objectReuse;
+   }
+
+   @Override
+   public boolean collect(Iterable outputNames, StreamRecord 
record) {
+   boolean emitted = false;
+
+   if (selectAllOutputs.length > 0) {
+   collect(selectAllOutputs, 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




[GitHub] [flink] liming30 commented on a change in pull request #13109: [FLINK-18808][runtime/metrics] Include side outputs in numRecordsOut metric.

2020-08-26 Thread GitBox


liming30 commented on a change in pull request #13109:
URL: https://github.com/apache/flink/pull/13109#discussion_r477242251



##
File path: 
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/OperatorChain.java
##
@@ -739,40 +749,59 @@ public void collect(StreamRecord record) {
 
static class BroadcastingOutputCollector implements 
WatermarkGaugeExposingOutput> {

Review comment:
   Okay, I will rebase on it.





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




[GitHub] [flink] liming30 commented on a change in pull request #13109: [FLINK-18808][runtime/metrics] Include side outputs in numRecordsOut metric.

2020-08-26 Thread GitBox


liming30 commented on a change in pull request #13109:
URL: https://github.com/apache/flink/pull/13109#discussion_r477237731



##
File path: 
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/OperatorChain.java
##
@@ -409,7 +410,7 @@ public OP getHeadOperator() {
 
if (selectors == null || selectors.isEmpty()) {
// simple path, no selector necessary
-   if (allOutputs.size() == 1) {
+   if (allOutputs.size() == 1 && !(allOutputs.get(0).f0 
instanceof RecordWriterOutput)) {

Review comment:
   If we use `CountingOutput` directly, we can’t distinguish whether the 
record is actually sent (just like it was filtered by `OutputTag` in 
`sideOutput`)





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




[GitHub] [flink] liming30 commented on a change in pull request #13109: [FLINK-18808][runtime/metrics] Include side outputs in numRecordsOut metric.

2020-08-26 Thread GitBox


liming30 commented on a change in pull request #13109:
URL: https://github.com/apache/flink/pull/13109#discussion_r477235414



##
File path: 
flink-streaming-java/src/main/java/org/apache/flink/streaming/api/collector/selector/CopyingDirectedOutput.java
##
@@ -36,31 +38,56 @@
@SuppressWarnings({"unchecked", "rawtypes"})
public CopyingDirectedOutput(
List> outputSelectors,
-   List>, StreamEdge>> outputs) {
-   super(outputSelectors, outputs);
+   List>, StreamEdge>> outputs,
+   Counter numRecordsOutForTask) {
+   super(outputSelectors, outputs, numRecordsOutForTask);
}
 
@Override
public void collect(StreamRecord record) {
-   Set>> selectedOutputs = 
selectOutputs(record);
+   Tuple2>, 
Set>>> selectedOutputs = selectOutputs(record);

Review comment:
   Ok, I will modify this implementation by adding the 
`SelectedOutputsCollector` interface in the next submission.





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