1 /** 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 package org.apache.hadoop.mapreduce.lib.aggregate; 20 21 import java.util.ArrayList; 22 import java.util.Map.Entry; 23 24 import org.apache.hadoop.classification.InterfaceAudience; 25 import org.apache.hadoop.classification.InterfaceStability; 26 import org.apache.hadoop.conf.Configuration; 27 import org.apache.hadoop.io.Text; 28 29 /** 30 * This interface defines the contract a value aggregator descriptor must 31 * support. Such a descriptor can be configured with a {@link Configuration} 32 * object. Its main function is to generate a list of aggregation-id/value 33 * pairs. An aggregation id encodes an aggregation type which is used to 34 * guide the way to aggregate the value in the reduce/combiner phrase of an 35 * Aggregate based job. 36 * The mapper in an Aggregate based map/reduce job may create one or more of 37 * ValueAggregatorDescriptor objects at configuration time. For each input 38 * key/value pair, the mapper will use those objects to create aggregation 39 * id/value pairs. 40 * 41 */ 42 @InterfaceAudience.Public 43 @InterfaceStability.Stable 44 public interface ValueAggregatorDescriptor { 45 46 public static final String TYPE_SEPARATOR = ":"; 47 48 public static final Text ONE = new Text("1"); 49 50 /** 51 * Generate a list of aggregation-id/value pairs for 52 * the given key/value pair. 53 * This function is usually called by the mapper of an Aggregate based job. 54 * 55 * @param key 56 * input key 57 * @param val 58 * input value 59 * @return a list of aggregation id/value pairs. An aggregation id encodes an 60 * aggregation type which is used to guide the way to aggregate the 61 * value in the reduce/combiner phrase of an Aggregate based job. 62 */ generateKeyValPairs(Object key, Object val)63 public ArrayList<Entry<Text, Text>> generateKeyValPairs(Object key, 64 Object val); 65 66 /** 67 * Configure the object 68 * 69 * @param conf 70 * a Configuration object that may contain the information 71 * that can be used to configure the object. 72 */ configure(Configuration conf)73 public void configure(Configuration conf); 74 } 75