You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The COMPARE_AND_CLEAR mutation type allows the user specify a value and to conditionally clear a key if the value is equal to that key. The count and possibly the sum index types should use this to remove keys that have been decremented to zero. In particular, this is good as with grouped aggregates, one can wind up in situations where if the grouping key is something that increases with time, then older grouping keys will never be garbage collected out. (For example, imagine a grouping column of, say, "day" to bucket together the number of records per day. Then if only k days of history are kept around, there will only be at most k non-zero index keys, but the older days are never cleared out.) Both the count and sum indexes treat null (i.e., unset keys) identically to keys set to zero.
The text was updated successfully, but these errors were encountered:
alecgrieser
changed the title
Count indexes should use clear when decremented to zero
Count indexes should be cleared when decremented to zero
Sep 29, 2019
One thing about sum that perhaps makes this more complicated is that a "sum" index can be zero either if all elements (or all elements in a group) are removed or if the sum is legitimately zero (because, say, all elements are zero or there are both positive and negative elements), and we probably do want to retain zero entries in that case, but we don't have a good way to distinguish the two.
It might perhaps make sense to add this add an option, with it set to "don't clear" by default for two reasons:
Behavior preservation
Keep the same behavior for "sum" and "count" indexes
Then we encourage (through documentation) that the option be enabled on count indexes but not sum indexes (but you can enable it if you either don't care about the zero sum groups or only have positive values in the sum).
…mented to zero (FoundationDB#1097)
This takes the approach suggested in the comment of making this an optional behavior defaulting to off, for the reasons stated there: it avoids incompatible changes and makes `SUM` and `COUNT` symmetrical.
The
COMPARE_AND_CLEAR
mutation type allows the user specify a value and to conditionally clear a key if the value is equal to that key. Thecount
and possibly thesum
index types should use this to remove keys that have been decremented to zero. In particular, this is good as with grouped aggregates, one can wind up in situations where if the grouping key is something that increases with time, then older grouping keys will never be garbage collected out. (For example, imagine a grouping column of, say, "day" to bucket together the number of records per day. Then if only k days of history are kept around, there will only be at most k non-zero index keys, but the older days are never cleared out.) Both thecount
andsum
indexes treat null (i.e., unset keys) identically to keys set to zero.The text was updated successfully, but these errors were encountered: