File outputFile = tmpDir.getFile("output");
Target parquetFileTarget = new AvroParquetFileTarget(outputFile.getAbsolutePath());
pipeline.write(genericCollection, parquetFileTarget);
pipeline.run();
Person person = genericCollection.materialize().iterator().next();
PCollection<Person> retrievedPeople = pipeline.read(new AvroParquetFileSource<Person>(
new Path(outputFile.toURI()), Avros.records(Person.class)));
Person retrievedPerson = retrievedPeople.materialize().iterator().next();
assertThat(retrievedPerson, is(person));
Path parquetFile = new Path(new File(outputFile, "part-m-00000.parquet").getPath());
AvroParquetReader<Person> reader = new AvroParquetReader<Person>(parquetFile);
try {
Person readPerson = reader.read();
assertThat(readPerson, is(person));
} finally {
reader.close();
}
}