Package com.twilio.kudu.sql
Class CalciteScannerMessage<T>
java.lang.Object
com.twilio.kudu.sql.CalciteScannerMessage<T>
- Type Parameters:
T
- The Calcite type. For multicolumn rows it is an Object[] for single it is Object
Message object represents a Message from an active scanner. There are
multiple types defined in
CalciteScannerMessage.MessageType
and each consumer is expected
handle each type. Types are 1. ROW -- contains a row 2. CLOSE -- scanner is
closing so shouldn't expect any more ROW 3. ERROR -- scanner failed in some
manner, contains a failure.
When an ERROR message is received, the producer needs to produce a CLOSE
message just after. ERROR message is not terminal, only CLOSE is terminal
We use this in a Queue as the only synchronization and shared state between a
ScannerCallback
and CalciteKuduEnumerable
. A Queue with
heterogeneous messages is the only solution we were able to make work. Using
a queue and another synchronization object did not work.-
Nested Class Summary
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCalciteScannerMessage
(ScannerCallback callback) Constructs a Batch Completed Scanner Message.CalciteScannerMessage
(Exception failure) Construct a Scanner Message that contains an exception.CalciteScannerMessage
(T row) Constructs a Scanner Message that contains a row. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> CalciteScannerMessage<T>
Construct aCalciteScannerMessage.MessageType.CLOSE
message to represent closing of the scanner.boolean
Whether or not this message means the end of the scan
-
Field Details
-
type
-
row
-
failure
-
callback
-
-
Constructor Details
-
CalciteScannerMessage
Construct a Scanner Message that contains an exception. When this message is consumed the consumer is _expected_ to throw the exception.- Parameters:
failure
- the exception this message represents
-
CalciteScannerMessage
Constructs a Scanner Message that contains a row. Row must by nonNull- Parameters:
row
- the T that should be consumed.
-
CalciteScannerMessage
Constructs a Batch Completed Scanner Message.- Parameters:
callback
- theScannerCallback
that completed it's batch
-
-
Method Details
-
createEndMessage
Construct aCalciteScannerMessage.MessageType.CLOSE
message to represent closing of the scanner. The consumer is excepted to keep track of closed scanners and should not expect moreCalciteScannerMessage.MessageType.ROW
from the scanner.- Type Parameters:
T
- The Calcite type. For multicolumn rows it is an Object[] for single it is Object- Returns:
- simple
CalciteScannerMessage.MessageType.CLOSE
message.
-
isTerminal
public boolean isTerminal()Whether or not this message means the end of the scan- Returns:
- true if the scanner is no longer processing rows.
-