Skip to content

HollowSparseIntegerSet: keep values of records modified in a delta - #873

Draft
Sunjeet wants to merge 1 commit into
masterfrom
sunjeets/sparseintegerset-keep-modified-values
Draft

Sunjeet wants to merge 1 commit into
masterfrom
sunjeets/sparseintegerset-keep-modified-values

Conversation

@Sunjeet

@Sunjeet Sunjeet commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

HollowSparseIntegerSet.endUpdate() applied valuesToSet before valuesToClear. A record modified in a delta arrives as removedOrdinal(old) + addedOrdinal(new) carrying the same value, so the value was set and then immediately cleared:

  • A record whose indexed value didn't change (e.g. only its title changed) dropped out of the set.
  • A record that started matching the predicate was never added.

Fix: drop values from valuesToClear that the delta also sets. Netting the two sets, rather than only reordering to clear-then-set, also avoids a transient miss for concurrent readers, because the live set is updated in place when no resize is needed. Also removes the two stale comments around the loops (duplicate counting was removed in 2017; "first clear" no longer matched the code).

The class was originally written clear-then-set (7130286); a1145ab (2017-08-14) swapped the order, so every release since v2.7.0 is affected.

Testing

  • New HollowSparseIntegerSetTest.testDeltaKeepsValuesOfModifiedRecords: a delta that renames a 2009 movie (must stay indexed) and moves another movie into 2009 (must be added). Fails without the fix.
  • All com.netflix.hollow.core.index.* tests pass (252).

🤖 Generated with Claude Code

endUpdate() applied valuesToSet before valuesToClear. A record modified in a
delta arrives as a removed ordinal and an added ordinal carrying the same
value, so the value was set and then immediately cleared: a record whose
indexed value did not change dropped out of the set, and a record that
started matching the predicate was never added.

Don't clear values that the delta also sets. Netting the two sets, rather
than only clearing first, also avoids a transient miss for concurrent
readers, since the live set is updated in place when no resize is needed.

The set-then-clear order dates back to a1145ab (2017-08-14), so every
release that includes HollowSparseIntegerSet (v2.7.0 onward) is affected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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