xinyuiscool commented on code in PR #23313:
URL: https://github.com/apache/beam/pull/23313#discussion_r980575683


##########
runners/samza/src/main/java/org/apache/beam/runners/samza/runtime/OpAdapter.java:
##########
@@ -188,7 +176,31 @@ public void emitWatermark(Instant watermark) {
 
     @Override
     public <T> void emitView(String id, WindowedValue<Iterable<T>> elements) {
-      outputList.add(OpMessage.ofSideInput(id, elements));
+      outputQueue.add(OpMessage.ofSideInput(id, elements));
+    }
+
+    @Override
+    public Collection<OpMessage<OutT>> collectOutput() {
+      final List<OpMessage<OutT>> outputList = new ArrayList<>();
+      OpMessage<OutT> output;
+      while ((output = outputQueue.poll()) != null) {
+        outputList.add(output);
+      }
+      return outputList;
+    }
+
+    @Override
+    public CompletionStage<Collection<OpMessage<OutT>>> collectFuture() {
+      final CompletionStage<Collection<OpMessage<OutT>>> future = outputFuture;
+      outputFuture = null;

Review Comment:
   The caller apply() is synchronized so this it thread-safe.



##########
runners/samza/src/main/java/org/apache/beam/runners/samza/runtime/OpAdapter.java:
##########
@@ -84,8 +84,6 @@ public final void schedule(Scheduler<KeyedTimerData<K>> 
timerRegistry) {
 
   @Override
   public synchronized CompletionStage<Collection<OpMessage<OutT>>> 
apply(OpMessage<InT> message) {

Review Comment:
   We still need here, e.g. to synchronize the underlying method calls. You 
pointed out the collectFuture() call in another comments. So keep this 
synchronized will avoid these complications.



-- 
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]

Reply via email to