Package io.trino.plugin.hive.util
Class ThrottledAsyncQueue<T>
- java.lang.Object
-
- io.trino.plugin.hive.util.AsyncQueue<T>
-
- io.trino.plugin.hive.util.ThrottledAsyncQueue<T>
-
- Type Parameters:
T- The type of elements accepted by the queue.
@ThreadSafe public class ThrottledAsyncQueue<T> extends AsyncQueue<T>
An asynchronous queue that limits the rate at which batches will be made available as well as the number of elements they will contain.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.trino.plugin.hive.util.AsyncQueue
AsyncQueue.BorrowResult<T,R>
-
-
Constructor Summary
Constructors Constructor Description ThrottledAsyncQueue(int maxBatchSizePerSec, int targetQueueSize, Executor executor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <O> com.google.common.util.concurrent.ListenableFuture<O>borrowBatchAsync(int maxSize, Function<List<T>,AsyncQueue.BorrowResult<T,O>> function)Invokefunctionwith up tomaxSizeelements removed from the head of the queue, and insert elements in the return value to the tail of the queue.-
Methods inherited from class io.trino.plugin.hive.util.AsyncQueue
finish, getBatchAsync, getNotEmptySignal, isFinished, offer, size
-
-
-
-
Constructor Detail
-
ThrottledAsyncQueue
public ThrottledAsyncQueue(int maxBatchSizePerSec, int targetQueueSize, Executor executor)
-
-
Method Detail
-
borrowBatchAsync
public <O> com.google.common.util.concurrent.ListenableFuture<O> borrowBatchAsync(int maxSize, Function<List<T>,AsyncQueue.BorrowResult<T,O>> function)Description copied from class:AsyncQueueInvokefunctionwith up tomaxSizeelements removed from the head of the queue, and insert elements in the return value to the tail of the queue.If no element is currently available, invocation of
functionwill be deferred until some element is available, or no more elements will be. Spurious invocation offunctionis possible.Insertion through return value of
functionwill be effective even ifAsyncQueue.finish()has been invoked. When borrow (of a non-empty list) is ongoing,AsyncQueue.isFinished()will return false. If an empty list is supplied tofunction, it must not return a result indicating intention to insert elements into the queue.- Overrides:
borrowBatchAsyncin classAsyncQueue<T>
-
-