taegeonum commented on a change in pull request #153: [NEMO-245,247] Handle watermark in OutputWriter and Implement unbounded word count example URL: https://github.com/apache/incubator-nemo/pull/153#discussion_r232606765
########## File path: runtime/executor/src/main/java/org/apache/nemo/runtime/executor/task/MultiThreadParentTaskDataFetcher.java ########## @@ -96,14 +100,37 @@ private void fetchDataLazily() { final List<CompletableFuture<DataUtil.IteratorWithNumBytes>> futures = readersForParentTask.read(); numOfIterators = futures.size(); + if (numOfIterators > 1) { + inputWatermarkManager = new MultiInputWatermarkManager(numOfIterators, new WatermarkCollector()); + } else { + inputWatermarkManager = new SingleInputWatermarkManager(new WatermarkCollector()); + } + futures.forEach(compFuture -> compFuture.whenComplete((iterator, exception) -> { // A thread for each iterator queueInsertionThreads.submit(() -> { if (exception == null) { // Consume this iterator to the end. while (iterator.hasNext()) { // blocked on the iterator. final Object element = iterator.next(); - elementQueue.offer(element); + + if (LOG.isDebugEnabled()) { + LOG.debug("Receive data : {}", element); + } + + if (element instanceof WatermarkWithIndex) { + // watermark element + // the input watermark manager is accessed by multiple threads + // so we should synchronize it + synchronized (inputWatermarkManager) { + final WatermarkWithIndex watermarkWithIndex = (WatermarkWithIndex) element; + inputWatermarkManager.trackAndEmitWatermarks( Review comment: will add the comment to `InputWatermarkManager` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on 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 With regards, Apache Git Services