reset Sample

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
This commit is contained in:
Ruihang Xia
2024-03-13 23:32:22 +08:00
parent aa125a50f9
commit 89c51d9b87
2 changed files with 9 additions and 5 deletions

View File

@@ -28,7 +28,7 @@ use crate::proto::PromLabel;
use crate::repeated_field::Clear;
/// [TablesBuilder] serves as an intermediate container to build [RowInsertRequests].
#[derive(Default)]
#[derive(Default, Debug)]
pub(crate) struct TablesBuilder {
tables: HashMap<String, TableBuilder>,
}
@@ -68,6 +68,7 @@ impl TablesBuilder {
}
/// Builder for one table.
#[derive(Debug)]
pub(crate) struct TableBuilder {
/// Column schemas.
schema: Vec<ColumnSchema>,

View File

@@ -26,10 +26,13 @@ use crate::prom_store::METRIC_NAME_LABEL_BYTES;
use crate::repeated_field::{Clear, RepeatedField};
impl Clear for Sample {
fn clear(&mut self) {}
fn clear(&mut self) {
self.timestamp = 0;
self.value = 0.0;
}
}
#[derive(Default, Clone)]
#[derive(Default, Clone, Debug)]
pub struct PromLabel {
pub name: Bytes,
pub value: Bytes,
@@ -76,7 +79,7 @@ impl PromLabel {
}
}
#[derive(Default)]
#[derive(Default, Debug)]
pub struct PromTimeSeries {
pub table_name: String,
pub labels: RepeatedField<PromLabel>,
@@ -161,7 +164,7 @@ impl PromTimeSeries {
}
}
#[derive(Default)]
#[derive(Default, Debug)]
pub struct PromWriteRequest {
table_data: TablesBuilder,
series: PromTimeSeries,