[ 
https://issues.apache.org/jira/browse/GOSSIP-63?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15901231#comment-15901231
 ] 

ASF GitHub Bot commented on GOSSIP-63:
--------------------------------------

Github user edwardcapriolo commented on a diff in the pull request:

    https://github.com/apache/incubator-gossip/pull/41#discussion_r104913013
  
    --- Diff: src/main/java/org/apache/gossip/crdt/GrowOnlyCounter.java ---
    @@ -0,0 +1,94 @@
    +package org.apache.gossip.crdt;
    +
    +
    +import java.lang.annotation.ElementType;
    +import java.util.HashMap;
    +import java.util.Map;
    +
    +public class GrowOnlyCounter implements CrdtCounter<Long, GrowOnlyCounter> 
{
    +
    +
    +    private final Map<String, Long> counters = new HashMap<>();
    +    private final String myID;
    +
    +    public GrowOnlyCounter(String myID) {
    +        this.myID = myID;
    +        counters.putIfAbsent(myID, 0L);
    +    }
    +
    +    private GrowOnlyCounter(String myID, Long count) {
    +        this.myID = myID;
    +        counters.putIfAbsent(myID, count);
    +    }
    +
    +    private GrowOnlyCounter(String myID, Map<String, Long> counters) {
    +        this.myID = myID;
    +        this.counters.putAll(counters);
    +    }
    +
    +
    +    @Override
    +    public GrowOnlyCounter merge(GrowOnlyCounter other) {
    --- End diff --
    
    For the other Crdt types they are immutable and merge returns a new 
instance. I would follow that pattern.


> Implement Crdt G-Counter
> ------------------------
>
>                 Key: GOSSIP-63
>                 URL: https://issues.apache.org/jira/browse/GOSSIP-63
>             Project: Gossip
>          Issue Type: New Feature
>            Reporter: Edward Capriolo
>




--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to