Created
April 11, 2013 15:55
-
-
Save anonymous/5364601 to your computer and use it in GitHub Desktop.
PigStorage
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
import com.google.common.base.Preconditions; | |
import com.ioffer.hadoop.input.LimitedDailyLogFormat; | |
import org.apache.hadoop.mapreduce.InputFormat; | |
import org.apache.hadoop.mapreduce.Job; | |
import org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigTextInputFormat; | |
import org.apache.pig.builtin.PigStorage; | |
import java.io.IOException; | |
public class LimitedDailyLogLoader extends PigStorage { | |
private Integer limit; | |
private static final String DELIMITER = Character.toString('\t'); | |
public LimitedDailyLogLoader(String limit) { | |
this(Integer.parseInt(limit), DELIMITER); | |
} | |
public LimitedDailyLogLoader(String limit, String delimeter) { | |
this(Integer.parseInt(limit), delimeter); | |
} | |
public LimitedDailyLogLoader(Integer limit, String delimiter) { | |
super(delimiter); | |
Preconditions.checkArgument(limit != null && limit > 0, "limit is null or less than zero"); | |
this.limit = limit; | |
} | |
@Override | |
public InputFormat getInputFormat() { | |
return new PigTextInputFormat(); | |
} | |
@Override | |
public void setLocation(String location, Job job) throws IOException { | |
LimitedDailyLogFormat.setInputPaths(job, location, limit); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment