org.apache.hadoop.hbase.coprocessor
Class AggregateImplementation

java.lang.Object
  extended by org.apache.hadoop.hbase.coprocessor.BaseEndpointCoprocessor
      extended by org.apache.hadoop.hbase.coprocessor.AggregateImplementation
All Implemented Interfaces:
Coprocessor, AggregateProtocol, CoprocessorProtocol, VersionedProtocol

public class AggregateImplementation
extends BaseEndpointCoprocessor
implements AggregateProtocol

A concrete AggregateProtocol implementation. Its system level coprocessor that computes the aggregate function at a region level.


Nested Class Summary
 
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 class org.apache.hadoop.hbase.coprocessor.BaseEndpointCoprocessor
VERSION
 
Fields inherited from interface org.apache.hadoop.hbase.coprocessor.AggregateProtocol
VERSION
 
Fields inherited from interface org.apache.hadoop.hbase.Coprocessor
PRIORITY_HIGHEST, PRIORITY_LOWEST, PRIORITY_SYSTEM, PRIORITY_USER
 
Constructor Summary
AggregateImplementation()
           
 
Method Summary
<T,S> Pair<S,Long>
getAvg(ColumnInterpreter<T,S> ci, Scan scan)
          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.
<T,S> T
getMax(ColumnInterpreter<T,S> ci, Scan scan)
          Gives the maximum for a given combination of column qualifier and column family, in the given row range as defined in the Scan object.
<T,S> List<S>
getMedian(ColumnInterpreter<T,S> ci, Scan scan)
          Gives a List containing sum of values and sum of weights.
<T,S> T
getMin(ColumnInterpreter<T,S> ci, Scan scan)
          Gives the minimum for a given combination of column qualifier and column family, in the given row range as defined in the Scan object.
 ProtocolSignature getProtocolSignature(String protocol, long version, int clientMethodsHashCode)
          Return protocol version corresponding to protocol interface.
<T,S> long
getRowNum(ColumnInterpreter<T,S> ci, Scan scan)
           
<T,S> Pair<List<S>,Long>
getStd(ColumnInterpreter<T,S> ci, Scan scan)
          Gives a Pair with first object a List containing Sum and sum of squares, and the second object as row count.
<T,S> S
getSum(ColumnInterpreter<T,S> ci, Scan scan)
          Gives the sum for a given combination of column qualifier and column family, in the given row range as defined in the Scan object.
 
Methods inherited from class org.apache.hadoop.hbase.coprocessor.BaseEndpointCoprocessor
getEnvironment, getProtocolVersion, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.hadoop.hbase.ipc.VersionedProtocol
getProtocolVersion
 

Field Detail

log

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

AggregateImplementation

public AggregateImplementation()
Method Detail

getProtocolSignature

public ProtocolSignature getProtocolSignature(String protocol,
                                              long version,
                                              int clientMethodsHashCode)
                                       throws IOException
Description copied from interface: VersionedProtocol
Return protocol version corresponding to protocol interface.

Specified by:
getProtocolSignature in interface VersionedProtocol
Overrides:
getProtocolSignature in class BaseEndpointCoprocessor
Parameters:
protocol - The classname of the protocol interface
version - The version of the protocol that the client speaks
clientMethodsHashCode - the hashcode of client protocol methods
Returns:
the server protocol signature containing its version and a list of its supported methods
Throws:
IOException
See Also:
for a default implementation

getMax

public <T,S> T getMax(ColumnInterpreter<T,S> ci,
                      Scan scan)
         throws IOException
Description copied from interface: AggregateProtocol
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 interface AggregateProtocol
Returns:
max value as mentioned above
Throws:
IOException

getMin

public <T,S> T getMin(ColumnInterpreter<T,S> ci,
                      Scan scan)
         throws IOException
Description copied from interface: AggregateProtocol
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 interface AggregateProtocol
Returns:
min as mentioned above
Throws:
IOException

getSum

public <T,S> S getSum(ColumnInterpreter<T,S> ci,
                      Scan scan)
         throws IOException
Description copied from interface: AggregateProtocol
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 interface AggregateProtocol
Returns:
sum of values as defined by the column interpreter
Throws:
IOException

getRowNum

public <T,S> long getRowNum(ColumnInterpreter<T,S> ci,
                            Scan scan)
               throws IOException
Specified by:
getRowNum in interface AggregateProtocol
Returns:
Row count for the given column family and column qualifier, in the given row range as defined in the Scan object.
Throws:
IOException

getAvg

public <T,S> Pair<S,Long> getAvg(ColumnInterpreter<T,S> ci,
                                 Scan scan)
                    throws IOException
Description copied from interface: AggregateProtocol
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 interface AggregateProtocol
Returns:
Average
Throws:
IOException

getStd

public <T,S> Pair<List<S>,Long> getStd(ColumnInterpreter<T,S> ci,
                                       Scan scan)
                          throws IOException
Description copied from interface: AggregateProtocol
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 interface AggregateProtocol
Returns:
STD
Throws:
IOException

getMedian

public <T,S> List<S> getMedian(ColumnInterpreter<T,S> ci,
                               Scan scan)
                  throws IOException
Description copied from interface: AggregateProtocol
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 interface AggregateProtocol
Returns:
Pair
Throws:
IOException


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