public static long calculateOffset(long offset,
Calculate the approximate offset from a given offset. The offset is the
number of added or removed entries. The result is 0 in most of the cases,
but sometimes it is a (positive or negative) multiple of the resolution,
such that on average, the sum of the returned value matches the sum of
the passed offsets.
offset - the high-resolution input offset
resolution - the resolution
the low-resolution offset (most of the time 0)
public static long adjustOffset(long oldCount,
This method ensures that the new approximate count (the old count plus
the calculated offset) does not go below 0.
Also, for large counts and resolutions larger than 10, it reduces the
resolution by a factor of 10 (further reducing the number of updates
needed by a factor of 10).
oldCount - the old count
calculatedOffset - the calculated offset (may not be 0)
resolution - the new (lower) resolution
the new offset
public static void adjustCountSync(NodeBuilder builder,
Adjust a counter in the given node. This method supports concurrent
changes. It uses multiple properties, and is less accurate, but can be
used in a multi-threaded environment, as it uses unique property names.