1/**2* Copyright 2011 The Apache Software Foundation3*4* Licensed to the Apache Software Foundation (ASF) under one5* or more contributor license agreements. See the NOTICE file6* distributed with this work for additional information7* regarding copyright ownership. The ASF licenses this file8* to you under the Apache License, Version 2.0 (the9* "License"); you may not use this file except in compliance10* with the License. You may obtain a copy of the License at11*12* http://www.apache.org/licenses/LICENSE-2.013*14* Unless required by applicable law or agreed to in writing, software15* distributed under the License is distributed on an "AS IS" BASIS,16* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.17* See the License for the specific language governing permissions and18* limitations under the License.19*/20 21packageorg.apache.hadoop.hbase.coprocessor; 22 23importjava.io.IOException; 24importjava.util.List; 25 26importorg.apache.hadoop.hbase.client.Scan; 27importorg.apache.hadoop.hbase.client.coprocessor.AggregationClient; 28importorg.apache.hadoop.hbase.ipc.CoprocessorProtocol; 29importorg.apache.hadoop.hbase.util.Pair; 30 31/**32* Defines the aggregation functions that are to be supported in this33* Coprocessor. For each method, it takes a Scan object and a columnInterpreter.34* The scan object should have a column family (else an exception will be35* thrown), and an optional column qualifier. In the current implementation36* {@link AggregateImplementation}, only one column family and column qualifier37* combination is served. In case there are more than one, only first one will38* be picked. Refer to {@link AggregationClient} for some general conditions on39* input parameters.40*/41publicinterfaceAggregateProtocolextendsCoprocessorProtocol { 42publicstaticfinallongVERSION = 1L; 43 44/**45* Gives the maximum for a given combination of column qualifier and column46* family, in the given row range as defined in the Scan object. In its47* current implementation, it takes one column family and one column qualifier48* (if provided). In case of null column qualifier, maximum value for the49* entire column family will be returned.50* @param ci51* @param scan52* @return max value as mentioned above53* @throws IOException54*/55 <T, S> T getMax(ColumnInterpreter<T, S> ci, Scan scan)throwsIOException; 56 57/**58* Gives the minimum for a given combination of column qualifier and column59* family, in the given row range as defined in the Scan object. In its60* current implementation, it takes one column family and one column qualifier61* (if provided). In case of null column qualifier, minimum value for the62* entire column family will be returned.63* @param ci64* @param scan65* @return min as mentioned above66* @throws IOException67*/68 <T, S> T getMin(ColumnInterpreter<T, S> ci, Scan scan)throwsIOException; 69 70/**71* Gives the sum for a given combination of column qualifier and column72* family, in the given row range as defined in the Scan object. In its73* current implementation, it takes one column family and one column qualifier74* (if provided). In case of null column qualifier, sum for the entire column75* family will be returned.76* @param ci77* @param scan78* @return sum of values as defined by the column interpreter79* @throws IOException80*/81 <T, S> S getSum(ColumnInterpreter<T, S> ci, Scan scan)throwsIOException; 82 83/**84* @param ci85* @param scan86* @return Row count for the given column family and column qualifier, in87* the given row range as defined in the Scan object.88* @throws IOException89*/90 <T, S>longgetRowNum(ColumnInterpreter<T, S> ci, Scan scan) 91throwsIOException; 92 93/**94* Gives a Pair with first object as Sum and second object as row count,95* computed for a given combination of column qualifier and column family in96* the given row range as defined in the Scan object. In its current97* implementation, it takes one column family and one column qualifier (if98* provided). In case of null column qualifier, an aggregate sum over all the99* entire column family will be returned.100* <p>101* The average is computed in102* {@link AggregationClient#avg(byte[], ColumnInterpreter, Scan)} by103* processing results from all regions, so its "ok" to pass sum and a Long104* type.105* @param ci106* @param scan107* @return Average108* @throws IOException109*/110 <T, S> Pair<S, Long> getAvg(ColumnInterpreter<T, S> ci, Scan scan) 111throwsIOException; 112 113/**114* Gives a Pair with first object a List containing Sum and sum of squares,115* and the second object as row count. It is computed for a given combination of116* column qualifier and column family in the given row range as defined in the117* Scan object. In its current implementation, it takes one column family and118* one column qualifier (if provided). The idea is get the value of variance first:119* the average of the squares less the square of the average a standard120* deviation is square root of variance.121* @param ci122* @param scan123* @return STD124* @throws IOException125*/126 <T, S> Pair<List<S>, Long> getStd(ColumnInterpreter<T, S> ci, Scan scan) 127throwsIOException; 128 129/**130* Gives a List containing sum of values and sum of weights.131* It is computed for the combination of column132* family and column qualifier(s) in the given row range as defined in the133* Scan object. In its current implementation, it takes one column family and134* two column qualifiers. The first qualifier is for values column and135* the second qualifier (optional) is for weight column.136* @param ci137* @param scan138* @return Pair139* @throws IOException140*/141 <T, S> List<S> getMedian(ColumnInterpreter<T, S> ci, Scan scan) 142throwsIOException; 143 144 }