Beispiel #1
0
 /// <exception cref="System.IO.IOException"/>
 /// <exception cref="System.Exception"/>
 protected internal CombineFileRecordReaderWrapper(FileInputFormat <K, V> inputFormat
                                                   , CombineFileSplit split, TaskAttemptContext context, int idx)
 {
     fileSplit = new FileSplit(split.GetPath(idx), split.GetOffset(idx), split.GetLength
                                   (idx), split.GetLocations());
     delegate_ = inputFormat.CreateRecordReader(fileSplit, context);
 }
 /// <summary>Get the record reader for the next chunk in this CombineFileSplit.</summary>
 /// <exception cref="System.IO.IOException"/>
 protected internal virtual bool InitNextRecordReader()
 {
     if (curReader != null)
     {
         curReader.Close();
         curReader = null;
         if (idx > 0)
         {
             progress += split.GetLength(idx - 1);
         }
     }
     // done processing so far
     // if all chunks have been processed, nothing more to do.
     if (idx == split.GetNumPaths())
     {
         return(false);
     }
     context.Progress();
     // get a record reader for the idx-th chunk
     try
     {
         Configuration conf = context.GetConfiguration();
         // setup some helper config variables.
         conf.Set(MRJobConfig.MapInputFile, split.GetPath(idx).ToString());
         conf.SetLong(MRJobConfig.MapInputStart, split.GetOffset(idx));
         conf.SetLong(MRJobConfig.MapInputPath, split.GetLength(idx));
         curReader = rrConstructor.NewInstance(new object[] { split, context, Sharpen.Extensions.ValueOf
                                                                  (idx) });
         if (idx > 0)
         {
             // initialize() for the first RecordReader will be called by MapTask;
             // we're responsible for initializing subsequent RecordReaders.
             curReader.Initialize(split, context);
         }
     }
     catch (Exception e)
     {
         throw new RuntimeException(e);
     }
     idx++;
     return(true);
 }