use of org.apache.trevni.avro.AvroColumnWriter in project trevni by cutting.
the class CreateRandomTool method run.
@Override
public int run(InputStream stdin, PrintStream out, PrintStream err, List<String> args) throws Exception {
if (args.size() != 3) {
err.println("Usage: schemaFile count outputFile");
return 1;
}
File schemaFile = new File(args.get(0));
int count = Integer.parseInt(args.get(1));
File outputFile = new File(args.get(2));
Schema schema = Schema.parse(schemaFile);
AvroColumnWriter<Object> writer = new AvroColumnWriter<Object>(schema, new ColumnFileMetaData());
for (Object datum : new RandomData(schema, count)) writer.write(datum);
writer.writeTo(outputFile);
return 0;
}
Aggregations