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

com.twitter.elephantbird.pig.util.NullWritableConverter Maven / Gradle / Ivy

There is a newer version: 4.17
Show newest version
package com.twitter.elephantbird.pig.util;

import java.io.IOException;

import org.apache.hadoop.io.NullWritable;
import org.apache.pig.ResourceSchema.ResourceFieldSchema;
import org.apache.pig.data.DataByteArray;
import org.apache.pig.data.DataType;

/**
 * Supports conversion from NullWritable to Pig null, and from all Pig types to {@link NullWritable}
 * .
 *
 * @author Andy Schlaikjer
 */
public class NullWritableConverter extends AbstractWritableConverter {
  public NullWritableConverter() {
    super(NullWritable.get());
  }

  @Override
  public ResourceFieldSchema getLoadSchema() throws IOException {
    ResourceFieldSchema schema = new ResourceFieldSchema();
    schema.setType(DataType.NULL);
    return schema;
  }

  @Override
  public Object bytesToObject(DataByteArray dataByteArray) throws IOException {
    return null;
  }

  @Override
  public NullWritable toWritable(Object value) throws IOException {
    return writable;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy