/// <exception cref="System.IO.IOException"/> /// <exception cref="System.Exception"/> protected override void Cleanup(Mapper.Context context) { if (lastKey != null) { context.Write(new Text(filename + ":end"), lastKey); context.Write(Checksum, new Text(checksum.ToString())); } }
/// <exception cref="System.IO.IOException"/> /// <exception cref="System.Exception"/> protected override void Reduce(Text key, IEnumerable <Text> values, Reducer.Context context) { if (Error.Equals(key)) { foreach (Text val in values) { context.Write(key, val); } } else { if (Checksum.Equals(key)) { Unsigned16 tmp = new Unsigned16(); Unsigned16 sum = new Unsigned16(); foreach (Text val in values) { tmp.Set(val.ToString()); sum.Add(tmp); } context.Write(Checksum, new Text(sum.ToString())); } else { Text value = values.GetEnumerator().Next(); if (firstKey) { firstKey = false; } else { if (value.CompareTo(lastValue) < 0) { context.Write(Error, new Text("bad key partitioning:\n file " + lastKey + " key " + TextifyBytes(lastValue) + "\n file " + key + " key " + TextifyBytes(value))); } } lastKey.Set(key); lastValue.Set(value); } } }