use of org.apache.orc.mapreduce.OrcMapreduceRecordReader in project incubator-gobblin by apache.
the class OrcCompactionTaskTest method readOrcFile.
/**
* Read a output ORC compacted file into memory.
* This only works if fields are int value.
*/
private List<OrcStruct> readOrcFile(Path orcFilePath) throws IOException, InterruptedException {
ReaderImpl orcReader = new ReaderImpl(orcFilePath, new OrcFile.ReaderOptions(new Configuration()));
Reader.Options options = new Reader.Options().schema(orcReader.getSchema());
OrcMapreduceRecordReader recordReader = new OrcMapreduceRecordReader(orcReader, options);
List<OrcStruct> result = new ArrayList<>();
OrcStruct recordContainer;
while (recordReader.nextKeyValue()) {
recordContainer = (OrcStruct) OrcUtils.createValueRecursively(orcReader.getSchema());
OrcUtils.upConvertOrcStruct((OrcStruct) recordReader.getCurrentValue(), recordContainer, orcReader.getSchema());
result.add(recordContainer);
}
return result;
}
Aggregations