Created
March 22, 2012 14:48
-
-
Save tf0054/2158743 to your computer and use it in GitHub Desktop.
Hack#15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package org.hadoophacks.mapreduce.lib.input; | |
| import java.io.IOException; | |
| import org.apache.hadoop.io.Text; | |
| import org.apache.hadoop.mapreduce.InputSplit; | |
| import org.apache.hadoop.mapreduce.RecordReader; | |
| import org.apache.hadoop.mapreduce.TaskAttemptContext; | |
| import org.apache.hadoop.mapreduce.lib.input.CombineFileInputFormat; | |
| import org.apache.hadoop.mapreduce.lib.input.CombineFileRecordReader; | |
| import org.apache.hadoop.mapreduce.lib.input.CombineFileSplit; | |
| import org.apache.hadoop.conf.Configuration; | |
| public class CustomCombineFileInputFormat extends | |
| CombineFileInputFormat<Text, Text> { | |
| public RecordReader<Text, Text> createRecordReader( | |
| InputSplit split, TaskAttemptContext context) { | |
| try { | |
| Configuration conf = context.getConfiguration(); | |
| CombineFileRecordReader<Text, Text> reader = new CombineFileRecordReader<Text, Text>( | |
| (CombineFileSplit) split, context, CombineFileLineRecordReader.class); | |
| return reader; | |
| } catch (IOException e) { | |
| e.printStackTrace(); | |
| return null; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment