}
});
}
@Override public KeyValue<K, ReducerInput<V>> next() {
KeyValues proto = readProto();
if (proto == null) {
throw new NoSuchElementException();
}
K key;
try {
key = keyMarshaller.fromBytes(proto.getKey().asReadOnlyByteBuffer());
} catch (IOException e) {
// TODO(ohler): abort mapreduce
throw new RuntimeException(
this + ": " + keyMarshaller + " failed to parse key from " + proto, e);
}
return KeyValue.of(key,
ReducerInputs.fromIterator(
Iterators.concat(makeIterator(proto),
proto.getPartial()
? Iterators.concat(new IteratorIterator(proto.getKey()))
: Iterators.<V>emptyIterator())));
}