Skip to content

fix: M item should be 0 after deserialize - #592

Merged
leerho merged 1 commit into
apache:masterfrom
proost:fix-var-opt-deserialize-m
Nov 20, 2026
Merged

leerho merged 1 commit into
apache:masterfrom
proost:fix-var-opt-deserialize-m

Conversation

@proost

@proost proost commented Nov 20, 2026

Copy link
Copy Markdown
Member

What i understand, M items are temporary during update.

Item go H region or M first. And then light enough items go M region from H regions.

After that choose candidate to be deleted. Finally surviving items go R.

If sketch's state transition is finished, then there should be no items with M.

So if i am correct, after deserialization there should be no items.

@proost
proost requested a review from leerho November 20, 2026 16:27
@proost proost self-assigned this Nov 20, 2026

@leerho leerho left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is right: at rest an estimation-mode sketch has h + r == k with the gap at slot h and m == 0, as Java's heapify sets it. I confirmed on master that any update after deserializing an estimation-mode sketch throws ("invariant violated when growing candidate set" for a light item, "invalid sketch state during heavy general update" for a heavy one), and the union is affected the same way through its gadget. The (r > 0 ? 1 : 0) came from cd747bf in 2020.

@leerho
leerho merged commit 35fb704 into apache:master Nov 20, 2026
21 checks passed
@proost
proost deleted the fix-var-opt-deserialize-m branch November 21, 2026 07:09
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.

2 participants