Class LazyOutputBuffer

    • Constructor Detail

      • LazyOutputBuffer

        public LazyOutputBuffer​(TaskId taskId,
                                String taskInstanceId,
                                Executor executor,
                                io.airlift.units.DataSize maxBufferSize,
                                io.airlift.units.DataSize maxBroadcastBufferSize,
                                Supplier<LocalMemoryContext> systemMemoryContextSupplier,
                                Runnable notifyStatusChanged)
    • Method Detail

      • addStateChangeListener

        public void addStateChangeListener​(StateMachine.StateChangeListener<BufferState> stateChangeListener)
        Description copied from interface: OutputBuffer
        Add a listener which fires anytime the buffer state changes. Listener is always notified asynchronously using a dedicated notification thread pool so, care should be taken to avoid leaking this when adding a listener in a constructor. Additionally, it is possible notifications are observed out of order due to the asynchronous execution.
        Specified by:
        addStateChangeListener in interface OutputBuffer
      • isFinished

        public boolean isFinished()
        Description copied from interface: OutputBuffer
        A buffer is finished once no-more-pages has been set and all buffers have been closed with an abort call.
        Specified by:
        isFinished in interface OutputBuffer
      • getUtilization

        public double getUtilization()
        Description copied from interface: OutputBuffer
        Get the memory utilization percentage.
        Specified by:
        getUtilization in interface OutputBuffer
      • isOverutilized

        public boolean isOverutilized()
        Description copied from interface: OutputBuffer
        Check if the buffer is blocking producers.
        Specified by:
        isOverutilized in interface OutputBuffer
      • getInfo

        public OutputBufferInfo getInfo()
        Description copied from interface: OutputBuffer
        Gets the current state of this buffer. This method is guaranteed to not block or acquire contended locks, but the stats in the info object may be internally inconsistent.
        Specified by:
        getInfo in interface OutputBuffer
      • get

        public com.google.common.util.concurrent.ListenableFuture<BufferResult> get​(OutputBuffers.OutputBufferId bufferId,
                                                                                    long token,
                                                                                    io.airlift.units.DataSize maxSize)
        Description copied from interface: OutputBuffer
        Gets pages from the output buffer, and acknowledges all pages received from the last request. The initial token is zero. Subsequent tokens are acquired from the next token field in the BufferResult returned from the previous request. If the buffer result is marked as complete, the client must call abort to acknowledge receipt of the final state.
        Specified by:
        get in interface OutputBuffer
      • isFull

        public com.google.common.util.concurrent.ListenableFuture<?> isFull()
        Description copied from interface: OutputBuffer
        Get a future that will be completed when the buffer is not full.
        Specified by:
        isFull in interface OutputBuffer
      • enqueue

        public void enqueue​(List<SerializedPage> pages)
        Description copied from interface: OutputBuffer
        Adds a split-up page to an unpartitioned buffer. If no-more-pages has been set, the enqueue page call is ignored. This can happen with limit queries.
        Specified by:
        enqueue in interface OutputBuffer
      • enqueue

        public void enqueue​(int partition,
                            List<SerializedPage> pages)
        Description copied from interface: OutputBuffer
        Adds a split-up page to a specific partition. If no-more-pages has been set, the enqueue page call is ignored. This can happen with limit queries.
        Specified by:
        enqueue in interface OutputBuffer
      • setNoMorePages

        public void setNoMorePages()
        Description copied from interface: OutputBuffer
        Notify buffer that no more pages will be added. Any future calls to enqueue a page are ignored.
        Specified by:
        setNoMorePages in interface OutputBuffer
      • destroy

        public void destroy()
        Description copied from interface: OutputBuffer
        Destroys the buffer, discarding all pages.
        Specified by:
        destroy in interface OutputBuffer
      • fail

        public void fail()
        Description copied from interface: OutputBuffer
        Fail the buffer, discarding all pages, but blocking readers. It is expected that readers will be unblocked when the failed query is cleaned up.
        Specified by:
        fail in interface OutputBuffer
      • getPeakMemoryUsage

        public long getPeakMemoryUsage()
        Specified by:
        getPeakMemoryUsage in interface OutputBuffer
        Returns:
        the peak memory usage of this output buffer.