1
|
package eu.dnetlib.data.mapreduce.hbase.broker.enrich;
|
2
|
|
3
|
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
|
4
|
import org.apache.hadoop.hbase.mapreduce.TableMapper;
|
5
|
|
6
|
/**
|
7
|
* Created by claudio on 21/02/2017.
|
8
|
*/
|
9
|
public abstract class AbstractEnrichmentMapper extends TableMapper<ImmutableBytesWritable, ImmutableBytesWritable> {
|
10
|
|
11
|
protected ImmutableBytesWritable outValue;
|
12
|
|
13
|
protected ImmutableBytesWritable outKey;
|
14
|
|
15
|
protected abstract String counterGroup();
|
16
|
|
17
|
@Override
|
18
|
protected void setup(final Context context) {
|
19
|
outKey = new ImmutableBytesWritable();
|
20
|
outValue = new ImmutableBytesWritable();
|
21
|
}
|
22
|
|
23
|
protected void emit(final Context context, final byte[] key, final byte[] value, final String entityType) {
|
24
|
outKey.set(key);
|
25
|
outValue.set(value);
|
26
|
try {
|
27
|
context.write(outKey, outValue);
|
28
|
context.getCounter(counterGroup(), "entity type: " + entityType).increment(1);
|
29
|
} catch (Exception e) {
|
30
|
throw new IllegalArgumentException(e);
|
31
|
}
|
32
|
}
|
33
|
|
34
|
}
|