package test;

import java.io.IOException;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;

public class DummyRecordReader implements org.apache.hadoop.mapred.RecordReader<LongWritable, Text>
{
    private long _position;
    
    @Override
    public void close() throws IOException
    {
    }

    @Override
    public LongWritable createKey()
    {
        return new LongWritable();
    }

    @Override
    public Text createValue()
    {
        return new Text();
    }

    @Override
    public long getPos() throws IOException
    {
        return _position;
    }

    @Override
    public float getProgress() throws IOException
    {
        return _position / 100.0f;
    }

    @Override
    public boolean next(LongWritable key, Text value) throws IOException
    {
        if (_position >= 100) return false;
        
        key.set(_position);
        value.set(Long.toString(_position));
        
        _position++;
        return true;
    }
}
