@Test public void reader_simple() throws Exception { Configuration conf = new ConfigurationProvider().newInstance(); FileStatus stat = write(conf, 1); try (RecordReader<NullWritable, Text> reader = TemporaryInputFormat.createRecordReader()) { reader.initialize( new FileSplit(stat.getPath(), 0, stat.getLen(), null), new TaskAttemptContextImpl(conf, new TaskAttemptID())); assertThat(reader.nextKeyValue(), is(true)); assertThat(reader.getCurrentValue(), is(new Text("Hello, world!"))); assertThat(reader.nextKeyValue(), is(false)); assertThat((double) reader.getProgress(), closeTo(1.0, 0.01)); } }
@Override public RecordReader<NullWritable, T> createRecordReader( InputSplit split, TaskAttemptContext context) throws IOException, InterruptedException { FileSplit s = (FileSplit) split; assert s.getStart() % TemporaryFile.BLOCK_SIZE == 0; assert s.getStart() > 0 || s.getLength() > 0; return createRecordReader(); }
TemporaryInputFormat extends InputFormat<NullWritable, T> { @Override public RecordReader<NullWritable, T> createRecordReader( InputSplit split, TaskAttemptContext context) throws IOException, InterruptedException { FileSplit s = (FileSplit) split; assert s.getStart() % TemporaryFile.BLOCK_SIZE == 0; assert s.getStart() > 0 || s.getLength() > 0; return createRecordReader(); } }
TemporaryInputFormat extends InputFormat<NullWritable, T> { @Override public RecordReader<NullWritable, T> createRecordReader( InputSplit split, TaskAttemptContext context) throws IOException, InterruptedException { FileSplit s = (FileSplit) split; assert s.getStart() % TemporaryFile.BLOCK_SIZE == 0; assert s.getStart() > 0 || s.getLength() > 0; return createRecordReader(); }  }
TemporaryInputFormat extends InputFormat<NullWritable, T> { @Override public RecordReader<NullWritable, T> createRecordReader( InputSplit split, TaskAttemptContext context) throws IOException, InterruptedException { FileSplit s = (FileSplit) split; assert s.getStart() % TemporaryFile.BLOCK_SIZE == 0; assert s.getStart() > 0 || s.getLength() > 0; return createRecordReader(); }  @Override List<InputSplit> getSplits(JobContext context); List<InputSplit> getSplits(
            JobContext context,
            List<StageInput> inputList); static void setInputPaths(Job job, List<Path> paths); static List<Path> getInputPaths(JobContext context); @Override RecordReader<NullWritable, T> createRecordReader(
            InputSplit split,
            TaskAttemptContext context); }
TemporaryInputFormat extends InputFormat<NullWritable, T> { @Override public RecordReader<NullWritable, T> createRecordReader( InputSplit split, TaskAttemptContext context) throws IOException, InterruptedException { FileSplit s = (FileSplit) split; assert s.getStart() % TemporaryFile.BLOCK_SIZE == 0; assert s.getStart() > 0 || s.getLength() > 0; return createRecordReader(); }  @Override List<InputSplit> getSplits(JobContext context); List<InputSplit> getSplits(
            JobContext context,
            List<StageInput> inputList); static void setInputPaths(Job job, List<Path> paths); static List<Path> getInputPaths(JobContext context); @Override RecordReader<NullWritable, T> createRecordReader(
            InputSplit split,
            TaskAttemptContext context);  }