public static List < Class < ? extends CompressionCodec > > getCodecClasses ( Configuration conf ) { String codecsString = conf . get ( "io.compression.codecs" ) ; if ( codecsString != null ) { List < Class < ? extends CompressionCodec > > result = new ArrayList < Class < ? extends CompressionCodec > > ( ) ; StringTokenizer codecSplit = new StringTokenizer ( codecsString , "," ) ; while ( codecSplit . hasMoreElements ( ) ) { String codecSubstring = codecSplit . nextToken ( ) ; if ( codecSubstring . length ( ) != 0 ) { try { Class < ? > cls = conf . getClassByName ( codecSubstring ) ; if ( ! CompressionCodec . class . isAssignableFrom ( cls ) ) { throw new IllegalArgumentException ( "Class " + codecSubstring + " is not a CompressionCodec" ) ; } result . add ( cls . asSubclass ( CompressionCodec . class ) ) ; } catch ( ClassNotFoundException ex ) { throw new IllegalArgumentException ( "Compression codec " + codecSubstring + " not found." , ex ) ; } } } return result ; } else { return null ; } }
Get the list of codecs listed in the configuration