Avros.records(Person.class)));
PCollection<Employee> employees = genericCollection.parallelDo(new DoFn<Person, Employee>() {
@Override
public void process(Person person, Emitter<Employee> emitter) {
emitter.emit(new Employee(person.getName(), 0, "Eng"));
}
}, Avros.records(Employee.class));
File output1File = tmpDir.getFile("output1");
File output2File = tmpDir.getFile("output2");
pipeline.write(genericCollection, new AvroParquetFileTarget(output1File.getAbsolutePath()));
pipeline.write(employees, new AvroParquetFileSourceTarget(new Path(output2File.getAbsolutePath()),
Avros.records(Employee.class)));
pipeline.run();
Person person = genericCollection.materialize().iterator().next();
Employee employee = employees.materialize().iterator().next();
Path parquet1File = new Path(new File(output1File, "part-m-00000.parquet").getPath());
Path parquet2File = new Path(new File(output2File, "part-m-00000.parquet").getPath());
AvroParquetReader<Person> personReader = new AvroParquetReader<Person>(parquet1File);
try {
Person readPerson = personReader.read();
assertThat(readPerson, is(person));
} finally {
personReader.close();
}
AvroParquetReader<Employee> employeeReader = new AvroParquetReader<Employee>(parquet2File);
try {
Employee readEmployee = employeeReader.read();
assertThat(readEmployee, is(employee));
} finally {
employeeReader.close();
}