Revision 57560
Added by Miriam Baglioni over 4 years ago
PropagationCommunityThroughOrganizationReducer.java | ||
---|---|---|
37 | 37 |
DedupedList communities = new DedupedList(); |
38 | 38 |
Set<String> resultIds = new HashSet<>(); |
39 | 39 |
|
40 |
while(it.hasNext()){
|
|
40 |
while (it.hasNext()) {
|
|
41 | 41 |
Value v = Value.fromJson(it.next().toString()); |
42 |
switch (v.getType()){ |
|
42 |
switch (v.getType()) {
|
|
43 | 43 |
case fromorganization: |
44 | 44 |
communities.addAll(DedupedList.fromJson(v.getValue())); |
45 | 45 |
break; |
... | ... | |
51 | 51 |
|
52 | 52 |
} |
53 | 53 |
|
54 |
if(communities.size() > 0){
|
|
54 |
if (communities.size() > 0) {
|
|
55 | 55 |
final ResultProtos.Result.Metadata.Builder metadata = ResultProtos.Result.Metadata.newBuilder(); |
56 |
communities.stream().forEach(community->metadata.addContext(Utils.getContext(community, ORGANIZATION_COMMUNITY_TRUST, CLASS_ORGANIZATION_ID, DATA_INFO_TYPE,CLASS_ORGANIZATION_NAME))); |
|
57 |
for(String result: resultIds){ |
|
56 |
communities.stream().forEach(community -> { |
|
57 |
metadata.addContext(Utils.getContext(community, ORGANIZATION_COMMUNITY_TRUST, CLASS_ORGANIZATION_ID, DATA_INFO_TYPE, CLASS_ORGANIZATION_NAME)); |
|
58 |
context.getCounter(COUNTER_PROPAGATION, "added result to community " + community).increment(resultIds.size()); |
|
59 |
}); |
|
60 |
for (String result : resultIds) { |
|
58 | 61 |
final Put put = new Put(Bytes.toBytes(result)).add(Bytes.toBytes("result"), Bytes.toBytes("update_" + System.nanoTime()), Utils.getUpdate(metadata, result).toByteArray()); |
59 | 62 |
keyOut.set(Bytes.toBytes(result)); |
60 | 63 |
context.write(keyOut, put); |
... | ... | |
65 | 68 |
|
66 | 69 |
} |
67 | 70 |
|
68 |
|
|
69 | 71 |
} |
Also available in: Unified diff
Added one counter to count the number of results per community