From bcb8af7f77927f5593c3d7ee828c9ec24b1e26d5 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Sat, 4 Nov 2023 18:32:13 -0700 Subject: [PATCH] Use enhanced switch in ParquetCompressionUtils --- .../parquet/ParquetCompressionUtils.java | 28 ++++++------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/lib/trino-parquet/src/main/java/io/trino/parquet/ParquetCompressionUtils.java b/lib/trino-parquet/src/main/java/io/trino/parquet/ParquetCompressionUtils.java index 0c8cf74883e1..1c9069817ddf 100644 --- a/lib/trino-parquet/src/main/java/io/trino/parquet/ParquetCompressionUtils.java +++ b/lib/trino-parquet/src/main/java/io/trino/parquet/ParquetCompressionUtils.java @@ -49,25 +49,15 @@ public static Slice decompress(ParquetDataSourceId dataSourceId, CompressionCode return EMPTY_SLICE; } - switch (codec) { - case GZIP: - return decompressGzip(input, uncompressedSize); - case SNAPPY: - return decompressSnappy(input, uncompressedSize); - case UNCOMPRESSED: - return input; - case LZO: - return decompressLZO(input, uncompressedSize); - case LZ4: - return decompressLz4(input, uncompressedSize); - case ZSTD: - return decompressZstd(input, uncompressedSize); - case BROTLI: - case LZ4_RAW: - // unsupported - break; - } - throw new ParquetCorruptionException(dataSourceId, "Codec not supported in Parquet: %s", codec); + return switch (codec) { + case UNCOMPRESSED -> input; + case GZIP -> decompressGzip(input, uncompressedSize); + case SNAPPY -> decompressSnappy(input, uncompressedSize); + case LZO -> decompressLZO(input, uncompressedSize); + case LZ4 -> decompressLz4(input, uncompressedSize); + case ZSTD -> decompressZstd(input, uncompressedSize); + case BROTLI, LZ4_RAW -> throw new ParquetCorruptionException(dataSourceId, "Codec not supported in Parquet: %s", codec); + }; } private static Slice decompressSnappy(Slice input, int uncompressedSize)