ebyhr commented on code in PR #16881:
URL: https://github.com/apache/iceberg/pull/16881#discussion_r3445095902


##########
core/src/main/java/org/apache/iceberg/avro/Avro.java:
##########
@@ -248,26 +248,20 @@ static Context deleteContext(Map<String, String> config) {
       private static CodecFactory toCodec(String codecAsString, String 
compressionLevel) {
         CodecFactory codecFactory;
         try {
-          switch (Codec.valueOf(codecAsString.toUpperCase(Locale.ENGLISH))) {
-            case UNCOMPRESSED:
-              codecFactory = CodecFactory.nullCodec();
-              break;
-            case SNAPPY:
-              codecFactory = CodecFactory.snappyCodec();
-              break;
-            case ZSTD:
-              codecFactory =
-                  CodecFactory.zstandardCodec(
-                      compressionLevelAsInt(compressionLevel, 
ZSTD_COMPRESSION_LEVEL_DEFAULT));
-              break;
-            case GZIP:
-              codecFactory =
-                  CodecFactory.deflateCodec(
-                      compressionLevelAsInt(compressionLevel, 
GZIP_COMPRESSION_LEVEL_DEFAULT));
-              break;
-            default:
-              throw new IllegalArgumentException("Unsupported compression 
codec: " + codecAsString);
-          }
+          codecFactory =
+              switch 
(Codec.valueOf(codecAsString.toUpperCase(Locale.ENGLISH))) {
+                case UNCOMPRESSED -> CodecFactory.nullCodec();
+                case SNAPPY -> CodecFactory.snappyCodec();
+                case ZSTD ->
+                    CodecFactory.zstandardCodec(
+                        compressionLevelAsInt(compressionLevel, 
ZSTD_COMPRESSION_LEVEL_DEFAULT));
+                case GZIP ->
+                    CodecFactory.deflateCodec(
+                        compressionLevelAsInt(compressionLevel, 
GZIP_COMPRESSION_LEVEL_DEFAULT));
+                default ->
+                    throw new IllegalArgumentException(
+                        "Unsupported compression codec: " + codecAsString);

Review Comment:
   I believe this default branch is no longer necessary in the new switch 
statement. The compilation will fail if the switch expression doesn't cover all 
possible input values.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to