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
public final class CalciteScannerMessage<T> extends Object
Message object represents a Message from an active scanner. There are multiple types defined inCalciteScannerMessage.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 aScannerCallback
andCalciteKuduEnumerable
. 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
Nested Classes Modifier and Type Class Description static class
CalciteScannerMessage.MessageType
-
Constructor Summary
Constructors Constructor Description CalciteScannerMessage(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
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> CalciteScannerMessage<T>
createEndMessage()
Construct aCalciteScannerMessage.MessageType.CLOSE
message to represent closing of the scanner.
-
-
-
Field Detail
-
type
public final CalciteScannerMessage.MessageType type
-
callback
public final Optional<ScannerCallback> callback
-
-
Constructor Detail
-
CalciteScannerMessage
public CalciteScannerMessage(Exception failure)
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
public CalciteScannerMessage(T row)
Constructs a Scanner Message that contains a row. Row must by nonNull- Parameters:
row
- the T that should be consumed.
-
CalciteScannerMessage
public CalciteScannerMessage(ScannerCallback callback)
Constructs a Batch Completed Scanner Message.- Parameters:
callback
- theScannerCallback
that completed it's batch
-
-
Method Detail
-
createEndMessage
public static <T> CalciteScannerMessage<T> 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.
-
-