Package io.trino.execution.buffer
Class ArbitraryOutputBuffer
- java.lang.Object
-
- io.trino.execution.buffer.ArbitraryOutputBuffer
-
- All Implemented Interfaces:
OutputBuffer
public class ArbitraryOutputBuffer extends Object implements OutputBuffer
A buffer that assigns pages to queues based on a first come, first served basis.
-
-
Constructor Summary
Constructors Constructor Description ArbitraryOutputBuffer(String taskInstanceId, StateMachine<BufferState> state, io.airlift.units.DataSize maxBufferSize, Supplier<LocalMemoryContext> systemMemoryContextSupplier, Executor notificationExecutor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabort(OutputBuffers.OutputBufferId bufferId)Closes the specified output buffer.voidacknowledge(OutputBuffers.OutputBufferId bufferId, long sequenceId)Acknowledges the previously received pages from the output buffer.voidaddStateChangeListener(StateMachine.StateChangeListener<BufferState> stateChangeListener)Add a listener which fires anytime the buffer state changes.voiddestroy()Destroys the buffer, discarding all pages.voidenqueue(int partition, List<SerializedPage> pages)Adds a split-up page to a specific partition.voidenqueue(List<SerializedPage> pages)Adds a split-up page to an unpartitioned buffer.voidfail()Fail the buffer, discarding all pages, but blocking readers.com.google.common.util.concurrent.ListenableFuture<BufferResult>get(OutputBuffers.OutputBufferId bufferId, long startingSequenceId, io.airlift.units.DataSize maxSize)Gets pages from the output buffer, and acknowledges all pages received from the last request.OutputBufferInfogetInfo()Gets the current state of this buffer.longgetPeakMemoryUsage()doublegetUtilization()Get the memory utilization percentage.booleanisFinished()A buffer is finished once no-more-pages has been set and all buffers have been closed with an abort call.com.google.common.util.concurrent.ListenableFuture<Void>isFull()Get a future that will be completed when the buffer is not full.booleanisOverutilized()Check if the buffer is blocking producers.voidsetNoMorePages()Notify buffer that no more pages will be added.voidsetOutputBuffers(OutputBuffers newOutputBuffers)Updates the buffer configuration.
-
-
-
Constructor Detail
-
ArbitraryOutputBuffer
public ArbitraryOutputBuffer(String taskInstanceId, StateMachine<BufferState> state, io.airlift.units.DataSize maxBufferSize, Supplier<LocalMemoryContext> systemMemoryContextSupplier, Executor notificationExecutor)
-
-
Method Detail
-
addStateChangeListener
public void addStateChangeListener(StateMachine.StateChangeListener<BufferState> stateChangeListener)
Description copied from interface:OutputBufferAdd 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 leakingthiswhen adding a listener in a constructor. Additionally, it is possible notifications are observed out of order due to the asynchronous execution.- Specified by:
addStateChangeListenerin interfaceOutputBuffer
-
isFinished
public boolean isFinished()
Description copied from interface:OutputBufferA buffer is finished once no-more-pages has been set and all buffers have been closed with an abort call.- Specified by:
isFinishedin interfaceOutputBuffer
-
getUtilization
public double getUtilization()
Description copied from interface:OutputBufferGet the memory utilization percentage.- Specified by:
getUtilizationin interfaceOutputBuffer
-
isOverutilized
public boolean isOverutilized()
Description copied from interface:OutputBufferCheck if the buffer is blocking producers.- Specified by:
isOverutilizedin interfaceOutputBuffer
-
getInfo
public OutputBufferInfo getInfo()
Description copied from interface:OutputBufferGets 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:
getInfoin interfaceOutputBuffer
-
setOutputBuffers
public void setOutputBuffers(OutputBuffers newOutputBuffers)
Description copied from interface:OutputBufferUpdates the buffer configuration.- Specified by:
setOutputBuffersin interfaceOutputBuffer
-
isFull
public com.google.common.util.concurrent.ListenableFuture<Void> isFull()
Description copied from interface:OutputBufferGet a future that will be completed when the buffer is not full.- Specified by:
isFullin interfaceOutputBuffer
-
enqueue
public void enqueue(List<SerializedPage> pages)
Description copied from interface:OutputBufferAdds 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:
enqueuein interfaceOutputBuffer
-
enqueue
public void enqueue(int partition, List<SerializedPage> pages)Description copied from interface:OutputBufferAdds 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:
enqueuein interfaceOutputBuffer
-
get
public com.google.common.util.concurrent.ListenableFuture<BufferResult> get(OutputBuffers.OutputBufferId bufferId, long startingSequenceId, io.airlift.units.DataSize maxSize)
Description copied from interface:OutputBufferGets 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:
getin interfaceOutputBuffer
-
acknowledge
public void acknowledge(OutputBuffers.OutputBufferId bufferId, long sequenceId)
Description copied from interface:OutputBufferAcknowledges the previously received pages from the output buffer.- Specified by:
acknowledgein interfaceOutputBuffer
-
abort
public void abort(OutputBuffers.OutputBufferId bufferId)
Description copied from interface:OutputBufferCloses the specified output buffer.- Specified by:
abortin interfaceOutputBuffer
-
setNoMorePages
public void setNoMorePages()
Description copied from interface:OutputBufferNotify buffer that no more pages will be added. Any future calls to enqueue a page are ignored.- Specified by:
setNoMorePagesin interfaceOutputBuffer
-
destroy
public void destroy()
Description copied from interface:OutputBufferDestroys the buffer, discarding all pages.- Specified by:
destroyin interfaceOutputBuffer
-
fail
public void fail()
Description copied from interface:OutputBufferFail 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:
failin interfaceOutputBuffer
-
getPeakMemoryUsage
public long getPeakMemoryUsage()
- Specified by:
getPeakMemoryUsagein interfaceOutputBuffer- Returns:
- the peak memory usage of this output buffer.
-
-