/// <exception cref="System.IO.IOException"/>
            public virtual void Map(WritableComparable key, Writable value, OutputCollector <BytesWritable
                                                                                             , BytesWritable> output, Reporter reporter)
            {
                int itemCount = 0;

                while (numBytesToWrite > 0)
                {
                    int keyLength = minKeySize + (keySizeRange != 0 ? random.Next(keySizeRange) : 0);
                    randomKey.SetSize(keyLength);
                    RandomizeBytes(randomKey.GetBytes(), 0, randomKey.GetLength());
                    int valueLength = minValueSize + (valueSizeRange != 0 ? random.Next(valueSizeRange
                                                                                        ) : 0);
                    randomValue.SetSize(valueLength);
                    RandomizeBytes(randomValue.GetBytes(), 0, randomValue.GetLength());
                    output.Collect(randomKey, randomValue);
                    numBytesToWrite -= keyLength + valueLength;
                    reporter.IncrCounter(ThreadedMapBenchmark.Counters.BytesWritten, 1);
                    reporter.IncrCounter(ThreadedMapBenchmark.Counters.RecordsWritten, 1);
                    if (++itemCount % 200 == 0)
                    {
                        reporter.SetStatus("wrote record " + itemCount + ". " + numBytesToWrite + " bytes left."
                                           );
                    }
                }
                reporter.SetStatus("done with " + itemCount + " records.");
            }
 /// <exception cref="System.IO.IOException"/>
 public override void Map(K key, V value, OutputCollector <K, V> output, Reporter reporter
                          )
 {
     output.Collect(key, value);
     reporter.IncrCounter(TestUserDefinedCounters.EnumCounter.MapRecords, 1);
     reporter.IncrCounter("StringCounter", "MapRecords", 1);
 }
示例#3
0
            /// <exception cref="System.IO.IOException"/>
            public virtual void Map(Org.Apache.Hadoop.IO.Text key, Org.Apache.Hadoop.IO.Text
                                    val, OutputCollector <Org.Apache.Hadoop.IO.Text, Org.Apache.Hadoop.IO.Text> output
                                    , Reporter reporter)
            {
                long acc     = 0L;
                long recs    = 0;
                int  keydiff = keymax - keymin;
                int  valdiff = valmax - valmin;

                for (long i = 0L; acc < bytesToWrite; ++i)
                {
                    int recacc = 0;
                    recacc += GenerateSentence(key, keymin + (0 == keydiff ? 0 : r.Next(keydiff)));
                    recacc += GenerateSentence(val, valmin + (0 == valdiff ? 0 : r.Next(valdiff)));
                    output.Collect(key, val);
                    ++recs;
                    acc += recacc;
                    reporter.IncrCounter(GenericMRLoadGenerator.Counters.BytesWritten, recacc);
                    reporter.IncrCounter(GenericMRLoadGenerator.Counters.RecordsWritten, 1);
                    reporter.SetStatus(acc + "/" + (bytesToWrite - acc) + " bytes");
                }
                reporter.SetStatus("Wrote " + recs + " records");
            }
示例#4
0
 /// <exception cref="System.IO.IOException"/>
 public virtual void Run(RecordReader <K1, V1> input, OutputCollector <K2, V2> output
                         , Reporter reporter)
 {
     try
     {
         // allocate key & value instances that are re-used for all entries
         K1 key   = input.CreateKey();
         V1 value = input.CreateValue();
         while (input.Next(key, value))
         {
             // map pair to output
             mapper.Map(key, value, output, reporter);
             if (incrProcCount)
             {
                 reporter.IncrCounter(SkipBadRecords.CounterGroup, SkipBadRecords.CounterMapProcessedRecords
                                      , 1);
             }
         }
     }
     finally
     {
         mapper.Close();
     }
 }