1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// SPDX-License-Identifier: Apache-2.0
// Copyright (c) 2026-present, Structured World Foundation
//! Merge-on-read delete materialization for columnar segments.
//!
//! Builds the positional [`DeleteBitmap`] for a columnar segment from the range
//! tombstones that cover its rows below the compaction watermark, reusing the
//! same monotonic active-set sweep as the compaction stream's
//! `covered_by_applied_tombstone`. The bitmap is a pure membership set: a
//! position is marked iff its entry is deleted for every live snapshot (some
//! active tombstone strictly below the watermark outranks the entry's seqno).
//! Deletes at or above the watermark stay as ordinary tombstones in higher
//! levels until a later compaction, exactly as the copy-on-write drop path
//! treats them.
use crate::;
use Vec;
/// Builds a positional delete-bitmap for a columnar segment.
///
/// `rows` yields each entry's `(user_key, seqno)` in the segment's physical
/// position order — block-index order, every stored version a distinct
/// position. This is the SAME numbering the writer assigns when it transposes
/// the entries and the read mask checks via
/// [`DataBlock::from_columnar_block_masked`](crate::table::data_block::DataBlock),
/// so a marked position drops the exact entry the merge-on-read compaction
/// resolved as deleted.
///
/// `tombstones` is the whole-version range-tombstone set; only those strictly
/// below `watermark` (visible to the oldest live snapshot) materialize. A
/// position is marked iff an active below-watermark tombstone outranks its
/// entry's seqno (`entry_seqno < tombstone_seqno`), matching the stream's
/// `covered_by_applied_tombstone`.
///
/// Entries must arrive in non-decreasing `user_key` order (guaranteed by the
/// segment layout: keys ascend, versions of one key descend by seqno), so the
/// active set is swept monotonically in one pass.
///
/// The body is `core` + `alloc` only (active-set sweep over `RangeTombstone`s):
/// it rides on the same range-tombstone-application machinery as the compaction
/// stream, which is currently `std`-gated in the worker, so this module is gated
/// to match. It un-gates trivially alongside that layer.
// `pub` (not `pub(crate)`) inside this crate-private module: clippy flags the
// redundant restriction since the module itself is already crate-scoped.
///
/// # Errors
///
/// Returns [`crate::Error::InvalidHeader`] if the row count exceeds `u32::MAX`:
/// positions are u32 by the bitmap's design, so a larger segment cannot be
/// addressed without aliasing earlier rows.