Revision 58039
Added by Claudio Atzori about 4 years ago
modules/dnet-mapreduce-jobs/trunk/src/main/java/eu/dnetlib/data/mapreduce/hbase/dataexport/ExportInformationSpaceMapper2DHP.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.data.mapreduce.hbase.dataexport; |
2 | 2 |
|
3 |
import com.fasterxml.jackson.annotation.JsonInclude; |
|
4 |
import com.fasterxml.jackson.databind.ObjectMapper; |
|
3 | 5 |
import com.google.gson.Gson; |
4 | 6 |
import com.google.protobuf.InvalidProtocolBufferException; |
5 | 7 |
import eu.dnetlib.data.mapreduce.util.DedupUtils; |
... | ... | |
37 | 39 |
|
38 | 40 |
private MultipleOutputs multipleOutputs; |
39 | 41 |
|
40 |
private Gson g;
|
|
42 |
private ObjectMapper objectMapper;
|
|
41 | 43 |
|
42 | 44 |
@Override |
43 | 45 |
protected void setup(final Context context) throws IOException, InterruptedException { |
... | ... | |
46 | 48 |
keyOut = new Text(); |
47 | 49 |
valueOut = new Text(); |
48 | 50 |
multipleOutputs = new MultipleOutputs(context); |
49 |
g = new Gson(); |
|
51 |
objectMapper = new ObjectMapper() |
|
52 |
.setSerializationInclusion(JsonInclude.Include.NON_NULL); |
|
50 | 53 |
} |
51 | 54 |
|
52 | 55 |
@Override |
... | ... | |
101 | 104 |
} |
102 | 105 |
if (result != null) { |
103 | 106 |
keyOut.set(result.getClass().getName()); |
104 |
valueOut.set(g.toJson(result));
|
|
107 |
valueOut.set(objectMapper.writeValueAsString(result));
|
|
105 | 108 |
|
106 | 109 |
final String namedOutput = result.getClass().getSimpleName().toLowerCase(); |
107 | 110 |
multipleOutputs.write(namedOutput, keyOut, valueOut, namedOutput + "/" + namedOutput); |
Also available in: Unified diff
use jackson object mapper to serialize dhp oaf model ignoring blank properties