org.apache.hadoop.hbase.coprocessor
Class AggregateImplementation<T,S,P extends com.google.protobuf.Message,Q extends com.google.protobuf.Message,R extends com.google.protobuf.Message>

java.lang.Object
  extended by org.apache.hadoop.hbase.protobuf.generated.AggregateProtos.AggregateService
      extended by org.apache.hadoop.hbase.coprocessor.AggregateImplementation<T,S,P,Q,R>
Type Parameters:
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 () instance
R - PB message that is used to transport Promoted () instance
All Implemented Interfaces:
com.google.protobuf.Service, Coprocessor, CoprocessorService

@InterfaceAudience.Private
public class AggregateImplementation<T,S,P extends com.google.protobuf.Message,Q extends com.google.protobuf.Message,R extends com.google.protobuf.Message>
extends AggregateProtos.AggregateService
implements CoprocessorService, Coprocessor

A concrete AggregateProtocol implementation. Its system level coprocessor that computes the aggregate function at a region level. ColumnInterpreter is used to interpret column value. This class is parameterized with the following (these are the types with which the ColumnInterpreter is parameterized, and for more description on these, refer to ColumnInterpreter):


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.hadoop.hbase.protobuf.generated.AggregateProtos.AggregateService
AggregateProtos.AggregateService.BlockingInterface, AggregateProtos.AggregateService.Interface, AggregateProtos.AggregateService.Stub
 
Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.Coprocessor
Coprocessor.State
 
Field Summary
protected static org.apache.commons.logging.Log log
           
 
Fields inherited from interface org.apache.hadoop.hbase.Coprocessor
PRIORITY_HIGHEST, PRIORITY_LOWEST, PRIORITY_SYSTEM, PRIORITY_USER, VERSION
 
Constructor Summary
AggregateImplementation()
           
 
Method Summary
 void getAvg(com.google.protobuf.RpcController controller, AggregateProtos.AggregateRequest request, com.google.protobuf.RpcCallback<AggregateProtos.AggregateResponse> done)
          Gives a Pair with first object as Sum and second object as row count, computed for a given combination of column qualifier and column family in the given row range as defined in the Scan object.
 void getMax(com.google.protobuf.RpcController controller, AggregateProtos.AggregateRequest request, com.google.protobuf.RpcCallback<AggregateProtos.AggregateResponse> done)
          Gives the maximum for a given combination of column qualifier and column family, in the given row range as defined in the Scan object.
 void getMedian(com.google.protobuf.RpcController controller, AggregateProtos.AggregateRequest request, com.google.protobuf.RpcCallback<AggregateProtos.AggregateResponse> done)
          Gives a List containing sum of values and sum of weights.
 void getMin(com.google.protobuf.RpcController controller, AggregateProtos.AggregateRequest request, com.google.protobuf.RpcCallback<AggregateProtos.AggregateResponse> done)
          Gives the minimum for a given combination of column qualifier and column family, in the given row range as defined in the Scan object.
 void getRowNum(com.google.protobuf.RpcController controller, AggregateProtos.AggregateRequest request, com.google.protobuf.RpcCallback<AggregateProtos.AggregateResponse> done)
          Gives the row count for the given column family and column qualifier, in the given row range as defined in the Scan object.
 com.google.protobuf.Service getService()
           
 void getStd(com.google.protobuf.RpcController controller, AggregateProtos.AggregateRequest request, com.google.protobuf.RpcCallback<AggregateProtos.AggregateResponse> done)
          Gives a Pair with first object a List containing Sum and sum of squares, and the second object as row count.
 void getSum(com.google.protobuf.RpcController controller, AggregateProtos.AggregateRequest request, com.google.protobuf.RpcCallback<AggregateProtos.AggregateResponse> done)
          Gives the sum for a given combination of column qualifier and column family, in the given row range as defined in the Scan object.
 void start(CoprocessorEnvironment env)
          Stores a reference to the coprocessor environment provided by the RegionCoprocessorHost from the region where this coprocessor is loaded.
 void stop(CoprocessorEnvironment env)
           
 
Methods inherited from class org.apache.hadoop.hbase.protobuf.generated.AggregateProtos.AggregateService
callMethod, getDescriptor, getDescriptorForType, getRequestPrototype, getResponsePrototype, newBlockingStub, newReflectiveBlockingService, newReflectiveService, newStub
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.apache.commons.logging.Log log
Constructor Detail

AggregateImplementation

public AggregateImplementation()
Method Detail

getMax

