pub struct TidBitmap { /* private fields */ }Expand description
A sparse, sorted set of row IDs backed by a Roaring bitmap.
Row IDs are u32 because Roaring’s API is u32-native; tables
with more than 4 billion rows need to partition by another
dimension (typically segment id) and use multiple bitmaps.
Implementations§
Source§impl TidBitmap
impl TidBitmap
Sourcepub fn with_cap_bytes(cap_bytes: usize) -> Self
pub fn with_cap_bytes(cap_bytes: usize) -> Self
Create an empty bitmap with a custom cap (bytes). Use 0 to disable the cap entirely — useful for tests and in-memory benchmarks.
Sourcepub fn insert(&mut self, tid: u32) -> Result<bool, BitmapError>
pub fn insert(&mut self, tid: u32) -> Result<bool, BitmapError>
Insert a row ID. Returns BitmapError::TooLarge if the
resulting size exceeds the configured cap; the row is
NOT inserted in that case so the caller can recover by
switching strategies.
Sourcepub fn extend_from_iter(
&mut self,
iter: impl IntoIterator<Item = u32>,
) -> Result<usize, BitmapError>
pub fn extend_from_iter( &mut self, iter: impl IntoIterator<Item = u32>, ) -> Result<usize, BitmapError>
Bulk insert from any iterator of row IDs. Stops on the first cap violation and returns the number of IDs that were successfully inserted before the cap was hit.
Sourcepub fn contains(&self, tid: u32) -> bool
pub fn contains(&self, tid: u32) -> bool
Returns true when the bitmap contains the given row ID. O(log n) lookup — Roaring does block search internally.
Sourcepub fn intersect_with(&mut self, other: &TidBitmap)
pub fn intersect_with(&mut self, other: &TidBitmap)
In-place AND with another bitmap. Used by the planner’s
WHERE a = 1 AND b = 2 rewrite: lookup each side, AND
the results.
Sourcepub fn union_with(&mut self, other: &TidBitmap)
pub fn union_with(&mut self, other: &TidBitmap)
In-place OR with another bitmap. Used by WHERE a OR b
patterns and IN list expansion.
Sourcepub fn difference_with(&mut self, other: &TidBitmap)
pub fn difference_with(&mut self, other: &TidBitmap)
In-place ANDNOT — remove every row ID also present in
other. Used by WHERE a AND NOT b patterns and EXCEPT
queries.
Sourcepub fn iter(&self) -> impl Iterator<Item = u32> + '_
pub fn iter(&self) -> impl Iterator<Item = u32> + '_
Iterate row IDs in sorted ascending order. The heap fetcher uses this to read pages sequentially.
Sourcepub fn into_sorted_vec(self) -> Vec<u32>
pub fn into_sorted_vec(self) -> Vec<u32>
Drain all row IDs in sorted ascending order, consuming
the bitmap. Equivalent to iter().collect() but releases
the inner storage as soon as iteration completes.
Sourcepub fn group_by_page(&self, rows_per_page: u32) -> Vec<(u32, Vec<u32>)>
pub fn group_by_page(&self, rows_per_page: u32) -> Vec<(u32, Vec<u32>)>
Group row IDs by their containing page number. Returns a
vector of (page_id, Vec<row_within_page>) pairs sorted
by page_id ascending. The heap fetcher reads each page
once and extracts every matching row in a single I/O.
rows_per_page is the table-specific constant — for
reddb’s default 8 KB pages with ~64-byte rows it’s
roughly 128, but call sites pass the exact value from
their schema metadata.
Sourcepub fn union_cardinality(&self, other: &TidBitmap) -> u64
pub fn union_cardinality(&self, other: &TidBitmap) -> u64
Cardinality of the union with another bitmap, computed without materialising the union itself. Used by the planner’s cost estimator to compare AND vs OR rewrites without paying the merge cost.
Sourcepub fn intersection_cardinality(&self, other: &TidBitmap) -> u64
pub fn intersection_cardinality(&self, other: &TidBitmap) -> u64
Cardinality of the intersection with another bitmap, also without materialising the result.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TidBitmap
impl RefUnwindSafe for TidBitmap
impl Send for TidBitmap
impl Sync for TidBitmap
impl Unpin for TidBitmap
impl UnsafeUnpin for TidBitmap
impl UnwindSafe for TidBitmap
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request