Skip to content
Merged
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
17 changes: 8 additions & 9 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion asap-query-engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ zstd = "0.13"
reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls"] }
tracing-appender = "0.2"
elastic_dsl_utilities.workspace = true
asap_sketchlib = { git = "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/ProjectASAP/asap_sketchlib", branch = "refactor/adopt-sketch-core-modules" }
asap_sketchlib = { git = "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/ProjectASAP/asap_sketchlib", branch = "main" }
# Persistence layer (SimpleMapStore parts / manifest / Tier-2 cache)
moka = { version = "0.12", features = ["sync"] }
memmap2 = "0.9"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::data_model::{
AggregateCore, AggregationType, KeyByLabelValues, MergeableAccumulator,
MultipleSubpopulationAggregate, SerializableToSink,
};
use asap_sketchlib::sketches::countmin::{CountMinSketch, CountMinSketchDelta};
use asap_sketchlib::sketches::countminsketch::{CountMinSketch, CountMinSketchDelta};
use serde_json::Value;
use std::collections::HashMap;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ use crate::data_model::{
AggregateCore, AggregationType, KeyByLabelValues, MergeableAccumulator,
MultipleSubpopulationAggregate, SerializableToSink,
};
use asap_sketchlib::sketches::cms_heap::{CmsHeapItem, CountMinSketchWithHeap};
use asap_sketchlib::sketches::countminsketch_topk::{CmsHeapItem, CountMinSketchWithHeap};
use serde_json::Value;
use std::collections::HashMap;

use promql_utilities::query_logics::enums::Statistic;

/// Count-Min Sketch with Heap accumulator — wraps `asap_sketchlib::sketches::CountMinSketchWithHeap`.
/// Core struct, update/merge/serde logic live in `asap_sketchlib::sketches::cms_heap`.
/// Core struct, update/merge/serde logic live in `asap_sketchlib::sketches::countminsketch_topk`.
/// This file retains QE-specific trait impls, legacy deserializers, and JSON output.
#[derive(Debug, Clone)]
pub struct CountMinSketchWithHeapAccumulator {
pub inner: CountMinSketchWithHeap,
}

// Re-export HeapItem so existing code using CountMinSketchWithHeapAccumulator::HeapItem still works.
pub use asap_sketchlib::sketches::cms_heap::CmsHeapItem as HeapItemReexport;
pub use asap_sketchlib::sketches::countminsketch_topk::CmsHeapItem as HeapItemReexport;

impl CountMinSketchWithHeapAccumulator {
pub fn new(row_num: usize, col_num: usize, heap_size: usize) -> Self {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Count Sketch accumulator — wraps `asap_sketchlib::sketches::count::CountSketch`.
//! Count Sketch accumulator — wraps `asap_sketchlib::sketches::countsketch::CountSketch`.
//!
//! This is the concrete accumulator reached from the modified-OTLP
//! `Metric.data = CountSketch{…}` hot path (PR C-CountSketch). Its
Expand All @@ -20,7 +20,7 @@
//! round-trip works end-to-end without that richer query surface.

use crate::data_model::{AggregateCore, AggregationType, KeyByLabelValues, SerializableToSink};
use asap_sketchlib::sketches::count::{CountSketch, CountSketchDelta};
use asap_sketchlib::sketches::countsketch::{CountSketch, CountSketchDelta};
use serde_json::Value;
use std::collections::HashMap;

Expand Down Expand Up @@ -178,11 +178,23 @@ impl CountSketchAccumulator {
.zip(pb.d_counts.iter())
.map(|((r, c), dc)| (*r, *c, *dc))
.collect();
// Proto-schema-divergence-tracker: the Go-side
// `CountSketchDelta` proto carries an `hh_keys` field
// (heavy-hitter candidate keys forwarded by the upstream
// Space-Saving tracker). The Rust wire-format struct now
// models it (`asap_sketchlib::CountSketchDelta::hh_keys`),
// but the vendored Rust proto bindings in
// `asap_otel_proto::sketchlib::v1` haven't been regenerated
// against the latest `.proto` yet, so no `hh_keys` arrive on
// the wire from Go producers. Sending an empty `hh_keys`
// disables the TopK rebuild path; it'll start firing once the
// proto-schema sync PR lands.
let delta = CountSketchDelta {
rows: pb.rows,
cols: pb.cols,
cells,
l2: pb.l2,
hh_keys: Vec::new(),
};
self.inner
.apply_delta(&delta)
Expand Down Expand Up @@ -302,7 +314,7 @@ impl AggregateCore for CountSketchAccumulator {
///
/// Hash compatibility with the agent is via the sketchlib hash
/// spec; the agent's `sketchlib-go::CountSketch` and the
/// backend's `asap_sketchlib::sketches::count::CountSketch` must use
/// backend's `asap_sketchlib::sketches::countsketch::CountSketch` must use
/// the same seed list (sketchlib's `portableHashSpec` /
/// `default_hash_spec`).
fn count_sketch_query_key(matrix: &Vec<Vec<f64>>, key: &str) -> f64 {
Expand Down
4 changes: 2 additions & 2 deletions asap-query-engine/tests/e2e_modified_otlp_sketch_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,7 @@ async fn e2e_count_min_sketch_msgpack_modified_otlp_path() {
// is what the Go producer (sketchlib-go) will emit once PR I's matching
// Go-side work lands.
let mut cms =
asap_sketchlib::sketches::countmin::CountMinSketch::new(rows as usize, cols as usize);
asap_sketchlib::sketches::countminsketch::CountMinSketch::new(rows as usize, cols as usize);
cms.update("user_a", 1.0);
cms.update("user_b", 1.0);
cms.update("user_a", 1.0);
Expand All @@ -1209,7 +1209,7 @@ async fn e2e_count_min_sketch_msgpack_modified_otlp_path() {

// Watermark advance using an empty msgpack sketch.
let empty =
asap_sketchlib::sketches::countmin::CountMinSketch::new(rows as usize, cols as usize);
asap_sketchlib::sketches::countminsketch::CountMinSketch::new(rows as usize, cols as usize);
let watermark_req = build_count_min_msgpack_export_request(
metric_name,
service_label,
Expand Down