LakshSingla commented on code in PR #15987:
URL: https://github.com/apache/druid/pull/15987#discussion_r1514353936
##########
processing/src/main/java/org/apache/druid/frame/segment/FrameCursorUtils.java:
##########
@@ -79,60 +79,71 @@ public static Filter buildFilter(@Nullable Filter filter,
Interval interval)
/**
* Writes a {@link Cursor} to a sequence of {@link Frame}. This method
iterates over the rows of the cursor,
- * and writes the columns to the frames
- *
- * @param cursor Cursor to write to the frame
- * @param frameWriterFactory Frame writer factory to write to the frame.
- * Determines the signature of the rows that
are written to the frames
+ * and writes the columns to the frames. The iterable is lazy, and it
traverses the required portion of the cursor
+ * as required
*/
- public static Sequence<Frame> cursorToFrames(
- Cursor cursor,
- FrameWriterFactory frameWriterFactory
+ public static Iterable<Frame> cursorToFramesIterable(
+ final Cursor cursor,
+ final FrameWriterFactory frameWriterFactory
)
{
+ return () -> new Iterator<Frame>()
+ {
+ @Override
+ public boolean hasNext()
+ {
+ return !cursor.isDone();
+ }
- return Sequences.simple(
- () -> new Iterator<Frame>()
- {
- @Override
- public boolean hasNext()
- {
- return !cursor.isDone();
- }
-
- @Override
- public Frame next()
- {
- // Makes sure that cursor contains some elements prior. This
ensures if no row is written, then the row size
- // is larger than the MemoryAllocators returned by the provided
factory
- if (!hasNext()) {
- throw new NoSuchElementException();
+ @Override
+ public Frame next()
+ {
+ // Makes sure that cursor contains some elements prior. This ensures
if no row is written, then the row size
+ // is larger than the MemoryAllocators returned by the provided factory
+ if (!hasNext()) {
+ throw new NoSuchElementException();
+ }
+ boolean firstRowWritten = false;
+ Frame frame;
+ try (final FrameWriter frameWriter =
frameWriterFactory.newFrameWriter(cursor.getColumnSelectorFactory())) {
+ while (!cursor.isDone()) {
+ if (!frameWriter.addSelection()) {
+ break;
}
- boolean firstRowWritten = false;
- Frame frame;
- try (final FrameWriter frameWriter =
frameWriterFactory.newFrameWriter(cursor.getColumnSelectorFactory())) {
- while (!cursor.isDone()) {
- if (!frameWriter.addSelection()) {
- break;
- }
- firstRowWritten = true;
- cursor.advance();
- }
-
- if (!firstRowWritten) {
- throw DruidException
- .forPersona(DruidException.Persona.DEVELOPER)
- .ofCategory(DruidException.Category.CAPACITY_EXCEEDED)
- .build("Subquery's row size exceeds the frame size and
therefore cannot write the subquery's "
- + "row to the frame. This is a non-configurable
static limit that can only be modified by the "
- + "developer.");
- }
+ firstRowWritten = true;
+ cursor.advance();
+ }
- frame = Frame.wrap(frameWriter.toByteArray());
- }
- return frame;
+ if (!firstRowWritten) {
+ throw DruidException
+ .forPersona(DruidException.Persona.DEVELOPER)
+ .ofCategory(DruidException.Category.CAPACITY_EXCEEDED)
+ .build("Subquery's row size exceeds the frame size and
therefore cannot write the subquery's "
Review Comment:
Changed the message
--
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]