Search in sources :

Example 1 with ErasureCodec

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;
}
Also used : XORErasureCodec(org.apache.hadoop.io.erasurecode.codec.XORErasureCodec) HHXORErasureCodec(org.apache.hadoop.io.erasurecode.codec.HHXORErasureCodec) RSErasureCodec(org.apache.hadoop.io.erasurecode.codec.RSErasureCodec) ErasureCodec(org.apache.hadoop.io.erasurecode.codec.ErasureCodec) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 2 with ErasureCodec

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();
}
Also used : XORErasureCodec(org.apache.hadoop.io.erasurecode.codec.XORErasureCodec) HHXORErasureCodec(org.apache.hadoop.io.erasurecode.codec.HHXORErasureCodec) RSErasureCodec(org.apache.hadoop.io.erasurecode.codec.RSErasureCodec) ErasureCodec(org.apache.hadoop.io.erasurecode.codec.ErasureCodec)

Example 3 with ErasureCodec

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();
}
Also used : XORErasureCodec(org.apache.hadoop.io.erasurecode.codec.XORErasureCodec) HHXORErasureCodec(org.apache.hadoop.io.erasurecode.codec.HHXORErasureCodec) RSErasureCodec(org.apache.hadoop.io.erasurecode.codec.RSErasureCodec) ErasureCodec(org.apache.hadoop.io.erasurecode.codec.ErasureCodec)

Aggregations

ErasureCodec (org.apache.hadoop.io.erasurecode.codec.ErasureCodec)3 HHXORErasureCodec (org.apache.hadoop.io.erasurecode.codec.HHXORErasureCodec)3 RSErasureCodec (org.apache.hadoop.io.erasurecode.codec.RSErasureCodec)3 XORErasureCodec (org.apache.hadoop.io.erasurecode.codec.XORErasureCodec)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)1