/// <exception cref="System.IO.IOException"/> public override void Merge(IList <InMemoryMapOutput <K, V> > inputs) { if (inputs == null || inputs.Count == 0) { return; } TaskAttemptID dummyMapId = inputs[0].GetMapId(); IList <Merger.Segment <K, V> > inMemorySegments = new AList <Merger.Segment <K, V> >(); long mergeOutputSize = this._enclosing.CreateInMemorySegments(inputs, inMemorySegments , 0); int noInMemorySegments = inMemorySegments.Count; InMemoryMapOutput <K, V> mergedMapOutputs = this._enclosing.UnconditionalReserve(dummyMapId , mergeOutputSize, false); IFile.Writer <K, V> writer = new InMemoryWriter <K, V>(mergedMapOutputs.GetArrayStream ()); MergeManagerImpl.Log.Info("Initiating Memory-to-Memory merge with " + noInMemorySegments + " segments of total-size: " + mergeOutputSize); RawKeyValueIterator rIter = Merger.Merge(this._enclosing.jobConf, this._enclosing .rfs, (Type)this._enclosing.jobConf.GetMapOutputKeyClass(), (Type)this._enclosing .jobConf.GetMapOutputValueClass(), inMemorySegments, inMemorySegments.Count, new Path(this._enclosing.reduceId.ToString()), (RawComparator <K>) this._enclosing.jobConf .GetOutputKeyComparator(), this._enclosing.reporter, null, null, null); Merger.WriteFile(rIter, writer, this._enclosing.reporter, this._enclosing.jobConf ); writer.Close(); MergeManagerImpl.Log.Info(this._enclosing.reduceId + " Memory-to-Memory merge of the " + noInMemorySegments + " files in-memory complete."); // Note the output of the merge this._enclosing.CloseInMemoryMergedFile(mergedMapOutputs); }
/// <exception cref="System.IO.IOException"/> private void FillOutput(InMemoryMapOutput <Text, Text> output) { BoundedByteArrayOutputStream stream = output.GetArrayStream(); int count = stream.GetLimit(); for (int i = 0; i < count; ++i) { stream.Write(i); } }