/// <summary>The identify function.</summary> /// <remarks>The identify function. Input key/value pair is written directly to output. /// </remarks> /// <exception cref="System.IO.IOException"/> /// <exception cref="System.Exception"/> protected internal override void Map(K key, V val, Mapper.Context context) { FieldSelectionHelper helper = new FieldSelectionHelper(FieldSelectionHelper.emptyText , FieldSelectionHelper.emptyText); helper.ExtractOutputKeyValue(key.ToString(), val.ToString(), fieldSeparator, mapOutputKeyFieldList , mapOutputValueFieldList, allMapValueFieldsFrom, ignoreInputKey, true); context.Write(helper.GetKey(), helper.GetValue()); }
/// <exception cref="System.IO.IOException"/> /// <exception cref="System.Exception"/> protected internal override void Reduce(Text key, IEnumerable <Text> values, Reducer.Context context) { string keyStr = key.ToString() + this.fieldSeparator; foreach (Text val in values) { FieldSelectionHelper helper = new FieldSelectionHelper(); helper.ExtractOutputKeyValue(keyStr, val.ToString(), fieldSeparator, reduceOutputKeyFieldList , reduceOutputValueFieldList, allReduceValueFieldsFrom, false, false); context.Write(helper.GetKey(), helper.GetValue()); } }
/// <exception cref="System.IO.IOException"/> /// <exception cref="System.Exception"/> protected internal override void Setup(Reducer.Context context) { Configuration conf = context.GetConfiguration(); this.fieldSeparator = conf.Get(FieldSelectionHelper.DataFieldSeperator, "\t"); this.reduceOutputKeyValueSpec = conf.Get(FieldSelectionHelper.ReduceOutputKeyValueSpec , "0-:"); allReduceValueFieldsFrom = FieldSelectionHelper.ParseOutputKeyValueSpec(reduceOutputKeyValueSpec , reduceOutputKeyFieldList, reduceOutputValueFieldList); Log.Info(FieldSelectionHelper.SpecToString(fieldSeparator, reduceOutputKeyValueSpec , allReduceValueFieldsFrom, reduceOutputKeyFieldList, reduceOutputValueFieldList )); }
/// <exception cref="System.IO.IOException"/> /// <exception cref="System.Exception"/> protected internal override void Setup(Mapper.Context context) { Configuration conf = context.GetConfiguration(); this.fieldSeparator = conf.Get(FieldSelectionHelper.DataFieldSeperator, "\t"); this.mapOutputKeyValueSpec = conf.Get(FieldSelectionHelper.MapOutputKeyValueSpec, "0-:"); try { this.ignoreInputKey = typeof(TextInputFormat).GetCanonicalName().Equals(context.GetInputFormatClass ().GetCanonicalName()); } catch (TypeLoadException e) { throw new IOException("Input format class not found", e); } allMapValueFieldsFrom = FieldSelectionHelper.ParseOutputKeyValueSpec(mapOutputKeyValueSpec , mapOutputKeyFieldList, mapOutputValueFieldList); Log.Info(FieldSelectionHelper.SpecToString(fieldSeparator, mapOutputKeyValueSpec, allMapValueFieldsFrom, mapOutputKeyFieldList, mapOutputValueFieldList) + "\nignoreInputKey:" + ignoreInputKey); }