Project

General

Profile

« Previous | Next » 

Revision 57560

Added one counter to count the number of results per community

View differences:

modules/dnet-mapreduce-jobs/trunk/src/main/java/eu/dnetlib/data/mapreduce/hbase/propagation/communitythroughorganization/PropagationCommunityThroughOrganizationFileReducer.java
58 58

  
59 59
        if(communities.size() > 0){
60 60
            final ResultProtos.Result.Metadata.Builder metadata = ResultProtos.Result.Metadata.newBuilder();
61
            communities.stream().forEach(community->metadata.addContext(Utils.getContext(community, ORGANIZATION_COMMUNITY_TRUST, CLASS_ORGANIZATION_ID, DATA_INFO_TYPE,CLASS_ORGANIZATION_NAME)));
61
            communities.stream().forEach(community->
62
                                            {metadata.addContext(Utils.getContext(community, ORGANIZATION_COMMUNITY_TRUST, CLASS_ORGANIZATION_ID, DATA_INFO_TYPE,CLASS_ORGANIZATION_NAME));
63
                                            context.getCounter(COUNTER_PROPAGATION, "added result to community " + community).increment(resultIds.size());});
64

  
62 65
            for(String result: resultIds){
63 66
                keyOut.set(result);
64 67
                outValue.set(JsonFormat.printToString(Utils.getUpdate(metadata, result)).getBytes());
......
66 69
                context.getCounter(COUNTER_PROPAGATION, "added community to result").increment(communities.size());
67 70
            }
68 71

  
72

  
73

  
69 74
        }
70 75

  
71 76

  
modules/dnet-mapreduce-jobs/trunk/src/main/java/eu/dnetlib/data/mapreduce/hbase/propagation/communitythroughorganization/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