/** * @param key * the key is expected to be a Text object, whose prefix indicates * the type of aggregation to aggregate the values. In effect, data * driven computing is achieved. It is assumed that each aggregator's * getReport method emits appropriate output for the aggregator. This * may be further customiized. * @value the values to be aggregated */ public void reduce(Text key, Iterator<Text> values, OutputCollector<Text, Text> output, Reporter reporter) throws IOException { String keyStr = key.toString(); int pos = keyStr.indexOf(ValueAggregatorDescriptor.TYPE_SEPARATOR); String type = keyStr.substring(0, pos); keyStr = keyStr.substring(pos + ValueAggregatorDescriptor.TYPE_SEPARATOR.length()); ValueAggregator aggregator = ValueAggregatorBaseDescriptor .generateValueAggregator(type); while (values.hasNext()) { aggregator.addNextValue(values.next()); } String val = aggregator.getReport(); key = new Text(keyStr); output.collect(key, new Text(val)); }
String countType = LONG_VALUE_SUM; String id = "record_count"; Entry<Text, Text> e = generateEntry(countType, id, ONE); if (e != null) { retv.add(e); e = generateEntry(countType, this.inputFile, ONE); if (e != null) { retv.add(e);
/** * @param key * the key is expected to be a Text object, whose prefix indicates * the type of aggregation to aggregate the values. In effect, data * driven computing is achieved. It is assumed that each aggregator's * getReport method emits appropriate output for the aggregator. This * may be further customiized. * @param values * the values to be aggregated */ public void reduce(Text key, Iterator<Text> values, OutputCollector<Text, Text> output, Reporter reporter) throws IOException { String keyStr = key.toString(); int pos = keyStr.indexOf(ValueAggregatorDescriptor.TYPE_SEPARATOR); String type = keyStr.substring(0, pos); keyStr = keyStr.substring(pos + ValueAggregatorDescriptor.TYPE_SEPARATOR.length()); ValueAggregator aggregator = ValueAggregatorBaseDescriptor .generateValueAggregator(type); while (values.hasNext()) { aggregator.addNextValue(values.next()); } String val = aggregator.getReport(); key = new Text(keyStr); output.collect(key, new Text(val)); }
String countType = LONG_VALUE_SUM; String id = "record_count"; Entry<Text, Text> e = generateEntry(countType, id, ONE); if (e != null) { retv.add(e); e = generateEntry(countType, this.inputFile, ONE); if (e != null) { retv.add(e);
/** * @param key * the key is expected to be a Text object, whose prefix indicates * the type of aggregation to aggregate the values. In effect, data * driven computing is achieved. It is assumed that each aggregator's * getReport method emits appropriate output for the aggregator. This * may be further customiized. * @value the values to be aggregated */ public void reduce(Text key, Iterator<Text> values, OutputCollector<Text, Text> output, Reporter reporter) throws IOException { String keyStr = key.toString(); int pos = keyStr.indexOf(ValueAggregatorDescriptor.TYPE_SEPARATOR); String type = keyStr.substring(0, pos); keyStr = keyStr.substring(pos + ValueAggregatorDescriptor.TYPE_SEPARATOR.length()); ValueAggregator aggregator = ValueAggregatorBaseDescriptor .generateValueAggregator(type); while (values.hasNext()) { aggregator.addNextValue(values.next()); } String val = aggregator.getReport(); key = new Text(keyStr); output.collect(key, new Text(val)); }
/** * @param key * the key is expected to be a Text object, whose prefix indicates * the type of aggregation to aggregate the values. In effect, data * driven computing is achieved. It is assumed that each aggregator's * getReport method emits appropriate output for the aggregator. This * may be further customiized. * @value the values to be aggregated */ public void reduce(Text key, Iterator<Text> values, OutputCollector<Text, Text> output, Reporter reporter) throws IOException { String keyStr = key.toString(); int pos = keyStr.indexOf(ValueAggregatorDescriptor.TYPE_SEPARATOR); String type = keyStr.substring(0, pos); keyStr = keyStr.substring(pos + ValueAggregatorDescriptor.TYPE_SEPARATOR.length()); ValueAggregator aggregator = ValueAggregatorBaseDescriptor .generateValueAggregator(type); while (values.hasNext()) { aggregator.addNextValue(values.next()); } String val = aggregator.getReport(); key = new Text(keyStr); output.collect(key, new Text(val)); }
/** Combines values for a given key. * @param key the key is expected to be a Text object, whose prefix indicates * the type of aggregation to aggregate the values. * @param values the values to combine * @param output to collect combined values */ public void reduce(Text key, Iterator<Text> values, OutputCollector<Text, Text> output, Reporter reporter) throws IOException { String keyStr = key.toString(); int pos = keyStr.indexOf(ValueAggregatorDescriptor.TYPE_SEPARATOR); String type = keyStr.substring(0, pos); ValueAggregator aggregator = ValueAggregatorBaseDescriptor .generateValueAggregator(type); while (values.hasNext()) { aggregator.addNextValue(values.next()); } Iterator outputs = aggregator.getCombinerOutput().iterator(); while (outputs.hasNext()) { Object v = outputs.next(); if (v instanceof Text) { output.collect(key, (Text)v); } else { output.collect(key, new Text(v.toString())); } } }
/** * @param key * the key is expected to be a Text object, whose prefix indicates * the type of aggregation to aggregate the values. In effect, data * driven computing is achieved. It is assumed that each aggregator's * getReport method emits appropriate output for the aggregator. This * may be further customiized. * @param values * the values to be aggregated */ public void reduce(Text key, Iterator<Text> values, OutputCollector<Text, Text> output, Reporter reporter) throws IOException { String keyStr = key.toString(); int pos = keyStr.indexOf(ValueAggregatorDescriptor.TYPE_SEPARATOR); String type = keyStr.substring(0, pos); keyStr = keyStr.substring(pos + ValueAggregatorDescriptor.TYPE_SEPARATOR.length()); ValueAggregator aggregator = ValueAggregatorBaseDescriptor .generateValueAggregator(type); while (values.hasNext()) { aggregator.addNextValue(values.next()); } String val = aggregator.getReport(); key = new Text(keyStr); output.collect(key, new Text(val)); }
/** * @param key * the key is expected to be a Text object, whose prefix indicates * the type of aggregation to aggregate the values. In effect, data * driven computing is achieved. It is assumed that each aggregator's * getReport method emits appropriate output for the aggregator. This * may be further customiized. * @param values * the values to be aggregated */ public void reduce(Text key, Iterator<Text> values, OutputCollector<Text, Text> output, Reporter reporter) throws IOException { String keyStr = key.toString(); int pos = keyStr.indexOf(ValueAggregatorDescriptor.TYPE_SEPARATOR); String type = keyStr.substring(0, pos); keyStr = keyStr.substring(pos + ValueAggregatorDescriptor.TYPE_SEPARATOR.length()); ValueAggregator aggregator = ValueAggregatorBaseDescriptor .generateValueAggregator(type); while (values.hasNext()) { aggregator.addNextValue(values.next()); } String val = aggregator.getReport(); key = new Text(keyStr); output.collect(key, new Text(val)); }
/** * @param key * the key is expected to be a Text object, whose prefix indicates * the type of aggregation to aggregate the values. In effect, data * driven computing is achieved. It is assumed that each aggregator's * getReport method emits appropriate output for the aggregator. This * may be further customiized. * @param values * the values to be aggregated */ public void reduce(Text key, Iterator<Text> values, OutputCollector<Text, Text> output, Reporter reporter) throws IOException { String keyStr = key.toString(); int pos = keyStr.indexOf(ValueAggregatorDescriptor.TYPE_SEPARATOR); String type = keyStr.substring(0, pos); keyStr = keyStr.substring(pos + ValueAggregatorDescriptor.TYPE_SEPARATOR.length()); ValueAggregator aggregator = ValueAggregatorBaseDescriptor .generateValueAggregator(type); while (values.hasNext()) { aggregator.addNextValue(values.next()); } String val = aggregator.getReport(); key = new Text(keyStr); output.collect(key, new Text(val)); }
/** Combines values for a given key. * @param key the key is expected to be a Text object, whose prefix indicates * the type of aggregation to aggregate the values. * @param values the values to combine * @param output to collect combined values */ public void reduce(Text key, Iterator<Text> values, OutputCollector<Text, Text> output, Reporter reporter) throws IOException { String keyStr = key.toString(); int pos = keyStr.indexOf(ValueAggregatorDescriptor.TYPE_SEPARATOR); String type = keyStr.substring(0, pos); ValueAggregator aggregator = ValueAggregatorBaseDescriptor .generateValueAggregator(type); while (values.hasNext()) { aggregator.addNextValue(values.next()); } Iterator outputs = aggregator.getCombinerOutput().iterator(); while (outputs.hasNext()) { Object v = outputs.next(); if (v instanceof Text) { output.collect(key, (Text)v); } else { output.collect(key, new Text(v.toString())); } } }
/** Combines values for a given key. * @param key the key is expected to be a Text object, whose prefix indicates * the type of aggregation to aggregate the values. * @param values the values to combine * @param output to collect combined values */ public void reduce(Text key, Iterator<Text> values, OutputCollector<Text, Text> output, Reporter reporter) throws IOException { String keyStr = key.toString(); int pos = keyStr.indexOf(ValueAggregatorDescriptor.TYPE_SEPARATOR); String type = keyStr.substring(0, pos); ValueAggregator aggregator = ValueAggregatorBaseDescriptor .generateValueAggregator(type); while (values.hasNext()) { aggregator.addNextValue(values.next()); } Iterator outputs = aggregator.getCombinerOutput().iterator(); while (outputs.hasNext()) { Object v = outputs.next(); if (v instanceof Text) { output.collect(key, (Text)v); } else { output.collect(key, new Text(v.toString())); } } }
/** Combines values for a given key. * @param key the key is expected to be a Text object, whose prefix indicates * the type of aggregation to aggregate the values. * @param values the values to combine * @param output to collect combined values */ public void reduce(Text key, Iterator<Text> values, OutputCollector<Text, Text> output, Reporter reporter) throws IOException { String keyStr = key.toString(); int pos = keyStr.indexOf(ValueAggregatorDescriptor.TYPE_SEPARATOR); String type = keyStr.substring(0, pos); ValueAggregator aggregator = ValueAggregatorBaseDescriptor .generateValueAggregator(type); while (values.hasNext()) { aggregator.addNextValue(values.next()); } Iterator outputs = aggregator.getCombinerOutput().iterator(); while (outputs.hasNext()) { Object v = outputs.next(); if (v instanceof Text) { output.collect(key, (Text)v); } else { output.collect(key, new Text(v.toString())); } } }
/** Combines values for a given key. * @param key the key is expected to be a Text object, whose prefix indicates * the type of aggregation to aggregate the values. * @param values the values to combine * @param output to collect combined values */ public void reduce(Text key, Iterator<Text> values, OutputCollector<Text, Text> output, Reporter reporter) throws IOException { String keyStr = key.toString(); int pos = keyStr.indexOf(ValueAggregatorDescriptor.TYPE_SEPARATOR); String type = keyStr.substring(0, pos); ValueAggregator aggregator = ValueAggregatorBaseDescriptor .generateValueAggregator(type); while (values.hasNext()) { aggregator.addNextValue(values.next()); } Iterator outputs = aggregator.getCombinerOutput().iterator(); while (outputs.hasNext()) { Object v = outputs.next(); if (v instanceof Text) { output.collect(key, (Text)v); } else { output.collect(key, new Text(v.toString())); } } }
/** Combines values for a given key. * @param key the key is expected to be a Text object, whose prefix indicates * the type of aggregation to aggregate the values. * @param values the values to combine * @param output to collect combined values */ public void reduce(Text key, Iterator<Text> values, OutputCollector<Text, Text> output, Reporter reporter) throws IOException { String keyStr = key.toString(); int pos = keyStr.indexOf(ValueAggregatorDescriptor.TYPE_SEPARATOR); String type = keyStr.substring(0, pos); ValueAggregator aggregator = ValueAggregatorBaseDescriptor .generateValueAggregator(type); while (values.hasNext()) { aggregator.addNextValue(values.next()); } Iterator outputs = aggregator.getCombinerOutput().iterator(); while (outputs.hasNext()) { Object v = outputs.next(); if (v instanceof Text) { output.collect(key, (Text)v); } else { output.collect(key, new Text(v.toString())); } } }
/** Combines values for a given key. * @param key the key is expected to be a Text object, whose prefix indicates * the type of aggregation to aggregate the values. * @param values the values to combine * @param output to collect combined values */ public void reduce(Text key, Iterator<Text> values, OutputCollector<Text, Text> output, Reporter reporter) throws IOException { String keyStr = key.toString(); int pos = keyStr.indexOf(ValueAggregatorDescriptor.TYPE_SEPARATOR); String type = keyStr.substring(0, pos); ValueAggregator aggregator = ValueAggregatorBaseDescriptor .generateValueAggregator(type); while (values.hasNext()) { aggregator.addNextValue(values.next()); } Iterator outputs = aggregator.getCombinerOutput().iterator(); while (outputs.hasNext()) { Object v = outputs.next(); if (v instanceof Text) { output.collect(key, (Text)v); } else { output.collect(key, new Text(v.toString())); } } }