jihoonson commented on a change in pull request #10076:
URL: https://github.com/apache/druid/pull/10076#discussion_r445696870



##########
File path: 
core/src/main/java/org/apache/druid/java/util/common/guava/ParallelMergeCombiningSequence.java
##########
@@ -1350,4 +1363,24 @@ long getTotalCpuTimeNanos()
       return totalCpuTimeNanos;
     }
   }
+
+  private static <T> void closeAllCursors(final 
PriorityQueue<BatchedResultsCursor<T>> pQueue)
+  {
+    Closer closer = Closer.create();
+    while (!pQueue.isEmpty()) {
+      final BatchedResultsCursor<T> yielder = pQueue.poll();
+      if (yielder != null) {
+        // Note: yielder can be null if our comparator threw an exception 
during queue.add.
+        closer.register(yielder);

Review comment:
       nit: `Closer.register()` has null check. You can use `registerAll()` 
instead.

##########
File path: 
core/src/main/java/org/apache/druid/java/util/common/guava/ParallelMergeCombiningSequence.java
##########
@@ -1036,11 +1047,13 @@ public boolean isReleasable()
     @Override
     public void close()
     {
-      try {
-        yielder.close();
-      }
-      catch (IOException e) {
-        throw new RuntimeException("Failed to close yielder", e);
+      if (yielder != null) {
+        try {
+          yielder.close();
+        }
+        catch (IOException e) {
+          throw new RuntimeException("Failed to close yielder", e);

Review comment:
       It seems the exception will be eventually handled by `CloseQuietly`.

##########
File path: 
core/src/main/java/org/apache/druid/java/util/common/guava/ParallelMergeCombiningSequence.java
##########
@@ -1350,4 +1363,24 @@ long getTotalCpuTimeNanos()
       return totalCpuTimeNanos;
     }
   }
+
+  private static <T> void closeAllCursors(final 
PriorityQueue<BatchedResultsCursor<T>> pQueue)
+  {
+    Closer closer = Closer.create();
+    while (!pQueue.isEmpty()) {
+      final BatchedResultsCursor<T> yielder = pQueue.poll();
+      if (yielder != null) {
+        // Note: yielder can be null if our comparator threw an exception 
during queue.add.
+        closer.register(yielder);
+      }
+    }
+    CloseQuietly.close(closer);
+  }
+
+  private static <T> void closeAllCursors(final List<BatchedResultsCursor<T>> 
list)

Review comment:
       You can merge these methods if you use `registerAll()` above.




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org
For additional commands, e-mail: commits-h...@druid.apache.org

Reply via email to