@Override
@SuppressWarnings("unchecked")
public Iterator<T> read(FileSystem fs, Path path) {
Path p = fs.makeQualified(path);
final ParquetReader reader;
try {
reader = new ParquetReader(p, new CrunchAvroReadSupport(avroType));
} catch (IOException e) {
throw new CrunchRuntimeException(e);
}
return new AutoClosingIterator<T>(reader, new UnmodifiableIterator<T>() {
private T next;
@Override
public boolean hasNext() {
if (next != null) {
return true;
}
try {
next = (T) reader.read();
} catch (IOException e) {
throw new CrunchRuntimeException(e);
}
return next != null;
}