pub struct StringView { /* private fields */ }Expand description
A 16 byte handle on a string.
The layout is a u32 length and 12 bytes of payload. For a string of 12 bytes or fewer the
payload is the string, zero padded. For a longer one the first 4 bytes are the prefix, the next
4 are the index of the block holding it, and the last 4 are the offset into that block.
A view on its own cannot produce a long string, only a short one. That is deliberate: the
blocks live in the StringColumn and the borrow checker is what stops a view from outliving
them, rather than a rule somebody has to remember.
Implementations§
Source§impl StringView
impl StringView
Sourcepub fn inline(text: &str) -> Self
pub fn inline(text: &str) -> Self
A view on a string that fits inline.
§Panics
If the string is longer than INLINE_LIMIT. Callers that do not know the length go
through StringColumn::push, which decides.
Sourcepub fn prefix(&self) -> [u8; 4]
pub fn prefix(&self) -> [u8; 4]
The first four bytes, zero padded.
This is the whole point of the representation. Two strings with different prefixes are different, and two strings with the same prefix are usually equal, so a filter on a string column resolves without touching the payload on almost every row.
Sourcepub fn as_inline_str(&self) -> Option<&str>
pub fn as_inline_str(&self) -> Option<&str>
The string, when it is short enough to be in the view.
Sourcepub fn definitely_differs(&self, other: &Self) -> bool
pub fn definitely_differs(&self, other: &Self) -> bool
Whether these two views are definitely different, answered from the view alone.
A false here means the payloads have to be compared. A true means they do not, which on
a filter against a selective literal is almost every row.
Trait Implementations§
Source§impl Clone for StringView
impl Clone for StringView
Source§fn clone(&self) -> StringView
fn clone(&self) -> StringView
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more