Search in sources :

Example 1 with AvroColumnWriter

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;
}
Also used : RandomData(org.apache.trevni.avro.RandomData) ColumnFileMetaData(org.apache.trevni.ColumnFileMetaData) Schema(org.apache.avro.Schema) File(java.io.File) AvroColumnWriter(org.apache.trevni.avro.AvroColumnWriter)

Aggregations

File (java.io.File)1 Schema (org.apache.avro.Schema)1 ColumnFileMetaData (org.apache.trevni.ColumnFileMetaData)1 AvroColumnWriter (org.apache.trevni.avro.AvroColumnWriter)1 RandomData (org.apache.trevni.avro.RandomData)1