Search in sources :

Example 1 with AccumuloRecordReader

use of org.apache.accumulo.hadoopImpl.mapred.AccumuloRecordReader in project accumulo by apache.

the class AccumuloRowInputFormat method getRecordReader.

@Override
public RecordReader<Text, PeekingIterator<Entry<Key, Value>>> getRecordReader(InputSplit split, JobConf job, Reporter reporter) throws IOException {
    AccumuloRecordReader<Text, PeekingIterator<Entry<Key, Value>>> recordReader = new AccumuloRecordReader<>(CLASS) {

        RowIterator rowIterator;

        @Override
        public void initialize(InputSplit inSplit, JobConf job) throws IOException {
            super.initialize(inSplit, job);
            rowIterator = new RowIterator(scannerIterator);
        }

        @Override
        public boolean next(Text key, PeekingIterator<Entry<Key, Value>> value) {
            if (!rowIterator.hasNext())
                return false;
            value.initialize(rowIterator.next());
            numKeysRead = rowIterator.getKVCount();
            key.set((currentKey = value.peek().getKey()).getRow());
            return true;
        }

        @Override
        public Text createKey() {
            return new Text();
        }

        @Override
        public PeekingIterator<Entry<Key, Value>> createValue() {
            return new PeekingIterator<>();
        }
    };
    recordReader.initialize(split, job);
    return recordReader;
}
Also used : Entry(java.util.Map.Entry) RowIterator(org.apache.accumulo.core.client.RowIterator) Value(org.apache.accumulo.core.data.Value) Text(org.apache.hadoop.io.Text) PeekingIterator(org.apache.accumulo.core.util.PeekingIterator) AccumuloRecordReader(org.apache.accumulo.hadoopImpl.mapred.AccumuloRecordReader) InputSplit(org.apache.hadoop.mapred.InputSplit) JobConf(org.apache.hadoop.mapred.JobConf) Key(org.apache.accumulo.core.data.Key)

Aggregations

Entry (java.util.Map.Entry)1 RowIterator (org.apache.accumulo.core.client.RowIterator)1 Key (org.apache.accumulo.core.data.Key)1 Value (org.apache.accumulo.core.data.Value)1 PeekingIterator (org.apache.accumulo.core.util.PeekingIterator)1 AccumuloRecordReader (org.apache.accumulo.hadoopImpl.mapred.AccumuloRecordReader)1 Text (org.apache.hadoop.io.Text)1 InputSplit (org.apache.hadoop.mapred.InputSplit)1 JobConf (org.apache.hadoop.mapred.JobConf)1