use of org.apache.tez.runtime.library.input.UnorderedKVInput in project tez by apache.
the class FilterByWordOutputProcessor method run.
@Override
public void run() throws Exception {
if (inputs.size() != 1) {
throw new IllegalStateException("FilterByWordOutputProcessor processor can only work with a single input");
}
if (outputs.size() != 1) {
throw new IllegalStateException("FilterByWordOutputProcessor processor can only work with a single output");
}
for (LogicalInput input : inputs.values()) {
input.start();
}
for (LogicalOutput output : outputs.values()) {
output.start();
}
LogicalInput li = inputs.values().iterator().next();
if (!(li instanceof UnorderedKVInput)) {
throw new IllegalStateException("FilterByWordOutputProcessor processor can only work with ShuffledUnorderedKVInput");
}
LogicalOutput lo = outputs.values().iterator().next();
if (!(lo instanceof MROutput)) {
throw new IllegalStateException("FilterByWordOutputProcessor processor can only work with MROutput");
}
UnorderedKVInput kvInput = (UnorderedKVInput) li;
MROutput mrOutput = (MROutput) lo;
KeyValueReader kvReader = kvInput.getReader();
KeyValueWriter kvWriter = mrOutput.getWriter();
while (kvReader.next()) {
Object key = kvReader.getCurrentKey();
Object value = kvReader.getCurrentValue();
kvWriter.write(key, value);
}
}
Aggregations