arunpandianp commented on code in PR #39961:
URL: https://github.com/apache/beam/pull/39961#discussion_r4045444427
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/PubsubSink.java:
##########
@@ -187,18 +190,31 @@ public long add(WindowedValue<T> data) throws IOException
{
return byteString.size();
}
+ private void flush(boolean bundleLevel) {
+ try {
+ Windmill.PubSubMessageBundle pubsubMessages = outputBuilder.build();
+ if (pubsubMessages.getMessagesCount() > 0) {
+ if (bundleLevel) {
+ // If/when we add support for ordering keys, the flush needs to
happen at the key level
+ context.addBundlePubsubMessages(pubsubMessages);
+ } else {
+ context.getOutputBuilder().addPubsubMessages(pubsubMessages);
+ }
+ }
+ } finally {
+ outputBuilder = createOutputBuilder();
Review Comment:
Yes, WriteOperation calls sink.writer() per bundle and PubsubSink.writer()
creates a new writer.
https://github.com/apache/beam/blob/73bb356a40861f9e9ee17afce1b13659e3ecec9c/runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/util/common/worker/WriteOperation.java#L72
+1 to reusing them, I'll file a bug to reuse the streaming sinks across
bundles.
--
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]