pub struct DictionaryKeyEncoder { /* private fields */ }Expand description
Compact dictionary encoder that maps variable-length byte keys to u32 codes.
Pre-populate during query setup (Ring 2), then use the fast encode() path
during event processing (Ring 0). The encoder is Send for transfer to
reactor threads but not Sync — it’s designed for single-threaded access.
Implementations§
Source§impl DictionaryKeyEncoder
impl DictionaryKeyEncoder
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates a new encoder with pre-allocated capacity.
Use this when the approximate number of distinct keys is known (e.g., number of ticker symbols, region names).
Sourcepub fn encode(&self, key: &[u8]) -> Option<u32>
pub fn encode(&self, key: &[u8]) -> Option<u32>
Encodes a key to its compact u32 code (Ring 0 hot path).
Returns None if the key has not been inserted. This is a pure
hash map lookup with no allocation.
Sourcepub fn encode_or_insert(&mut self, key: &[u8]) -> Option<u32>
pub fn encode_or_insert(&mut self, key: &[u8]) -> Option<u32>
Encodes a key, inserting it if not already present (Ring 2 setup).
Allocates on first insertion of a new key. Subsequent calls for the same key return the existing code without allocation.
§Errors
Returns None if the dictionary already contains u32::MAX keys.
Sourcepub fn decode(&self, code: u32) -> Option<&[u8]>
pub fn decode(&self, code: u32) -> Option<&[u8]>
Decodes a compact code back to the original key bytes.
Returns None if the code is out of range.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DictionaryKeyEncoder
impl RefUnwindSafe for DictionaryKeyEncoder
impl Send for DictionaryKeyEncoder
impl Sync for DictionaryKeyEncoder
impl Unpin for DictionaryKeyEncoder
impl UnsafeUnpin for DictionaryKeyEncoder
impl UnwindSafe for DictionaryKeyEncoder
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 more