public void setCodec(final Codec codec) {
        this.codec = checkNotNull(codec, "codec can not be null");
    }
@Test
    void testCompression() throws Exception {
        // given
        final Path outputPath =
                new Path(File.createTempFile("avro-output-file", "avro").getAbsolutePath());
        final AvroOutputFormat<User> outputFormat = new AvroOutputFormat<>(outputPath, User.class);
        outputFormat.setWriteMode(FileSystem.WriteMode.OVERWRITE);

        final Path compressedOutputPath =
                new Path(
                        File.createTempFile("avro-output-file", "compressed.avro")
                                .getAbsolutePath());
        final AvroOutputFormat<User> compressedOutputFormat =
                new AvroOutputFormat<>(compressedOutputPath, User.class);
        compressedOutputFormat.setWriteMode(FileSystem.WriteMode.OVERWRITE);
        compressedOutputFormat.setCodec(AvroOutputFormat.Codec.SNAPPY);

        // when
        output(outputFormat);
        output(compressedOutputFormat);

        // then
        assertThat(fileSize(outputPath)).isGreaterThan(fileSize(compressedOutputPath));

        // cleanup
        FileSystem fs = FileSystem.getLocalFileSystem();
        fs.delete(outputPath, false);
        fs.delete(compressedOutputPath, false);
    }