Example usage for org.apache.hadoop.io WritableFactory newInstance

List of usage examples for org.apache.hadoop.io WritableFactory newInstance

Introduction

In this page you can find the example usage for org.apache.hadoop.io WritableFactory newInstance.

Prototype

Writable newInstance();

Source Link

Document

Return a new instance.

Usage

From source file:com.taobao.adfs.distributed.rpc.WritableFactories.java

License:Apache License

/** Create a new instance of a class with a defined factory. */
public static Writable newInstance(Class<? extends Writable> c, Configuration conf) {
    WritableFactory factory = WritableFactories.getFactory(c);
    if (factory != null) {
        Writable result = factory.newInstance();
        if (result instanceof Configurable) {
            ((Configurable) result).setConf(conf);
        }/*from  w  w  w . j av  a  2s.co  m*/
        return result;
    } else {
        return ReflectionUtils.newInstance(c, conf);
    }
}