pub struct ColumnarExport {
pub timestamps: Vec<i64>,
pub metrics: Vec<String>,
pub values: Vec<f64>,
}Expand description
A flat, owned columnar representation of exported time-series data.
ColumnarExport stores three parallel vectors:
timestamps: Unix epoch milliseconds.metrics: series / metric names.values: observed measurement values.
It is independent of the arrow-export feature and is always compiled.
Use it as a lightweight bridge to CSV, TSV, or JSON exports for small to
medium datasets, or as a staging area before Arrow conversion.
Fields§
§timestamps: Vec<i64>Parallel array of Unix epoch milliseconds.
metrics: Vec<String>Parallel array of metric / series names.
values: Vec<f64>Parallel array of observed values.
Implementations§
Source§impl ColumnarExport
impl ColumnarExport
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create a ColumnarExport pre-allocated for capacity rows.
Sourcepub fn from_points(points: &[ExportedPoint]) -> Self
pub fn from_points(points: &[ExportedPoint]) -> Self
Populate from a slice of ExportedPoints.
Sourcepub fn push(&mut self, timestamp_ms: i64, metric: impl Into<String>, value: f64)
pub fn push(&mut self, timestamp_ms: i64, metric: impl Into<String>, value: f64)
Append a single row.
Sourcepub fn to_points(&self) -> Vec<ExportedPoint>
pub fn to_points(&self) -> Vec<ExportedPoint>
Convert to a Vec<ExportedPoint>.
Sourcepub fn to_csv(&self, path: &Path) -> TsdbResult<()>
pub fn to_csv(&self, path: &Path) -> TsdbResult<()>
Write this export as CSV to the file at path.
The header row is timestamp_ms,metric,value.
Sourcepub fn to_tsv(&self, path: &Path) -> TsdbResult<()>
pub fn to_tsv(&self, path: &Path) -> TsdbResult<()>
Write this export as TSV (tab-separated values) to the file at path.
The header row is timestamp_ms\tmetric\tvalue.
Sourcepub fn to_json(&self) -> TsdbResult<Value>
pub fn to_json(&self) -> TsdbResult<Value>
Serialize this export to a JSON array.
Each element is {"timestamp_ms": <i64>, "metric": <str>, "value": <f64>}.
Sourcepub fn to_json_string(&self) -> TsdbResult<String>
pub fn to_json_string(&self) -> TsdbResult<String>
Serialize this export to a JSON string.
Sourcepub fn filter_metric(&self, metric: &str) -> Self
pub fn filter_metric(&self, metric: &str) -> Self
Filter rows to only those matching the given metric name, returning a
new ColumnarExport.
Sourcepub fn filter_time_range(&self, start_ms: i64, end_ms: i64) -> Self
pub fn filter_time_range(&self, start_ms: i64, end_ms: i64) -> Self
Filter rows to the given time range [start_ms, end_ms] inclusive.
Sourcepub fn sort_by_timestamp(&mut self)
pub fn sort_by_timestamp(&mut self)
Sort rows by timestamp in ascending order (in-place).
Sourcepub fn value_stats(&self) -> ColumnarStats
pub fn value_stats(&self) -> ColumnarStats
Compute basic descriptive statistics over the value column.
Sourcepub fn from_csv(path: &Path) -> TsdbResult<Self>
pub fn from_csv(path: &Path) -> TsdbResult<Self>
Read a CSV file previously written by to_csv back into a
ColumnarExport.
Trait Implementations§
Source§impl Clone for ColumnarExport
impl Clone for ColumnarExport
Source§fn clone(&self) -> ColumnarExport
fn clone(&self) -> ColumnarExport
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ColumnarExport
impl Debug for ColumnarExport
Source§impl Default for ColumnarExport
impl Default for ColumnarExport
Source§fn default() -> ColumnarExport
fn default() -> ColumnarExport
Auto Trait Implementations§
impl Freeze for ColumnarExport
impl RefUnwindSafe for ColumnarExport
impl Send for ColumnarExport
impl Sync for ColumnarExport
impl Unpin for ColumnarExport
impl UnsafeUnpin for ColumnarExport
impl UnwindSafe for ColumnarExport
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