org.apache.hadoop.hbase.coprocessor
Interface ColumnInterpreter<T,S>
- Type Parameters:
T
- Cell value data typeS
- Promoted data type
- All Superinterfaces:
- org.apache.hadoop.io.Writable
- All Known Implementing Classes:
- BigDecimalColumnInterpreter, LongColumnInterpreter
public interface ColumnInterpreter<T,S>
- extends org.apache.hadoop.io.Writable
Defines how value for specific column is interpreted and provides utility
methods like compare, add, multiply etc for them. Takes column family, column
qualifier and return the cell value. Its concrete implementation should
handle null case gracefully. Refer to LongColumnInterpreter
for an
example.
Takes two generic parameters. The cell value type of the interpreter is .
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 . All computations are performed on the promoted data type
. There is a conversion method
castToReturnType(Object)
which takes a type and
returns a type.
Methods inherited from interface org.apache.hadoop.io.Writable |
readFields, write |
getValue
T getValue(byte[] colFamily,
byte[] colQualifier,
KeyValue kv)
throws IOException
- Parameters:
colFamily
- colQualifier
- kv
-
- Returns:
- value of type T
- Throws:
IOException
add
S add(S l1,
S l2)
- Parameters:
l1
- l2
-
- Returns:
- sum or non null value among (if either of them is null); otherwise
returns a null.
getMaxValue
T getMaxValue()
- returns the maximum value for this type T
- Returns:
- max
getMinValue
T getMinValue()
multiply
S multiply(S o1,
S o2)
- Parameters:
o1
- o2
-
- Returns:
- multiplication
increment
S increment(S o)
- Parameters:
o
-
- Returns:
- increment
castToReturnType
S castToReturnType(T o)
- provides casting opportunity between the data types.
- Parameters:
o
-
- Returns:
- cast
compare
int compare(T l1,
T l2)
- 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
double divideForAvg(S o,
Long l)
- used for computing average of
data values. Not providing the divide
method that takes two values as it is not needed as of now.
- Parameters:
o
- l
-
- Returns:
- Average
Copyright © 2015 The Apache Software Foundation. All Rights Reserved.