use of org.apache.hadoop.io.erasurecode.codec.ErasureCodec in project hadoop by apache.
the class CodecUtil method createCodec.
private static ErasureCodec createCodec(Configuration conf, String codecClassName, ErasureCodecOptions options) {
ErasureCodec codec = null;
try {
Class<? extends ErasureCodec> codecClass = conf.getClassByName(codecClassName).asSubclass(ErasureCodec.class);
Constructor<? extends ErasureCodec> constructor = codecClass.getConstructor(Configuration.class, ErasureCodecOptions.class);
codec = constructor.newInstance(conf, options);
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
throw new RuntimeException("Failed to create erasure codec", e);
}
if (codec == null) {
throw new RuntimeException("Failed to create erasure codec");
}
return codec;
}
use of org.apache.hadoop.io.erasurecode.codec.ErasureCodec in project hadoop by apache.
the class CodecUtil method createDecoder.
/**
* Create decoder corresponding to given codec.
* @param options Erasure codec options
* @return erasure decoder
*/
public static ErasureDecoder createDecoder(Configuration conf, ErasureCodecOptions options) {
Preconditions.checkNotNull(conf);
Preconditions.checkNotNull(options);
String codecKey = getCodecClassName(conf, options.getSchema().getCodecName());
ErasureCodec codec = createCodec(conf, codecKey, options);
return codec.createDecoder();
}
use of org.apache.hadoop.io.erasurecode.codec.ErasureCodec in project hadoop by apache.
the class CodecUtil method createEncoder.
/**
* Create encoder corresponding to given codec.
* @param options Erasure codec options
* @return erasure encoder
*/
public static ErasureEncoder createEncoder(Configuration conf, ErasureCodecOptions options) {
Preconditions.checkNotNull(conf);
Preconditions.checkNotNull(options);
String codecKey = getCodecClassName(conf, options.getSchema().getCodecName());
ErasureCodec codec = createCodec(conf, codecKey, options);
return codec.createEncoder();
}
Aggregations