com.twitter.elephantbird.mapreduce.io.ThriftWritable Maven / Gradle / Ivy
package com.twitter.elephantbird.mapreduce.io;
import org.apache.thrift.TBase;
import com.twitter.elephantbird.util.TypeRef;
/**
* {@link BinaryWritable} for Thrift
*/
public class ThriftWritable> extends BinaryWritable {
/**
* Returns a ThriftWritable for a given Thrift class.
*/
public static > ThriftWritable newInstance(Class tClass) {
return new ThriftWritable(new TypeRef(tClass){});
}
public ThriftWritable() {
super(null, null);
}
public ThriftWritable(TypeRef typeRef) {
this(null, typeRef);
}
public ThriftWritable(M message, TypeRef typeRef) {
super(message, new ThriftConverter(typeRef));
}
@Override
protected BinaryConverter getConverterFor(Class clazz) {
return ThriftConverter.newInstance(clazz);
}
}