use of org.apache.crunch.test.Person.Builder in project crunch by cloudera.
the class SpecificAvroGroupByTest method createPersonAvroFile.
private void createPersonAvroFile(File avroFile) throws IOException {
Builder person = Person.newBuilder();
person.setAge(40);
person.setName("Bob");
List<CharSequence> siblingNames = Lists.newArrayList();
siblingNames.add("Bob" + "1");
siblingNames.add("Bob" + "2");
person.setSiblingnames(siblingNames);
FileOutputStream outputStream = new FileOutputStream(avroFile);
SpecificDatumWriter<Person> writer = new SpecificDatumWriter<Person>(Person.class);
DataFileWriter<Person> dataFileWriter = new DataFileWriter<Person>(writer);
dataFileWriter.create(Person.SCHEMA$, outputStream);
dataFileWriter.append(person.build());
dataFileWriter.close();
outputStream.close();
}
Aggregations