parquet.hadoop.ParquetWriter Java Examples
The following examples show how to use
parquet.hadoop.ParquetWriter.
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: ExaParquetWriterImpl.java From hadoop-etl-udfs with MIT License | 7 votes |
private ExaParquetWriterImpl(final MessageType schema, final int numColumns, final Configuration conf, final Path path, final String compressionType, final ExaIterator exa, final int firstColumnIndex, final List<Integer> dynamicPartitionExaColNums) throws Exception { System.out.println("Path: " + path.toString()); System.out.println("Parquet schema:\n" + schema); TupleWriteSupport.setSchema(schema, conf); this.writer = new ParquetWriter<>(path, new TupleWriteSupport(), CompressionCodecName.fromConf(compressionType), ParquetWriter.DEFAULT_BLOCK_SIZE, ParquetWriter.DEFAULT_PAGE_SIZE, ParquetWriter.DEFAULT_PAGE_SIZE, ParquetWriter.DEFAULT_IS_DICTIONARY_ENABLED, ParquetWriter.DEFAULT_IS_VALIDATING_ENABLED, conf); // Create Tuple object with ExaIterator reference. this.row = new Tuple(exa, numColumns, firstColumnIndex, dynamicPartitionExaColNums); }
Example #2
Source File: ParquetAvroStockWriter.java From hiped2 with Apache License 2.0 | 5 votes |
/** * Write the file. * * @param args the command-line arguments * @return the process exit code * @throws Exception if something goes wrong */ public int run(final String[] args) throws Exception { Cli cli = Cli.builder().setArgs(args).addOptions(CliCommonOpts.IOFileOpts.values()).build(); int result = cli.runCmd(); if (result != 0) { return result; } File inputFile = new File(cli.getArgValueAsString(CliCommonOpts.IOFileOpts.INPUT)); Path outputPath = new Path(cli.getArgValueAsString(CliCommonOpts.IOFileOpts.OUTPUT)); AvroParquetWriter<Stock> writer = new AvroParquetWriter<Stock>(outputPath, Stock.SCHEMA$, CompressionCodecName.SNAPPY, ParquetWriter.DEFAULT_BLOCK_SIZE, ParquetWriter.DEFAULT_PAGE_SIZE, true); for (Stock stock : AvroStockUtils.fromCsvFile(inputFile)) { writer.write(stock); } writer.close(); return 0; }
Example #3
Source File: ParquetDataWriterBuilder.java From incubator-gobblin with Apache License 2.0 | 4 votes |
/** * Build a version-specific {@link ParquetWriter} for given {@link ParquetWriterConfiguration} * @param writerConfiguration * @return * @throws IOException */ @Override public ParquetWriterShim getVersionSpecificWriter(ParquetWriterConfiguration writerConfiguration) throws IOException { CompressionCodecName codecName = CompressionCodecName.fromConf(writerConfiguration.getCodecName()); ParquetProperties.WriterVersion writerVersion = ParquetProperties.WriterVersion .fromString(writerConfiguration.getWriterVersion()); Configuration conf = new Configuration(); ParquetWriter versionSpecificWriter = null; switch (writerConfiguration.getRecordFormat()) { case GROUP: { GroupWriteSupport.setSchema((MessageType) this.schema, conf); WriteSupport support = new GroupWriteSupport(); versionSpecificWriter = new ParquetWriter<Group>( writerConfiguration.getAbsoluteStagingFile(), support, codecName, writerConfiguration.getBlockSize(), writerConfiguration.getPageSize(), writerConfiguration.getDictPageSize(), writerConfiguration.isDictionaryEnabled(), writerConfiguration.isValidate(), writerVersion, conf); break; } case AVRO: { versionSpecificWriter = new AvroParquetWriter( writerConfiguration.getAbsoluteStagingFile(), (Schema) this.schema, codecName, writerConfiguration.getBlockSize(), writerConfiguration.getPageSize(), writerConfiguration.isDictionaryEnabled(), conf); break; } case PROTOBUF: { versionSpecificWriter = new ProtoParquetWriter( writerConfiguration.getAbsoluteStagingFile(), (Class<? extends Message>) this.schema, codecName, writerConfiguration.getBlockSize(), writerConfiguration.getPageSize(), writerConfiguration.isDictionaryEnabled(), writerConfiguration.isValidate()); break; } default: throw new RuntimeException("Record format not supported"); } ParquetWriter finalVersionSpecificWriter = versionSpecificWriter; return new ParquetWriterShim() { @Override public void write(Object record) throws IOException { finalVersionSpecificWriter.write(record); } @Override public void close() throws IOException { finalVersionSpecificWriter.close(); } }; }