Java Code Examples for org.apache.hadoop.hive.ql.io.orc.Writer#addRow()
The following examples show how to use
org.apache.hadoop.hive.ql.io.orc.Writer#addRow() .
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: OrcTestTools.java From incubator-gobblin with Apache License 2.0 | 6 votes |
/** * AvroRow version of writeAsOrcBinary */ private void writeAsOrcBinary(OrcRowIterator input, TypeInfo schema, Path outputPath) throws IOException { Configuration configuration = new Configuration(); // Note that it doesn't support schema evolution at all. // If the schema in realRow is inconsistent with given schema, writing into disk // would run into failure. ObjectInspector oi = TypeInfoUtils.getStandardWritableObjectInspectorFromTypeInfo(schema); OrcFile.WriterOptions options = OrcFile.writerOptions(configuration).inspector(oi); Writer writer = null; while (input.hasNext()) { AvroRow avroRow = (AvroRow) input.next(); if (writer == null) { options.inspector(avroRow.getInspector()); writer = OrcFile.createWriter(outputPath, options); } writer.addRow(avroRow.realRow); } if (writer != null) { writer.close(); } }
Example 2
Source File: OrcFileRewriter.java From presto with Apache License 2.0 | 5 votes |
private static OrcFileInfo rewrite(RecordReader reader, Writer writer, BitSet rowsToDelete, int inputRowCount) throws IOException { Object object = null; int row = 0; long rowCount = 0; long uncompressedSize = 0; row = rowsToDelete.nextClearBit(row); if (row < inputRowCount) { reader.seekToRow(row); } while (row < inputRowCount) { if (Thread.currentThread().isInterrupted()) { throw new InterruptedIOException(); } // seekToRow() is extremely expensive if (reader.getRowNumber() < row) { reader.next(object); continue; } object = reader.next(object); writer.addRow(object); rowCount++; uncompressedSize += uncompressedSize(object); row = rowsToDelete.nextClearBit(row + 1); } return new OrcFileInfo(rowCount, uncompressedSize); }