V3Writer

Struct V3Writer 

Source
pub struct V3Writer { /* private fields */ }
Expand description

V3 columnar metrics writer.

Accumulates metrics in columnar format with dictionary deduplication. Call V3Writer::write for each metric, then V3Writer::finalize to finalize and get the encoded data.

Implementations§

Source§

impl V3Writer

Source

pub fn new() -> Self

Creates a new V3 writer.

Source

pub fn metric_count(&self) -> usize

Returns the number of metrics written so far.

Source

pub fn estimated_uncompressed_len(&self) -> usize

Returns an estimate, in bytes, of the uncompressed size of the payload this writer would currently finalize to.

This exists so callers can decide when to stop adding metrics to a batch, rather than encoding an oversized batch and discovering afterwards that it has to be split and re-encoded. It is deliberately cheap: it inspects only the lengths of the accumulated columns, so it is O(1) and safe to call after every metric.

The figure is an estimate, not the exact finalized size. Dictionary string buffers are counted exactly, since they dominate for the high-cardinality workloads this guards against, while packed integer columns are counted at a fixed per-entry allowance because their true varint widths are only known once delta encoding runs during V3Writer::finalize. The allowance errs on the high side, so batches are cut slightly early rather than slightly late; callers MUST still check the finalized payload against their real size limits.

Source

pub fn write( &mut self, metric_type: V3MetricType, name: &str, ) -> V3MetricBuilder<'_>

Begins writing a new metric.

Returns a V3MetricBuilder that must be used to set the metric’s properties and add points, then closed with V3MetricBuilder::close.

Source

pub fn finalize(self) -> Result<V3EncodedMetrics, V3EncodeError>

Finalizes the writer and serializes the data to the given output buffer.

This performs delta encoding on all index arrays.

Trait Implementations§

Source§

impl Debug for V3Writer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for V3Writer

Source§

fn default() -> V3Writer

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.