1
|
package eu.dnetlib.data.mapreduce.hbase.broker.enrich;
|
2
|
|
3
|
import java.io.IOException;
|
4
|
|
5
|
import org.apache.commons.logging.Log;
|
6
|
import org.apache.commons.logging.LogFactory;
|
7
|
import org.apache.hadoop.hbase.client.Result;
|
8
|
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
|
9
|
import org.apache.hadoop.hbase.mapreduce.TableMapper;
|
10
|
|
11
|
public class DliArticleEnrichmentMapper extends TableMapper<ImmutableBytesWritable, ImmutableBytesWritable> {
|
12
|
|
13
|
protected ImmutableBytesWritable outValue;
|
14
|
|
15
|
protected ImmutableBytesWritable outKey;
|
16
|
|
17
|
private static final Log log = LogFactory.getLog(DliArticleEnrichmentMapper.class);
|
18
|
|
19
|
@Override
|
20
|
protected void setup(final Context context) {
|
21
|
outKey = new ImmutableBytesWritable();
|
22
|
outValue = new ImmutableBytesWritable();
|
23
|
}
|
24
|
|
25
|
@Override
|
26
|
protected void map(ImmutableBytesWritable key, Result value, Context context)
|
27
|
throws IOException, InterruptedException {
|
28
|
// TODO Auto-generated method stub
|
29
|
|
30
|
// DNGF d =
|
31
|
super.map(key, value, context);
|
32
|
}
|
33
|
|
34
|
private void emit(final Context context, final byte[] key, final byte[] value, final String entityType) {
|
35
|
outKey.set(key);
|
36
|
outValue.set(value);
|
37
|
try {
|
38
|
context.write(outKey, outValue);
|
39
|
context.getCounter("Broker Enrichment DLI articles", "entity type: " + entityType).increment(1);
|
40
|
} catch (Exception e) {
|
41
|
throw new IllegalArgumentException(e);
|
42
|
}
|
43
|
}
|
44
|
|
45
|
}
|