public void getMax(com.google.protobuf.RpcController controller,
                   AggregateProtos.AggregateRequest request,
                   com.google.protobuf.RpcCallback<AggregateProtos.AggregateResponse> done)
Gives the maximum for a given combination of column qualifier and column family, in the given row range as defined in the Scan object. In its current implementation, it takes one column family and one column qualifier (if provided). In case of null column qualifier, maximum value for the entire column family will be returned.

Specified by:
getMax in class AggregateProtos.AggregateService

getMin

public void getMin(com.google.protobuf.RpcController controller,
                   AggregateProtos.AggregateRequest request,
                   com.google.protobuf.RpcCallback<AggregateProtos.AggregateResponse> done)
Gives the minimum for a given combination of column qualifier and column family, in the given row range as defined in the Scan object. In its current implementation, it takes one column family and one column qualifier (if provided). In case of null column qualifier, minimum value for the entire column family will be returned.

Specified by:
getMin in class AggregateProtos.AggregateService

getSum

public void getSum(com.google.protobuf.RpcController controller,
                   AggregateProtos.AggregateRequest request,
                   com.google.protobuf.RpcCallback<AggregateProtos.AggregateResponse> done)
Gives the sum for a given combination of column qualifier and column family, in the given row range as defined in the Scan object. In its current implementation, it takes one column family and one column qualifier (if provided). In case of null column qualifier, sum for the entire column family will be returned.

Specified by:
getSum in class AggregateProtos.AggregateService

getRowNum

public void getRowNum(com.google.protobuf.RpcController controller,
                      AggregateProtos.AggregateRequest request,
                      com.google.protobuf.RpcCallback<AggregateProtos.AggregateResponse> done)
Gives the row count for the given column family and column qualifier, in the given row range as defined in the Scan object.

Specified by:
getRowNum in class AggregateProtos.AggregateService
Throws:
IOException

getAvg

public void getAvg(com.google.protobuf.RpcController controller,
                   AggregateProtos.AggregateRequest request,
                   com.google.protobuf.RpcCallback<AggregateProtos.AggregateResponse> done)
Gives a Pair with first object as Sum and second object as row count, computed for a given combination of column qualifier and column family in the given row range as defined in the Scan object. In its current implementation, it takes one column family and one column qualifier (if provided). In case of null column qualifier, an aggregate sum over all the entire column family will be returned.

The average is computed in AggregationClient#avg(byte[], ColumnInterpreter, Scan) by processing results from all regions, so its "ok" to pass sum and a Long type.

Specified by:
getAvg in class AggregateProtos.AggregateService

getStd

public void getStd(com.google.protobuf.RpcController controller,
                   AggregateProtos.AggregateRequest request,
                   com.google.protobuf.RpcCallback<AggregateProtos.AggregateResponse> done)
Gives a Pair with first object a List containing Sum and sum of squares, and the second object as row count. It is computed for a given combination of column qualifier and column family in the given row range as defined in the Scan object. In its current implementation, it takes one column family and one column qualifier (if provided). The idea is get the value of variance first: the average of the squares less the square of the average a standard deviation is square root of variance.

Specified by:
getStd in class AggregateProtos.AggregateService

getMedian

public void getMedian(com.google.protobuf.RpcController controller,
                      AggregateProtos.AggregateRequest request,
                      com.google.protobuf.RpcCallback<AggregateProtos.AggregateResponse> done)
Gives a List containing sum of values and sum of weights. It is computed for the combination of column family and column qualifier(s) in the given row range as defined in the Scan object. In its current implementation, it takes one column family and two column qualifiers. The first qualifier is for values column and the second qualifier (optional) is for weight column.

Specified by:
getMedian in class AggregateProtos.AggregateService

getService

public com.google.protobuf.Service getService()
Specified by:
getService in interface CoprocessorService

start

public void start(CoprocessorEnvironment env)
           throws IOException
Stores a reference to the coprocessor environment provided by the RegionCoprocessorHost from the region where this coprocessor is loaded. Since this is a coprocessor endpoint, it always expects to be loaded on a table region, so always expects this to be an instance of RegionCoprocessorEnvironment.

Specified by:
start in interface Coprocessor
Parameters:
env - the environment provided by the coprocessor host
Throws:
IOException - if the provided environment is not an instance of RegionCoprocessorEnvironment

stop

public void stop(CoprocessorEnvironment env)
          throws IOException
Specified by:
stop in interface Coprocessor
Throws:
IOException


Copyright © 2007–2015 The Apache Software Foundation. All rights reserved.