if (encodeJson) {
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(outfile));
try {
Encoder encoder = EncoderFactory.get().jsonEncoder(schema, (OutputStream) out);
for (int i = 0; i < numRecords; i++) {
TestRecord tr = new TestRecord();
dout.write(tr, encoder);
}
encoder.flush();
} finally {
out.close();
}
} else {
DataFileWriter out = new DataFileWriter(dout);
try {
out.create(schema, outfile);
for (int i = 0; i < numRecords; i++) {
TestRecord tr = new TestRecord();
out.append(tr);
}
} finally {
out.close();
}