FrankChen021 commented on code in PR #19823:
URL: https://github.com/apache/druid/pull/19823#discussion_r3720928708


##########
processing/src/main/java/org/apache/druid/query/rowsandcols/LazilyDecoratedRowsAndColumns.java:
##########
@@ -276,21 +276,15 @@ private Pair<byte[], RowSignature> 
materializeCursorFactory(CursorFactory cursor
           sortColumns
       );
 
-      final FrameWriter writer = 
frameWriterFactory.newFrameWriter(columnSelectorFactory);
-      for (; !cursor.isDoneOrInterrupted() && remainingRowsToSkip > 0; 
remainingRowsToSkip--) {
-        cursor.advance();
-      }
-      for (; !cursor.isDoneOrInterrupted() && remainingRowsToFetch > 0; 
remainingRowsToFetch--) {
-        writer.addSelection();
-        cursor.advance();
-      }
+      try (final FrameWriter writer = 
frameWriterFactory.newFrameWriter(columnSelectorFactory)) {
+        for (; !cursor.isDoneOrInterrupted() && remainingRowsToSkip > 0; 
remainingRowsToSkip--) {
+          cursor.advance();
+        }
+        for (; !cursor.isDoneOrInterrupted() && remainingRowsToFetch > 0; 
remainingRowsToFetch--) {
+          writer.addSelection();
+          cursor.advance();
+        }
 
-      if (writer == null) {
-        // This means that the accumulate was never called, which can only 
happen if we didn't have any cursors.
-        // We would only have zero cursors if we essentially didn't match 
anything, meaning that our RowsAndColumns
-        // should be completely empty.
-        return null;
-      } else {
         final byte[] bytes = writer.toByteArray();
         return Pair.of(bytes, siggy.get());
       }

Review Comment:
   No behavior changed here. The no-cursor sentinel remains the earlier `cursor 
== null` return. After a non-null cursor, `newFrameWriter` has already returned 
and assigned the final writer, so the removed `writer == null` branch was 
unreachable. An exhausted non-null cursor produced an empty frame before and 
still does now. All 28 checks pass. Resolving as a false positive.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to