jt2594838 commented on code in PR #18726:
URL: https://github.com/apache/iotdb/pull/18726#discussion_r4537096224


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/agent/task/subtask/sink/PipeRealtimePriorityBlockingQueue.java:
##########
@@ -203,22 +199,39 @@ public Event peek() {
 
   public synchronized void replace(
       String dataRegionId, Set<TsFileResource> sourceFiles, 
List<TsFileResource> targetFiles) {
+    if (!enableCompaction) {
+      return;
+    }
 
     final int regionId = Integer.parseInt(dataRegionId);
+    final Set<Path> sourceFilePaths =
+        sourceFiles.stream()
+            .map(TsFileResource::getTsFile)
+            .map(PipeRealtimePriorityBlockingQueue::normalizePath)
+            .collect(Collectors.toSet());
+
     final Map<CommitterKey, Set<PipeTsFileInsertionEvent>> 
eventsToBeRemovedGroupByCommitterKey =
         tsfileInsertEventDeque.stream()
             .filter(
                 event ->
                     event instanceof PipeTsFileInsertionEvent
                         && ((PipeTsFileInsertionEvent) event).getRegionId() == 
regionId)
             .map(event -> (PipeTsFileInsertionEvent) event)
+            .filter(event -> 
sourceFilePaths.contains(normalizePath(event.getSourceTsFile())))
             .collect(
                 Collectors.groupingBy(
                     PipeTsFileInsertionEvent::getCommitterKey, 
Collectors.toSet()))
             .entrySet()
             .stream()
-            // Replace if all source files are present in the queue
-            .filter(entry -> entry.getValue().size() == sourceFiles.size())
+            // Replace only when every source file is present exactly once for 
this pipe.
+            .filter(entry -> entry.getValue().size() == sourceFilePaths.size())
+            .filter(
+                entry ->
+                    entry.getValue().stream()
+                        .map(PipeTsFileInsertionEvent::getSourceTsFile)
+                        .map(PipeRealtimePriorityBlockingQueue::normalizePath)
+                        .collect(Collectors.toSet())
+                        .equals(sourceFilePaths))

Review Comment:
   We may expose the ratio as a parameter to users who wish for a faster 
transmission and could tolerate some re-transmission since it is idempotent.



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