Project

General

Profile

1
package eu.dnetlib.data.mapreduce.hbase.dedup.cc;
2

    
3
import java.io.IOException;
4

    
5
import org.apache.hadoop.hbase.KeyValue;
6
import org.apache.hadoop.hbase.client.Result;
7
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
8
import org.apache.hadoop.hbase.mapreduce.TableMapper;
9
import org.apache.hadoop.io.Text;
10

    
11
/**
12
 * Created by claudio on 14/10/15.
13
 */
14
public class HBaseToSimilarityGraphMapper extends TableMapper<Text, VertexWritable> {
15

    
16
	@Override
17
	protected void map(final ImmutableBytesWritable keyIn, final Result value, final Context context) throws IOException, InterruptedException {
18

    
19
		final VertexWritable vertex = new VertexWritable();
20
		final Text realKey = new Text(keyIn.copyBytes());
21

    
22
		vertex.checkAndSetMinimalVertex(realKey);
23
		vertex.addVertex(realKey);
24

    
25
		for (KeyValue kv : value.list()) {
26

    
27
			Text tmp = new Text(kv.getQualifier());
28
			vertex.checkAndSetMinimalVertex(tmp);
29
			vertex.addVertex(tmp);
30
		}
31

    
32
		context.write(realKey, vertex);
33

    
34
		for (Text edge : vertex.getEdges()) {
35
			context.write(edge, vertex.makeMessage());
36
		}
37
	}
38

    
39
}
(3-3/6)