Skip to content

Commit

Permalink
AVRO-3930: Mapping org.apache.hadoop.io.ZStandardCodec to zstandard
Browse files Browse the repository at this point in the history
  • Loading branch information
yaooqinn authored and nielsbasjes committed Feb 12, 2024
1 parent 97c8ba8 commit aa20739
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
* {@code bzip2}</li>
* <li>{@code org.apache.hadoop.io.compress.GZipCodec} will map to
* {@code deflate}</li>
* <li>{@code org.apache.hadoop.io.compress.ZStandardCodec} will map to
* {@code zstandard}</li>
* </ul>
*/
public class HadoopCodecFactory {
Expand All @@ -49,6 +51,7 @@ public class HadoopCodecFactory {
HADOOP_AVRO_NAME_MAP.put("org.apache.hadoop.io.compress.SnappyCodec", "snappy");
HADOOP_AVRO_NAME_MAP.put("org.apache.hadoop.io.compress.BZip2Codec", "bzip2");
HADOOP_AVRO_NAME_MAP.put("org.apache.hadoop.io.compress.GZipCodec", "deflate");
HADOOP_AVRO_NAME_MAP.put("org.apache.hadoop.io.compress.ZStandardCodec", "zstandard");
}

/**
Expand All @@ -64,6 +67,8 @@ public class HadoopCodecFactory {
* {@code bzip2}</li>
* <li>{@code org.apache.hadoop.io.compress.GZipCodec} will map to
* {@code deflate}</li>
* <li>{@code org.apache.hadoop.io.compress.ZStandardCodec} will map to
* {@code zstandard}</li>
* </ul>
*/
public static CodecFactory fromHadoopString(String hadoopCodecClass) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,11 @@ void hadoopCodecFactoryFail() {
CodecFactory hadoopSnappyCodec = HadoopCodecFactory.fromHadoopString("org.apache.hadoop.io.compress.FooCodec");
assertNull(hadoopSnappyCodec);
}

@Test
void hadoopCodecFactoryZstd() {
CodecFactory hadoopZstdCodec = HadoopCodecFactory.fromHadoopString("org.apache.hadoop.io.compress.ZStandardCodec");
CodecFactory avroZstdCodec = CodecFactory.fromString("zstandard");
assertEquals(hadoopZstdCodec.getClass(), avroZstdCodec.getClass());
}
}

0 comments on commit aa20739

Please sign in to comment.