use of edu.iu.dsc.tws.data.api.formatters.TextInputFormatter in project twister2 by DSC-SPIDAL.
the class WordCountExample method init.
@Override
public void init(Config config, int id, ResourcePlan resourcePlan) {
Config.Builder builder = new Config.Builder();
builder.put("input.file.path", "/home/pulasthi/git/twister2/twister2" + "/data/src/test/resources/TextInputFormatTestFile.text");
Config txtFileConf = builder.build();
Path path = new Path("/home/pulasthi/git/twister2/twister2/data/src/test/" + "resources/TextInputFormatTestFile.text");
@SuppressWarnings("unchecked") InputFormat txtInput = new TextInputFormatter(path);
txtInput.configure(txtFileConf);
int minSplits = 8;
try {
InputSplit[] inputSplits = txtInput.createInputSplits(minSplits);
InputSplitAssigner inputSplitAssigner = txtInput.getInputSplitAssigner(inputSplits);
MapperSource mapperSource = new MapperSource(txtInput, inputSplitAssigner.getNextInputSplit(null, id));
Mapper wordCountMapper = new Mapper();
wordCountMapper.setInputSource(mapperSource);
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations