tuple.set("s", r.nextLong() + "");
writer.append(tuple);
}
writer.close();
TupleInputFormat format = ReflectionUtils.newInstance(TupleInputFormat.class, getConf());
Job job = new Job(getConf());
FileInputFormat.setInputPaths(job, outPath);
logger.info("Using max input split size: " + maxSplitSize);
FileInputFormat.setMaxInputSplitSize(job, maxSplitSize);
job.setInputFormatClass(FileInputFormat.class);
// Read all the splits and count. The number of read rows must
// be the same than the written ones.
int count = 0;
for(InputSplit split : format.getSplits(job)) {
TaskAttemptID attemptId = new TaskAttemptID(new TaskID(), 1);
TaskAttemptContext attemptContext = TaskAttemptContextFactory.get(getConf(), attemptId);
logger.info("Sampling split: " + split);
RecordReader<ITuple, NullWritable> reader = format.createRecordReader(split, attemptContext);
reader.initialize(split, attemptContext);
while(reader.nextKeyValue()) {
tuple = reader.getCurrentKey();
count++;
}