Java Code Examples for org.apache.orc.OrcFile#ReaderOptions
The following examples show how to use
org.apache.orc.OrcFile#ReaderOptions .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OrcBulkWriterTestUtil.java From flink with Apache License 2.0 | 6 votes |
public static void validate(File files, List<Record> expected) throws IOException { final File[] buckets = files.listFiles(); assertNotNull(buckets); assertEquals(1, buckets.length); final File[] partFiles = buckets[0].listFiles(); assertNotNull(partFiles); for (File partFile : partFiles) { assertTrue(partFile.length() > 0); OrcFile.ReaderOptions readerOptions = OrcFile.readerOptions(new Configuration()); Reader reader = OrcFile.createReader(new org.apache.hadoop.fs.Path(partFile.toURI()), readerOptions); assertEquals(3, reader.getNumberOfRows()); assertEquals(2, reader.getSchema().getFieldNames().size()); assertSame(reader.getCompressionKind(), CompressionKind.LZ4); assertTrue(reader.hasMetadataValue(USER_METADATA_KEY)); assertTrue(reader.getMetadataKeys().contains(USER_METADATA_KEY)); List<Record> results = getResults(reader); assertEquals(3, results.size()); assertEquals(results, expected); } }
Example 2
Source File: OrcCompactionTaskTest.java From incubator-gobblin with Apache License 2.0 | 6 votes |
/** * Read a output ORC compacted file into memory. * This only works if fields are int value. */ public 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; }
Example 3
Source File: OrcToSdcRecordConverter.java From datacollector with Apache License 2.0 | 5 votes |
public OrcToSdcRecordConverter(Path orcFilePath) throws IOException { final Configuration readerConf = new Configuration(); final OrcFile.ReaderOptions fileReaderOptions = OrcFile.readerOptions(readerConf); this.orcFilePath = orcFilePath; reader = OrcFile.createReader(this.orcFilePath, fileReaderOptions); // TODO: support various parameters to Reader.Options via options passed into constructor? // final Reader.Options rowReaderOptions = new Reader.Options(); // for now, just use default options rows = reader.rows(); readerBatch = reader.getSchema().createRowBatch(); }