gianm commented on code in PR #18909:
URL: https://github.com/apache/druid/pull/18909#discussion_r2688246415
##########
processing/src/main/java/org/apache/druid/frame/channel/ReadableFrameChannel.java:
##########
@@ -20,54 +20,80 @@
package org.apache.druid.frame.channel;
import com.google.common.util.concurrent.ListenableFuture;
+import org.apache.druid.error.DruidException;
import org.apache.druid.frame.Frame;
+import org.apache.druid.query.rowsandcols.RowsAndColumns;
import java.io.Closeable;
+import java.util.NoSuchElementException;
/**
- * Interface for reading a sequence of frames. Supports nonblocking reads
through the {@link #canRead()} and
+ * Interface for reading a sequence of batches of data. Supports nonblocking
reads through the {@link #canRead()} and
* {@link #readabilityFuture()} methods.
*
* May be implemented using an in-memory queue, disk file, stream, etc.
*
* Channels implementing this interface are used by a single reader; they do
not support concurrent reads.
+ *
+ * Despite its name, instances of this class can typically return any {@link
RowsAndColumns} through the
+ * {@link #readRAC()} method.
*/
public interface ReadableFrameChannel extends Closeable
{
/**
- * Returns whether this channel is finished. Finished channels will not
generate any further frames or errors.
+ * Returns whether this channel is finished. Finished channels will not
generate any further data batches or errors.
*
* Generally, once you discover that a channel is finished, you should call
{@link #close()} and then
* discard it.
*
- * Note that it is possible for a channel to be unfinished and also have no
available frames or errors. This happens
- * when it is not in a ready-for-reading state. See {@link
#readabilityFuture()} for details.
+ * Note that it is possible for a channel to be unfinished and also have no
available data batches or errors.
+ * This happens when it is not in a ready-for-reading state. See {@link
#readabilityFuture()} for details.
*/
boolean isFinished();
/**
- * Returns whether this channel has a frame or error condition currently
available. If this method returns true, then
- * you can call {@link #read()} to retrieve the frame or error.
+ * Returns whether this channel has a batch of data or error condition
currently available. If this method returns
+ * true, then you can call {@link #read()} or {@link #readRAC()} to retrieve
the batch or error.
*
- * Note that it is possible for a channel to be unfinished and also have no
available frames or errors. This happens
+ * Note that it is possible for a channel to be unfinished and also have no
available batches or errors. This happens
* when it is not in a ready-for-reading state. See {@link
#readabilityFuture()} for details.
*/
boolean canRead();
/**
- * Returns the next available frame from this channel.
+ * Returns the next available batch of data from this channel as a {@link
Frame}.
+ *
+ * Before calling this method, you should check {@link #canRead()} to ensure
there is a batch of data or
+ * error available.
+ *
+ * @throws NoSuchElementException if there is no batch currently available
+ * @throws DruidException if the available batch was not available
as a {@link Frame}
+ */
+ default Frame read()
+ {
+ final RowsAndColumns rac = readRAC();
+ final Frame frame = rac.as(Frame.class);
+ if (frame != null) {
+ return frame;
+ } else {
+ throw DruidException.defensive("Got RAC[%s] which is not a frame", rac);
+ }
+ }
+
+ /**
+ * Returns the next available batch of data from this channel as a {@link
RowsAndColumns}.
*
- * Before calling this method, you should check {@link #canRead()} to ensure
there is a frame or
+ * Before calling this method, you should check {@link #canRead()} to ensure
there is a batch of data or
* error available.
*
- * @throws java.util.NoSuchElementException if there is no frame currently
available
+ * @throws NoSuchElementException if there is no batch currently available
*/
- Frame read();
+ RowsAndColumns readRAC();
Review Comment:
Hmm, I'll just change it now.
--
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]