FileOutputStream out = new FileOutputStream(outputFile, false);
DatumWriter<Object> dout = new GenericDatumWriter<Object>();
dout.setSchema(sch);
Encoder vout = factory.directBinaryEncoder(out, null);
vout.writeLong(numObjects); // metadata:the count of objects in the file
for (Object datum : new RandomData(sch, numObjects)) {
dout.write(datum, bufOut);
blockCount++;
if (buffer.size() >= SYNC_INTERVAL) {