Class ColumnInterpreter<T,S,P extends com.google.protobuf.Message,Q extends com.google.protobuf.Message,R extends com.google.protobuf.Message>
- Direct Known Subclasses:
BigDecimalColumnInterpreter
,DoubleColumnInterpreter
,LongColumnInterpreter
LongColumnInterpreter
for an example.
Takes two generic parameters and three Message parameters. The cell value type of the interpreter
is <T>. During some computations like sum, average, the return type can be different than
the cell value data type, for eg, sum of int cell values might overflow in case of a int result,
we should use Long for its result. Therefore, this class mandates to use a different (promoted)
data type for result of these computations <S>. All computations are performed on the
promoted data type <S>. There is a conversion method
castToReturnType(Object)
which takes a <T> type and returns a
<S> type. The AggregateIm>lementation uses PB messages to initialize the user's
ColumnInterpreter implementation, and for sending the responses back to AggregationClient.
<T> Cell value data type
<S> Promoted data type
<P> PB message that is used to transport initializer specific bytes
<Q> PB message that is used to transport Cell (<T>) instance
<R> PB message that is used to transport Promoted (<S>) instance
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract S
Returns sum or non null value among (if either of them is null); otherwise returns a null.abstract T
castToCellType
(S response) The response message comes as type S.abstract S
provides casting opportunity between the data types.abstract int
This takes care if either of arguments are null.abstract double
divideForAvg
(S o, Long l) used for computing average of <S> data values.abstract T
This method gets the PB message corresponding to the cell typeabstract T
returns the maximum value for this type Tabstract T
abstract S
This method gets the promoted type from the proto messageabstract Q
This method gets the PB message corresponding to the cell typeabstract R
This method gets the PB message corresponding to the promoted typeabstract P
This method should return any additional data that is needed on the server side to construct the ColumnInterpreter.abstract T
Returns value of type Tabstract S
Returns incrementabstract void
initialize
(P msg) This method should initialize any field(s) of the ColumnInterpreter with a parsing of the passed message bytes (used on the server side).abstract S
Returns multiplication
-
Constructor Details
-
ColumnInterpreter
public ColumnInterpreter()
-
-
Method Details
-
getValue
Returns value of type T- Throws:
IOException
-
add
Returns sum or non null value among (if either of them is null); otherwise returns a null. -
getMaxValue
returns the maximum value for this type T -
getMinValue
-
multiply
Returns multiplication -
increment
Returns increment -
castToReturnType
provides casting opportunity between the data types. -
compare
This takes care if either of arguments are null. returns 0 if they are equal or both are null;- > 0 if l1 > l2 or l1 is not null and l2 is null.
- < 0 if l1 < l2 or l1 is null and l2 is not null.
-
divideForAvg
used for computing average of <S> data values. Not providing the divide method that takes two <S> values as it is not needed as of now. -
getRequestData
This method should return any additional data that is needed on the server side to construct the ColumnInterpreter. The server will pass this to theinitialize(P)
method. If there is no ColumnInterpreter specific data (for e.g.,LongColumnInterpreter
) then null should be returned.- Returns:
- the PB message
-
initialize
This method should initialize any field(s) of the ColumnInterpreter with a parsing of the passed message bytes (used on the server side). -
getProtoForCellType
This method gets the PB message corresponding to the cell type- Returns:
- the PB message for the cell-type instance
-
getCellValueFromProto
This method gets the PB message corresponding to the cell type- Returns:
- the cell-type instance from the PB message
-
getProtoForPromotedType
This method gets the PB message corresponding to the promoted type- Returns:
- the PB message for the promoted-type instance
-
getPromotedValueFromProto
This method gets the promoted type from the proto message- Returns:
- the promoted-type instance from the PB message
-
castToCellType
The response message comes as type S. This will convert/cast it to T. In some sense, performs the opposite ofcastToReturnType(Object)
-