示例#1
0
 /// <exception cref="System.IO.IOException"/>
 /// <exception cref="System.Exception"/>
 protected override void Map(Text key, Text value, Mapper.Context context)
 {
     if (lastKey == null)
     {
         FileSplit fs = (FileSplit)context.GetInputSplit();
         filename = GetFilename(fs);
         context.Write(new Text(filename + ":begin"), key);
         lastKey = new Text();
     }
     else
     {
         if (key.CompareTo(lastKey) < 0)
         {
             context.Write(Error, new Text("misorder in " + filename + " between " + TextifyBytes
                                               (lastKey) + " and " + TextifyBytes(key)));
         }
     }
     // compute the crc of the key and value and add it to the sum
     crc32.Reset();
     crc32.Update(key.GetBytes(), 0, key.GetLength());
     crc32.Update(value.GetBytes(), 0, value.GetLength());
     tmp.Set(crc32.GetValue());
     checksum.Add(tmp);
     lastKey.Set(key);
 }
示例#2
0
        /// <exception cref="System.IO.IOException"/>
        /// <exception cref="System.Exception"/>
        protected internal override void Setup(Mapper.Context context)
        {
            // Find the Mapper from the TaggedInputSplit.
            TaggedInputSplit inputSplit = (TaggedInputSplit)context.GetInputSplit();

            mapper = (Mapper <K1, V1, K2, V2>)ReflectionUtils.NewInstance(inputSplit.GetMapperClass
                                                                              (), context.GetConfiguration());
        }
            /// <exception cref="System.IO.IOException"/>
            /// <exception cref="System.Exception"/>
            internal MapRunner(MultithreadedMapper <K1, V1, K2, V2> _enclosing, Mapper.Context
                               context)
            {
                this._enclosing = _enclosing;
                reader          = new MultithreadedMapper.SubMapRecordReader(this);
                this.mapper     = ReflectionUtils.NewInstance(this._enclosing.mapClass, context.GetConfiguration
                                                                  ());
                MapContext <K1, V1, K2, V2> mapContext = new MapContextImpl <K1, V1, K2, V2>(this._enclosing
                                                                                             .outer.GetConfiguration(), this._enclosing.outer.GetTaskAttemptID(), this.reader
                                                                                             , new MultithreadedMapper.SubMapRecordWriter(this), context.GetOutputCommitter()
                                                                                             , new MultithreadedMapper.SubMapStatusReporter(this), this._enclosing.outer.GetInputSplit
                                                                                                 ());

                this.subcontext = new WrappedMapper <K1, V1, K2, V2>().GetMapContext(mapContext);
                this.reader.Initialize(context.GetInputSplit(), context);
            }