Skip to content

Document that Clear turns copy-on-write off - #596

Merged
lemire merged 1 commit into
masterfrom
doc-clear-cow
Nov 12, 2026
Merged

lemire merged 1 commit into
masterfrom
doc-clear-cow

Conversation

@lemire

@lemire lemire commented Nov 12, 2026

Copy link
Copy Markdown
Member

Clear() resets a bitmap to the state of a new one, including turning copy-on-write off. This has been the behavior since copy-on-write was introduced (originally *ra = roaringArray{}), but it was not documented. It also matters for bitmaps loaded with FromBuffer, which turns copy-on-write on internally: after Clear they become ordinary bitmaps again.

Changes:

  • Document this on Clear() in both roaring and roaring64.
  • Xor and AndNot of a 32-bit bitmap with itself called Clear(), so they silently dropped the copy-on-write setting. They now empty the bitmap and keep the setting, matching roaring64.Xor.
  • Tests: TestClearResetsCopyOnWrite and TestClearResetsCopyOnWrite64.

Supersedes #594.

Clear resets a bitmap to the state of a new one, which includes turning
copy-on-write off. This has been the behavior since copy-on-write was
introduced, but it was not documented. State it on Clear in both the
32-bit and 64-bit packages.

Xor and AndNot of a 32-bit bitmap with itself called Clear, so they
also dropped the copy-on-write setting as a side effect. They now empty
the bitmap without changing the setting, as roaring64 Xor already does.
@lemire
lemire merged commit 340bdf6 into master Nov 12, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant