Class BlockingMultiStreamConsumer<E>
- java.lang.Object
-
- org.apache.pinot.query.runtime.operator.utils.BlockingMultiStreamConsumer<E>
-
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
BlockingMultiStreamConsumer.OfTransferableBlock
public abstract class BlockingMultiStreamConsumer<E> extends Object implements AutoCloseable
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBlockingMultiStreamConsumer.OfTransferableBlock
-
Field Summary
Fields Modifier and Type Field Description protected int_lastReadAn index that used to calculate where do we are going to start reading.protected List<? extends AsyncStream<E>>_mailboxesprotected ArrayBlockingQueue<Boolean>_newDataReady
-
Constructor Summary
Constructors Constructor Description BlockingMultiStreamConsumer(Object id, long deadlineMs, List<? extends AsyncStream<E>> asyncProducers)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidcancel(Throwable t)protected voidcancelRemainingMailboxes()voidclose()protected abstract booleanisEos(E element)protected abstract booleanisError(E element)voidonData()protected abstract EonEos()protected abstract EonException(Exception e)protected abstract EonTimeout()EreadBlockBlocking()Reads the next block for any ready mailbox or blocks until some of them is ready.
-
-
-
Field Detail
-
_mailboxes
protected final List<? extends AsyncStream<E>> _mailboxes
-
_newDataReady
protected final ArrayBlockingQueue<Boolean> _newDataReady
-
_lastRead
protected int _lastRead
An index that used to calculate where do we are going to start reading. The invariant is that we are always going to start reading from_lastRead + 1. Therefore_lastReadmust be in the range[-1, mailbox.size() - 1]
-
-
Constructor Detail
-
BlockingMultiStreamConsumer
public BlockingMultiStreamConsumer(Object id, long deadlineMs, List<? extends AsyncStream<E>> asyncProducers)
-
-
Method Detail
-
isError
protected abstract boolean isError(E element)
-
isEos
protected abstract boolean isEos(E element)
-
onTimeout
protected abstract E onTimeout()
-
onEos
protected abstract E onEos()
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable
-
cancel
public void cancel(Throwable t)
-
cancelRemainingMailboxes
protected void cancelRemainingMailboxes()
-
onData
public void onData()
-
readBlockBlocking
public E readBlockBlocking()
Reads the next block for any ready mailbox or blocks until some of them is ready. The method implements a sequential read semantic. Meaning that:- EOS is only returned when all mailboxes already emitted EOS or there are no mailboxes
- If an error is read from a mailbox, the error is returned
- If data is read from a mailbox, that data block is returned
- If no mailbox is ready, the calling thread is blocked
i, then next call will look for mailboxi+1,i+2... in a circular manner. In order to unblock a thread blocked here,onData()should be called. *
-
-