shunping commented on code in PR #39487:
URL: https://github.com/apache/beam/pull/39487#discussion_r3679068286
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/DataflowOutputCounter.java:
##########
@@ -63,15 +101,42 @@ public void update(Object elem) throws Exception {
objectAndByteCounter.update(elem);
long windowsSize = ((WindowedValue<?>) elem).getWindows().size();
if (windowsSize == 0) {
- // GroupingShuffleReader produces ValueInEmptyWindows.
- // For now, we count the element at least once to keep the current
counter
- // behavior.
- elementCount.addValue(1L);
+ updateEmptyWindows((WindowedValue<?>) elem);
} else {
+ // Standard WindowedValue.
elementCount.addValue(windowsSize);
}
}
+ protected void updateEmptyWindows(WindowedValue<?> elem) {
Review Comment:
Done
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/DataflowOutputCounter.java:
##########
@@ -41,20 +42,57 @@ public class DataflowOutputCounter implements
ElementCounter {
private OutputObjectAndByteCounter objectAndByteCounter;
private Counter<Long, ?> elementCount;
+ private final boolean isStreaming;
+
+ public static DataflowOutputCounter create(
+ String outputName,
+ ElementByteSizeObservable<?> elementByteSizeObservable,
+ CounterFactory counterFactory,
+ NameContext nameContext,
+ boolean isStreaming) {
+ return new DataflowOutputCounter(
+ outputName, elementByteSizeObservable, counterFactory, nameContext,
isStreaming);
+ }
+
+ public static DataflowOutputCounter create(
+ String outputName,
+ CounterFactory counterFactory,
+ NameContext nameContext,
+ boolean isStreaming) {
+ return create(outputName, null, counterFactory, nameContext, isStreaming);
+ }
public DataflowOutputCounter(
String outputName, CounterFactory counterFactory, NameContext
nameContext) {
- this(outputName, null, counterFactory, nameContext);
+ this(outputName, null, counterFactory, nameContext, false);
+ }
+
+ public DataflowOutputCounter(
+ String outputName,
+ CounterFactory counterFactory,
+ NameContext nameContext,
+ boolean isStreaming) {
+ this(outputName, null, counterFactory, nameContext, isStreaming);
}
public DataflowOutputCounter(
String outputName,
ElementByteSizeObservable<?> elementByteSizeObservable,
CounterFactory counterFactory,
NameContext nameContext) {
- objectAndByteCounter =
+ this(outputName, elementByteSizeObservable, counterFactory, nameContext,
false);
+ }
+
+ public DataflowOutputCounter(
Review Comment:
Done
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]