Interface ReadableFrameChannel

All Superinterfaces:
AutoCloseable, Closeable
All Known Implementing Classes:
ComposingReadableFrameChannel, ReadableByteChunksFrameChannel, ReadableConcatFrameChannel, ReadableFileFrameChannel, ReadableInputStreamFrameChannel, ReadableNilFrameChannel

public interface ReadableFrameChannel extends Closeable
Interface for reading a sequence of batches of data. Supports nonblocking reads through the canRead() and 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 RowsAndColumns through the read() method.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns whether this channel has a batch of data or error condition currently available.
    void
    Releases any resources associated with this readable channel.
    boolean
    Returns whether this channel is finished.
    Returns the next available batch of data from this channel as a RowsAndColumns.
    com.google.common.util.concurrent.ListenableFuture<?>
    Returns a future that will resolve when either isFinished() or canRead() would return true.
    default Frame
    Returns the next available batch of data from this channel as a Frame.
  • Method Details

    • isFinished

      boolean isFinished()
      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 close() and then discard it. 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 readabilityFuture() for details.
    • canRead

      boolean canRead()
      Returns whether this channel has a batch of data or error condition currently available. If this method returns true, then you can call readFrame() or read() to retrieve the batch or error. 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 readabilityFuture() for details.
    • read

      Returns the next available batch of data from this channel as a RowsAndColumns. Before calling this method, you should check canRead() to ensure there is a batch of data or error available.
      Throws:
      NoSuchElementException - if there is no batch currently available
    • readFrame

      default Frame readFrame()
      Returns the next available batch of data from this channel as a Frame. Before calling this method, you should check canRead() to ensure there is a batch of data or error available.
      Throws:
      NoSuchElementException - if there is no batch currently available
      DruidException - if the available batch was not available as a Frame
    • readabilityFuture

      com.google.common.util.concurrent.ListenableFuture<?> readabilityFuture()
      Returns a future that will resolve when either isFinished() or canRead() would return true. The future will never resolve to an exception. If something exceptional has happened, the exception can be retrieved from readFrame() or read().
    • close

      void close()
      Releases any resources associated with this readable channel. After calling this, you should not call any other methods on the channel.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable