All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.twitter.elephantbird.mapreduce.io.ProtobufWritable Maven / Gradle / Ivy

The newest version!
package com.twitter.elephantbird.mapreduce.io;

import com.google.protobuf.Message;
import com.twitter.elephantbird.util.TypeRef;

/**
 * A Hadoop Writable wrapper around a protocol buffer of type M.
 */

public class ProtobufWritable extends BinaryWritable {

  public ProtobufWritable() {
    super(null, null);
  }

  public ProtobufWritable(TypeRef typeRef) {
    this(null, typeRef);
  }

  public ProtobufWritable(M message, TypeRef typeRef) {
    super(message, new ProtobufConverter(typeRef));
  }

  /**
   * Returns a ProtobufWritable for a given Protobuf class.
   */
  public static  ProtobufWritable newInstance(Class tClass) {
    return new ProtobufWritable(new TypeRef(tClass){});
  }

  @Override
  protected BinaryConverter getConverterFor(Class clazz) {
    return ProtobufConverter.newInstance(clazz);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy