runメソッドを単純に実装することができます。たとえば、このように、クリーンアップフェーズに直接短絡するブールフィールドがあります。
public class SkipMapper extends Mapper<LongWritable, Text, Text, Text> {
private boolean skip;
@Override
protected void map(LongWritable key, Text value,
Mapper<LongWritable, Text, Text, Text>.Context context)
throws IOException, InterruptedException {
// map with the matcher
if (match) {
skip = true;
}
}
@Override
public void run(Mapper<LongWritable, Text, Text, Text>.Context context)
throws IOException, InterruptedException {
setup(context);
try {
while (!skip && context.nextKeyValue()) {
map(context.getCurrentKey(), context.getCurrentValue(), context);
}
} finally {
cleanup(context);
}
}
}
ありがとう、トーマス、これは本当に役に立ちます... –