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

com.twitter.elephantbird.cascading.protobuf.ProtobufSerializer Maven / Gradle / Ivy

There is a newer version: 4.17
Show newest version
package com.twitter.elephantbird.cascading.protobuf;

import java.io.IOException;
import java.io.OutputStream;

import com.google.protobuf.Message;

import org.apache.hadoop.io.serializer.Serializer;

/**
 * Serializes protobufs with delimiters
 * @author Ning Liang
 */
public class ProtobufSerializer implements Serializer {

  private OutputStream out;

  @Override
  public void open(OutputStream outStream) throws IOException {
    out = outStream;
  }

  @Override
  public void serialize(Message message) throws IOException {
    message.writeDelimitedTo(out);
  }

  @Override
  public void close() throws IOException {
    if (out != null) {
      out.close();
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy