wwj6591812 commented on code in PR #4039:
URL: https://github.com/apache/paimon/pull/4039#discussion_r1728114855


##########
paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/source/AppendBypassCoordinateOperator.java:
##########
@@ -57,27 +76,49 @@ public void open() throws Exception {
         checkArgument(
                 getRuntimeContext().getNumberOfParallelSubtasks() == 1,
                 "Compaction Coordinator parallelism in paimon MUST be one.");
-        this.coordinator = new UnawareAppendTableCompactionCoordinator(table, 
true, null);
         long intervalMs = 
table.coreOptions().continuousDiscoveryInterval().toMillis();
-        getProcessingTimeService().scheduleWithFixedDelay(this, 0, intervalMs);
+        this.compactTasks = new LinkedBlockingQueue<>();
+        UnawareAppendTableCompactionCoordinator coordinator =
+                new UnawareAppendTableCompactionCoordinator(table, true, null);
+        this.executorService =
+                Executors.newSingleThreadScheduledExecutor(
+                        newDaemonThreadFactory("Compaction Coordinator"));
+        this.executorService.scheduleWithFixedDelay(
+                () -> asyncPlan(coordinator), 0, intervalMs, 
TimeUnit.MILLISECONDS);
+        this.getProcessingTimeService().scheduleWithFixedDelay(this, 0, 
intervalMs);
     }
 
-    @Override
-    public void onProcessingTime(long time) {
-        while (true) {
+    public void asyncPlan(UnawareAppendTableCompactionCoordinator coordinator) 
{
+        while (compactTasks.size() < MAX_PENDING_TASKS) {
             List<UnawareAppendCompactionTask> tasks = coordinator.run();
-            for (UnawareAppendCompactionTask task : tasks) {
-                output.collect(new StreamRecord<>(Either.Right(task)));
-            }
-
+            compactTasks.addAll(tasks);

Review Comment:
   Because if tasks.isEmpty(), then there is no need to execute 
compactTasks.addAll (tasks);



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