Java Code Examples for org.apache.parquet.hadoop.ParquetReader#Builder
The following examples show how to use
org.apache.parquet.hadoop.ParquetReader#Builder .
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: PutParquetTest.java From nifi with Apache License 2.0 | 6 votes |
private void verifyAvroParquetUsers(final Path avroParquetUsers, final int numExpectedUsers) throws IOException { final ParquetReader.Builder<GenericRecord> readerBuilder = AvroParquetReader .<GenericRecord>builder(avroParquetUsers) .withConf(testConf); int currUser = 0; try (final ParquetReader<GenericRecord> reader = readerBuilder.build()) { GenericRecord nextRecord; while((nextRecord = reader.read()) != null) { Assert.assertNotNull(nextRecord); Assert.assertEquals("name" + currUser, nextRecord.get("name").toString()); Assert.assertEquals(currUser, nextRecord.get("favorite_number")); Assert.assertEquals("blue" + currUser, nextRecord.get("favorite_color").toString()); currUser++; } } Assert.assertEquals(numExpectedUsers, currUser); }
Example 2
Source File: ParquetFileReader.java From streamx with Apache License 2.0 | 5 votes |
@Override public Schema getSchema(Configuration conf, Path path) throws IOException { AvroReadSupport<GenericRecord> readSupport = new AvroReadSupport<>(); ParquetReader.Builder<GenericRecord> builder = ParquetReader.builder(readSupport, path); ParquetReader<GenericRecord> parquetReader = builder.withConf(conf).build(); GenericRecord record; Schema schema = null; while ((record = parquetReader.read()) != null) { schema = avroData.toConnectSchema(record.getSchema()); } parquetReader.close(); return schema; }
Example 3
Source File: ParquetFileReader.java From streamx with Apache License 2.0 | 5 votes |
@Override public Collection<Object> readData(Configuration conf, Path path) throws IOException { Collection<Object> result = new ArrayList<>(); AvroReadSupport<GenericRecord> readSupport = new AvroReadSupport<>(); ParquetReader.Builder<GenericRecord> builder = ParquetReader.builder(readSupport, path); ParquetReader<GenericRecord> parquetReader = builder.withConf(conf).build(); GenericRecord record; while ((record = parquetReader.read()) != null) { result.add(record); } parquetReader.close(); return result; }
Example 4
Source File: FilteringBenchmarks.java From parquet-mr with Apache License 2.0 | 5 votes |
public ParquetReader.Builder<Group> createReaderBuilder() throws IOException { ReadConfigurator readConfigurator = getReadConfigurator(); return readConfigurator.configureBuilder( new ParquetReader.Builder<Group>(HadoopInputFile.fromPath(file, new Configuration())) { @Override protected ReadSupport<Group> getReadSupport() { return new GroupReadSupport(); } }.set(GroupWriteSupport.PARQUET_EXAMPLE_SCHEMA, SCHEMA.toString())); }
Example 5
Source File: PhoneBookWriter.java From parquet-mr with Apache License 2.0 | 5 votes |
public static List<User> readUsers(ParquetReader.Builder<Group> builder) throws IOException { ParquetReader<Group> reader = builder.set(GroupWriteSupport.PARQUET_EXAMPLE_SCHEMA, schema.toString()).build(); List<User> users = new ArrayList<>(); for (Group group = reader.read(); group != null; group = reader.read()) { users.add(userFromGroup(group)); } return users; }
Example 6
Source File: ParquetIterable.java From iceberg with Apache License 2.0 | 4 votes |
ParquetIterable(ParquetReader.Builder<T> builder) { this.builder = builder; }
Example 7
Source File: ParquetIterable.java From iceberg with Apache License 2.0 | 4 votes |
ParquetIterable(ParquetReader.Builder<T> builder) { this.builder = builder; }
Example 8
Source File: FetchParquet.java From nifi with Apache License 2.0 | 4 votes |
@Override public HDFSRecordReader createHDFSRecordReader(final ProcessContext context, final FlowFile flowFile, final Configuration conf, final Path path) throws IOException { final ParquetReader.Builder<GenericRecord> readerBuilder = AvroParquetReader.<GenericRecord>builder(path).withConf(conf); return new AvroParquetHDFSRecordReader(readerBuilder.build()); }
Example 9
Source File: FilteringBenchmarks.java From parquet-mr with Apache License 2.0 | votes |
<T> ParquetReader.Builder<T> configureBuilder(ParquetReader.Builder<T> builder);