Skip to content

threshold_total: a zero count is an absent key - #1018

Closed
frankmcsherry wants to merge 1 commit into
TimelyDataflow:master-nextfrom
frankmcsherry:threshold-total-zero-count
Closed

frankmcsherry wants to merge 1 commit into
TimelyDataflow:master-nextfrom
frankmcsherry:threshold-total-zero-count

Conversation

@frankmcsherry

Copy link
Copy Markdown
Member

Fixes #992.

threshold_total called thresh on a key's count before and after each update, including when that count was zero. distinct_total passes |_,_| 1, so a key whose count fell to zero produced thresh(0) - thresh(1) = 0 and was never retracted: on master-next, +1 at time 1 and -1 at time 2 output only +1 at time 1. Whether a zero count reached thresh at all depended on whether the trace had merged away the cancelling updates. This dates from eac75b4 (2019), which replaced |_,c| if c.is_zero() { 0 } else { 1 } with |_,_| 1.

A zero count now contributes nothing, and thresh is not called on it. The rule is stated once, as a helper both counts go through, and in the method's docs. #993 makes the same change.

Test

distinct_total_zero_count in tests/threshold.rs has a key leave and return, with all updates in one batch and with one batch per time. It fails without this change. cargo test -p differential-dataflow passes.

Reported by @bos in #992.

🤖 Generated with Claude Code

https://claude.ai/code/session_019XsakwFGwtESwZ1gSYwG4o

Fixes TimelyDataflow#992.

`threshold_total` called `thresh` on a key's count before and after each update,
including when that count was zero. `distinct_total` passes `|_,_| 1`, so a key
whose count fell to zero produced `thresh(0) - thresh(1) = 0` and was never
retracted. Whether a zero count reached `thresh` at all depended on whether the
trace had merged away the cancelling updates.

A zero count now contributes nothing, and `thresh` is not called on it.

Reported by Bryan O'Sullivan in TimelyDataflow#992.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_019XsakwFGwtESwZ1gSYwG4o
@frankmcsherry

Copy link
Copy Markdown
Member Author

Closing in favor of #993, which makes the same change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant