Github user KanakaKumar commented on a diff in the pull request: https://github.com/apache/carbondata/pull/2877#discussion_r229578078 --- Diff: core/src/main/java/org/apache/carbondata/core/metadata/encoder/Encoding.java --- @@ -57,10 +62,55 @@ public static Encoding valueOf(int ordinal) { return ADAPTIVE_DELTA_INTEGRAL; } else if (ordinal == RLE_INTEGRAL.ordinal()) { return RLE_INTEGRAL; + } else if (ordinal == DIRECT_STRING.ordinal()) { + return DIRECT_STRING; + } else if (ordinal == ADAPTIVE_FLOATING.ordinal()) { + return ADAPTIVE_FLOATING; + } else if (ordinal == BOOL_BYTE.ordinal()) { + return BOOL_BYTE; + } else if (ordinal == ADAPTIVE_DELTA_FLOATING.ordinal()) { + return ADAPTIVE_DELTA_FLOATING; } else if (ordinal == DIRECT_COMPRESS_VARCHAR.ordinal()) { return DIRECT_COMPRESS_VARCHAR; } else { throw new RuntimeException("create Encoding with invalid ordinal: " + ordinal); } } + + /** + * Method to validate for supported encoding types that can be read using the current version + * + * @param encodings + * @return + */ + public static boolean assertTrueForEncodingTypes( + List<org.apache.carbondata.format.Encoding> encodings) { + if (null == encodings || encodings.isEmpty()) { + return true; + } + boolean supportedEncoding = true; + for (org.apache.carbondata.format.Encoding encoder : encodings) { + try { + // if case is handle unsupported encoding type. An encoding not supported for read will be + // added as null by thrift during deserialization + if (null == encoder) { + supportedEncoding = false; + } else { + // if given encoding name is not supported exception will be thrown. This case can come + // if there is any change done in the ordinal of supported encoding + Encoding.valueOf(encoder.name()); + } + } catch (IllegalArgumentException ex) { + supportedEncoding = false; --- End diff -- Log the exception to identify which encoding name failed.
---