com.twitter.scalding.commons.scheme.KeyValueByteScheme Maven / Gradle / Ivy
package com.twitter.scalding.commons.scheme;
import java.io.IOException;
import java.util.Arrays;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.BytesWritable;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.RecordReader;
import cascading.flow.FlowProcess;
import cascading.scheme.SinkCall;
import cascading.scheme.SourceCall;
import cascading.scheme.hadoop.WritableSequenceFile;
import cascading.tap.Tap;
import cascading.tuple.Fields;
import cascading.tuple.Tuple;
import cascading.tuple.TupleEntry;
/**
* Used in conjunction with VersionedKeyValSource.
*/
public class KeyValueByteScheme extends WritableSequenceFile {
public KeyValueByteScheme(Fields fields) {
super(fields, BytesWritable.class, BytesWritable.class);
}
public static byte[] getBytes(BytesWritable key) {
return Arrays.copyOfRange(key.getBytes(), 0, key.getLength());
}
@Override
public void sourceConfInit(FlowProcess extends Configuration> flowProcess,
Tap tap, Configuration conf) {
super.sourceConfInit(flowProcess, tap, conf);
conf.setClass("mapred.input.format.class", VersionedSequenceFileInputFormat.class,
org.apache.hadoop.mapred.InputFormat.class);
}
@Override
public boolean source(FlowProcess extends Configuration> flowProcess,
SourceCall
© 2015 - 2025 Weber Informatics LLC | Privacy Policy