Package com.twitter.elephantbird.pig.store

Source Code of com.twitter.elephantbird.pig.store.LzoRawBytesStorage

package com.twitter.elephantbird.pig.store;

import java.io.IOException;

import org.apache.hadoop.mapreduce.OutputFormat;
import org.apache.pig.data.DataByteArray;
import org.apache.pig.data.Tuple;

import com.twitter.elephantbird.mapreduce.io.RawBytesWritable;
import com.twitter.elephantbird.mapreduce.output.LzoBinaryBlockOutputFormat;
import com.twitter.elephantbird.pig.load.LzoBaseLoadFunc;
import com.twitter.elephantbird.pig.load.LzoRawBytesLoader;

/**
* Stores raw byte[] records with LZO block-compression, suitable for reading via
* {@link LzoRawBytesLoader} or some other {@link LzoBaseLoadFunc}.
*
* @author Andy Schlaikjer
*/
public class LzoRawBytesStorage extends BaseStoreFunc {
  private final RawBytesWritable writable = new RawBytesWritable();

  @Override
  @SuppressWarnings("rawtypes")
  public OutputFormat getOutputFormat() throws IOException {
    return new LzoBinaryBlockOutputFormat();
  }

  @Override
  public void putNext(Tuple t) throws IOException {
    DataByteArray data = null;
    if (t == null || t.size() < 1 || (data = (DataByteArray) t.get(0)) == null) {
      // TODO(Andy Schlaikjer): Signal error
      return;
    }
    writable.set(data.get());
    writeRecord(null, writable);
  }
}
TOP

Related Classes of com.twitter.elephantbird.pig.store.LzoRawBytesStorage

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.