org.apache.hadoop.hbase.client.coprocessor
Class LongColumnInterpreter

java.lang.Object
  extended by org.apache.hadoop.hbase.coprocessor.ColumnInterpreter<Long,Long,HBaseProtos.EmptyMsg,HBaseProtos.LongMsg,HBaseProtos.LongMsg>
      extended by org.apache.hadoop.hbase.client.coprocessor.LongColumnInterpreter

@InterfaceAudience.Private
public class LongColumnInterpreter
extends ColumnInterpreter<Long,Long,HBaseProtos.EmptyMsg,HBaseProtos.LongMsg,HBaseProtos.LongMsg>

a concrete column interpreter implementation. The cell value is a Long value and its promoted data type is also a Long value. For computing aggregation function, this class is used to find the datatype of the cell value. Client is supposed to instantiate it and passed along as a parameter. See TestAggregateProtocol methods for its sample usage. Its methods handle null arguments gracefully.


Constructor Summary
LongColumnInterpreter()
           
 
Method Summary
 Long add(Long l1, Long l2)
           
 Long castToCellType(Long l)
          The response message comes as type S.
 Long castToReturnType(Long o)
          provides casting opportunity between the data types.
 int compare(Long l1, Long l2)
          This takes care if either of arguments are null.
 double divideForAvg(Long l1, Long l2)
          used for computing average of data values.
 Long getCellValueFromProto(HBaseProtos.LongMsg q)
          This method gets the PB message corresponding to the cell type
 Long getMaxValue()
          returns the maximum value for this type T
 Long getMinValue()
           
 Long getPromotedValueFromProto(HBaseProtos.LongMsg r)
          This method gets the promoted type from the proto message
 HBaseProtos.LongMsg getProtoForCellType(Long t)
          This method gets the PB message corresponding to the cell type
 HBaseProtos.LongMsg getProtoForPromotedType(Long s)
          This method gets the PB message corresponding to the promoted type
 HBaseProtos.EmptyMsg getRequestData()
          This method should return any additional data that is needed on the server side to construct the ColumnInterpreter.
 Long getValue(byte[] colFamily, byte[] colQualifier, Cell kv)
          TODO: when removing ColumnInterpreter.getValue(byte[], byte[], KeyValue), this method should be made abstract
 Long increment(Long o)
           
 void initialize(HBaseProtos.EmptyMsg msg)
          This method should initialize any field(s) of the ColumnInterpreter with a parsing of the passed message bytes (used on the server side).
 Long multiply(Long l1, Long l2)
           
 
Methods inherited from class org.apache.hadoop.hbase.coprocessor.ColumnInterpreter
getValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LongColumnInterpreter

public LongColumnInterpreter()
Method Detail

getValue

public Long getValue(byte[] colFamily,
                     byte[] colQualifier,
                     Cell kv)
              throws IOException
Description copied from class: ColumnInterpreter
TODO: when removing ColumnInterpreter.getValue(byte[], byte[], KeyValue), this method should be made abstract

Overrides:
getValue in class ColumnInterpreter<Long,Long,HBaseProtos.EmptyMsg,HBaseProtos.LongMsg,HBaseProtos.LongMsg>
Returns:
value of type T
Throws:
IOException

add

public Long add(Long l1,
                Long l2)
Specified by:
add in class ColumnInterpreter<Long,Long,HBaseProtos.EmptyMsg,HBaseProtos.LongMsg,HBaseProtos.LongMsg>
Returns:
sum or non null value among (if either of them is null); otherwise returns a null.

compare

public int compare(Long l1,
                   Long l2)
Description copied from class: ColumnInterpreter
This takes care if either of arguments are null. returns 0 if they are equal or both are null;

getMaxValue

public Long getMaxValue()
Description copied from class: ColumnInterpreter
returns the maximum value for this type T

Specified by:
getMaxValue in class ColumnInterpreter<Long,Long,HBaseProtos.EmptyMsg,HBaseProtos.LongMsg,HBaseProtos.LongMsg>
Returns:
max

increment

public Long increment(Long o)
Specified by:
increment in class ColumnInterpreter<Long,Long,HBaseProtos.EmptyMsg,HBaseProtos.LongMsg,HBaseProtos.LongMsg>
Returns:
increment

multiply

public Long multiply(Long l1,
                     Long l2)
Specified by:
multiply in class ColumnInterpreter<Long,Long,HBaseProtos.EmptyMsg,HBaseProtos.LongMsg,HBaseProtos.LongMsg>
Returns:
multiplication

getMinValue

public Long getMinValue()
Specified by:
getMinValue in class ColumnInterpreter<Long,Long,HBaseProtos.EmptyMsg,HBaseProtos.LongMsg,HBaseProtos.LongMsg>

divideForAvg

public double divideForAvg(Long l1,
                           Long l2)
Description copied from class: ColumnInterpreter
used for computing average of data values. Not providing the divide method that takes two values as it is not needed as of now.

Specified by:
divideForAvg in class ColumnInterpreter<Long,Long,HBaseProtos.EmptyMsg,HBaseProtos.LongMsg,HBaseProtos.LongMsg>
Returns:
Average

castToReturnType

public Long castToReturnType(Long o)
Description copied from class: ColumnInterpreter
provides casting opportunity between the data types.

Specified by:
castToReturnType in class ColumnInterpreter<Long,Long,HBaseProtos.EmptyMsg,HBaseProtos.LongMsg,HBaseProtos.LongMsg>
Returns:
cast

castToCellType

public Long castToCellType(Long l)
Description copied from class: ColumnInterpreter
The response message comes as type S. This will convert/cast it to T. In some sense, performs the opposite of ColumnInterpreter.castToReturnType(Object)

Specified by:
castToCellType in class ColumnInterpreter<Long,Long,HBaseProtos.EmptyMsg,HBaseProtos.LongMsg,HBaseProtos.LongMsg>
Returns:
cast

getRequestData

public HBaseProtos.EmptyMsg getRequestData()
Description copied from class: ColumnInterpreter
This method should return any additional data that is needed on the server side to construct the ColumnInterpreter. The server will pass this to the ColumnInterpreter.initialize(P) method. If there is no ColumnInterpreter specific data (for e.g., LongColumnInterpreter) then null should be returned.

Specified by:
getRequestData in class ColumnInterpreter<Long,Long,HBaseProtos.EmptyMsg,HBaseProtos.LongMsg,HBaseProtos.LongMsg>
Returns:
the PB message

initialize

public void initialize(HBaseProtos.EmptyMsg msg)
Description copied from class: ColumnInterpreter
This method should initialize any field(s) of the ColumnInterpreter with a parsing of the passed message bytes (used on the server side).

Specified by:
initialize in class ColumnInterpreter<Long,Long,HBaseProtos.EmptyMsg,HBaseProtos.LongMsg,HBaseProtos.LongMsg>

getProtoForCellType

public HBaseProtos.LongMsg getProtoForCellType(Long t)
Description copied from class: ColumnInterpreter
This method gets the PB message corresponding to the cell type

Specified by:
getProtoForCellType in class ColumnInterpreter<Long,Long,HBaseProtos.EmptyMsg,HBaseProtos.LongMsg,HBaseProtos.LongMsg>
Returns:
the PB message for the cell-type instance

getProtoForPromotedType

public HBaseProtos.LongMsg getProtoForPromotedType(Long s)
Description copied from class: ColumnInterpreter
This method gets the PB message corresponding to the promoted type

Specified by:
getProtoForPromotedType in class ColumnInterpreter<Long,Long,HBaseProtos.EmptyMsg,HBaseProtos.LongMsg,HBaseProtos.LongMsg>
Returns:
the PB message for the promoted-type instance

getPromotedValueFromProto

public Long getPromotedValueFromProto(HBaseProtos.LongMsg r)
Description copied from class: ColumnInterpreter
This method gets the promoted type from the proto message

Specified by:
getPromotedValueFromProto in class ColumnInterpreter<Long,Long,HBaseProtos.EmptyMsg,HBaseProtos.LongMsg,HBaseProtos.LongMsg>
Returns:
the promoted-type instance from the PB message

getCellValueFromProto

public Long getCellValueFromProto(HBaseProtos.LongMsg q)
Description copied from class: ColumnInterpreter
This method gets the PB message corresponding to the cell type

Specified by:
getCellValueFromProto in class ColumnInterpreter<Long,Long,HBaseProtos.EmptyMsg,HBaseProtos.LongMsg,HBaseProtos.LongMsg>
Returns:
the cell-type instance from the PB message


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.