use std::collections::HashMap;
pub type Timestamp = u64;
pub type Value = f64;
pub type TagSet = HashMap<String, String>;
#[derive(Debug, Clone, PartialEq)]
pub struct DataPoint {
pub timestamp: Timestamp,
pub value: Value,
pub tags: TagSet,
}
#[derive(Debug, Default, Clone)] pub struct TimeSeriesChunk {
pub timestamps: Vec<Timestamp>,
pub values: Vec<Value>,
pub tags: Vec<TagSet>,
}
impl TimeSeriesChunk {
pub fn append(&mut self, point: DataPoint) {
self.timestamps.push(point.timestamp);
self.values.push(point.value);
self.tags.push(point.tags);
}
pub fn append_batch(&mut self, points: Vec<DataPoint>) {
let additional_capacity = points.len();
self.timestamps.reserve(additional_capacity);
self.values.reserve(additional_capacity);
self.tags.reserve(additional_capacity);
for point in points {
self.timestamps.push(point.timestamp);
self.values.push(point.value);
self.tags.push(point.tags);
}
}
pub fn len(&self) -> usize {
self.timestamps.len()
}
pub fn is_empty(&self) -> bool {
self.timestamps.is_empty()
}
}