pub struct DictionaryBlock {
pub dictionary: Vec<String>,
pub encoded: Vec<(i64, u32)>,
}Expand description
A self-contained, serialisable dictionary-compressed block.
Fields§
§dictionary: Vec<String>Reverse dictionary: dictionary[code] → string value.
encoded: Vec<(i64, u32)>Encoded (timestamp_ms, code) pairs.
Implementations§
Source§impl DictionaryBlock
impl DictionaryBlock
Sourcepub fn from_data(data: &[(i64, &str)]) -> TsdbResult<Self>
pub fn from_data(data: &[(i64, &str)]) -> TsdbResult<Self>
Build a block from a slice of (timestamp_ms, &str) pairs.
Sourcepub fn decode(&self) -> TsdbResult<Vec<(i64, &str)>>
pub fn decode(&self) -> TsdbResult<Vec<(i64, &str)>>
Decode all (timestamp_ms, value_str) pairs.
Sourcepub fn decode_owned(&self) -> TsdbResult<Vec<(i64, String)>>
pub fn decode_owned(&self) -> TsdbResult<Vec<(i64, String)>>
Decode all samples into owned String values.
Sourcepub fn lookup_code(&self, code: u32) -> Option<&str>
pub fn lookup_code(&self, code: u32) -> Option<&str>
Look up the string for a given code.
Returns None if the code is out of range.
Sourcepub fn find_code(&self, value: &str) -> Option<u32>
pub fn find_code(&self, value: &str) -> Option<u32>
Find the code assigned to value, or None if it is not in the
dictionary.
Sourcepub fn get_value(&self, timestamp: i64) -> Option<&str>
pub fn get_value(&self, timestamp: i64) -> Option<&str>
Return the string value at the given timestamp_ms, or None if no
sample exists at that exact timestamp.
Sourcepub fn cardinality(&self) -> usize
pub fn cardinality(&self) -> usize
Number of distinct values in the dictionary.
Sourcepub fn compression_ratio(&self, avg_string_len: usize) -> f64
pub fn compression_ratio(&self, avg_string_len: usize) -> f64
Approximate compression ratio vs. storing raw strings.
Assumes average string length of 10 bytes and 8-byte timestamp.
Sourcepub fn filter_range(&self, start: i64, end: i64) -> TsdbResult<Vec<(i64, &str)>>
pub fn filter_range(&self, start: i64, end: i64) -> TsdbResult<Vec<(i64, &str)>>
Filter encoded samples to a timestamp range [start, end] (inclusive).
Sourcepub fn value_frequencies(&self) -> Vec<(&str, usize)>
pub fn value_frequencies(&self) -> Vec<(&str, usize)>
Return the frequency of each distinct value as (value, count) pairs,
sorted by count descending.
Trait Implementations§
Source§impl Clone for DictionaryBlock
impl Clone for DictionaryBlock
Source§fn clone(&self) -> DictionaryBlock
fn clone(&self) -> DictionaryBlock
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DictionaryBlock
impl Debug for DictionaryBlock
Source§impl<'de> Deserialize<'de> for DictionaryBlock
impl<'de> Deserialize<'de> for DictionaryBlock
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for DictionaryBlock
impl PartialEq for DictionaryBlock
Source§impl Serialize for DictionaryBlock
impl Serialize for DictionaryBlock
impl StructuralPartialEq for DictionaryBlock
Auto Trait Implementations§
impl Freeze for DictionaryBlock
impl RefUnwindSafe for DictionaryBlock
impl Send for DictionaryBlock
impl Sync for DictionaryBlock
impl Unpin for DictionaryBlock
impl UnsafeUnpin for DictionaryBlock
impl UnwindSafe for DictionaryBlock
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 more