basho/riak_dt — pull request #47 by lenary (2013-07-27 15:58:43+00:00)
Title: Optimised PN-Counter Format (aka PNCounters V2)

The first version of the PNCounter code literally used a pair of GCounters as its representation and deferred a lot of the behaviour down to GCounter functions.

However, there were issues with this, essentially to do with keeping the two lists of actors in sync (something needed for GC) and the fact that you store each actor twice, which is inefficient.

The new format is very similar to the structure of a GCounter, but the actor-count tuples include a count of both increments and decrements. For example:

```
Old Style: {[{a,4}],[{a,1},{b,2}]}
New Style: [{a,4,1},{b,0,2}]
```

I've updated `from_binary/1` to convert into the new structure every time, however there's also a new `to_binary/2` which can create the old style (should it be required for downgrades).