Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub fn map_statistic_to_precompute_operator(
Statistic::Rate | Statistic::Increase => {
Ok(("MultipleIncrease".to_string(), "".to_string()))
}
Statistic::Topk => Ok(("CountMinSketchWithHeap".to_string(), "topk".to_string())),
_ => Err(format!("Statistic {statistic:?} not supported")),
}
}
Expand Down Expand Up @@ -157,6 +158,19 @@ mod tests {
));
}

#[test]
fn test_topk_maps_to_count_min_sketch_with_heap() {
let result = map_statistic_to_precompute_operator(
Statistic::Topk,
QueryTreatmentType::Approximate,
)
.unwrap();
assert_eq!(
result,
("CountMinSketchWithHeap".to_string(), "topk".to_string())
);
}

#[test]
fn test_get_is_collapsable() {
assert!(get_is_collapsable("sum_over_time", "sum"));
Expand Down
1 change: 1 addition & 0 deletions asap-common/dependencies/rs/sketch_db_common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ edition.workspace = true

[dependencies]
promql_utilities.workspace = true
sql_utilities.workspace = true
serde.workspace = true
serde_json.workspace = true
serde_yaml.workspace = true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AggregationReference {
pub aggregation_id: u64,
/// For circular_buffer policy: keep this many most recent aggregates
#[serde(skip_serializing_if = "Option::is_none")]
pub num_aggregates_to_retain: Option<u64>,
/// For read_based policy: remove aggregate after this many reads
#[serde(skip_serializing_if = "Option::is_none")]
pub read_count_threshold: Option<u64>,
}

impl AggregationReference {
pub fn new(aggregation_id: u64, num_aggregates_to_retain: Option<u64>) -> Self {
Self {
aggregation_id,
num_aggregates_to_retain,
read_count_threshold: None,
}
}

pub fn with_read_count_threshold(
aggregation_id: u64,
read_count_threshold: Option<u64>,
) -> Self {
Self {
aggregation_id,
num_aggregates_to_retain: None,
read_count_threshold,
}
}
}
Loading
Loading