@Override
  public int run(InputStream stdin, PrintStream out, PrintStream err, List<String> args) throws Exception {

    OptionParser p = new OptionParser();
    OptionSpec<String> codec = p.accepts("codec", "Compression codec").withRequiredArg().defaultsTo("null")
        .ofType(String.class);
    OptionSet opts = p.parse(args.toArray(new String[0]));
    if (opts.nonOptionArguments().size() != 2) {
      err.println("Usage: inFile outFile (filenames or '-' for stdin/stdout)");
      p.printHelpOn(err);
      return 1;
    }
    args = (List<String>) opts.nonOptionArguments();

    DataFileStream<Object> reader = new DataFileStream(Util.fileOrStdin(args.get(0), stdin),
        new GenericDatumReader<>());
    OutputStream outs = Util.fileOrStdout(args.get(1), out);
    AvroColumnWriter<Object> writer = new AvroColumnWriter<>(reader.getSchema(),
        new ColumnFileMetaData().setCodec(codec.value(opts)));
    for (Object datum : reader)
      writer.write(datum);
    writer.writeTo(outs);
    outs.close();
    reader.close();
    return 0;
  }
@Test
  void test() throws Exception {
    Schema schema = new Schema.Parser().parse(SCHEMA_FILE);

    DataFileWriter<Object> writer = new DataFileWriter<>(new GenericDatumWriter<>());
    File avroFile = dataDir.resolve("random.avro").toFile();
    writer.create(schema, avroFile);
    for (Object datum : new RandomData(schema, COUNT, SEED))
      writer.append(datum);
    writer.close();

    File trevniFile = dataDir.resolve("random.trv").toFile();
    run(avroFile.toString(), trevniFile.toString());

    AvroColumnReader<Object> reader = new AvroColumnReader<>(new AvroColumnReader.Params(trevniFile));
    Iterator<Object> found = reader.iterator();
    for (Object expected : new RandomData(schema, COUNT, SEED))
      assertEquals(expected, found.next());
    reader.close();
  }