Skip to content

Instantly share code, notes, and snippets.

@toddlipcon
Created February 11, 2010 00:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toddlipcon/301034 to your computer and use it in GitHub Desktop.
Save toddlipcon/301034 to your computer and use it in GitHub Desktop.
package org.apache.hadoop.mapred;
import java.io.*;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.BytesWritable;
import org.apache.hadoop.util.ReflectionUtils;
class Test {
public static void main(String []args) throws Exception {
Configuration conf = new Configuration();
DataInput in = new DataInputStream(new FileInputStream(args[0]));
JobClient.RawSplit raws[] = JobClient.readSplitFile(in);
for (JobClient.RawSplit raw : raws) {
InputSplit is = (InputSplit)ReflectionUtils.newInstance(
Class.forName(raw.getClassName()), conf);
BytesWritable bw = raw.getBytes();
is.readFields(new DataInputStream(
new ByteArrayInputStream(bw.getBytes(), 0, bw.getLength())));
System.out.println(is);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment