in stresso/src/main/java/stresso/trie/Generate.java [83:129]
public RecordReader<LongWritable, NullWritable> getRecordReader(InputSplit split, JobConf job,
Reporter reporter) throws IOException {
final int numToGen = job.getInt(TRIE_GEN_NUM_PER_MAPPER_PROP, 1);
final long max = job.getLong(TRIE_GEN_MAX_PROP, Long.MAX_VALUE);
return new RecordReader<LongWritable, NullWritable>() {
private Random random = new Random();
private int count = 0;
@Override
public boolean next(LongWritable key, NullWritable value) throws IOException {
if (count == numToGen) {
return false;
}
key.set((random.nextLong() & 0x7fffffffffffffffL) % max);
count++;
return true;
}
@Override
public LongWritable createKey() {
return new LongWritable();
}
@Override
public NullWritable createValue() {
return NullWritable.get();
}
@Override
public long getPos() throws IOException {
return count;
}
@Override
public void close() throws IOException {}
@Override
public float getProgress() throws IOException {
return (float) count / numToGen;
}
};
}