Skip to content

refactor(query-engine): split engine and storage naming - #137

Merged
zzylol merged 4 commits into
mainfrom
refactor/query-engine-storage-naming
May 12, 2026
Merged

zzylol merged 4 commits into
mainfrom
refactor/query-engine-storage-naming

Conversation

@zzylol

@zzylol zzylol commented May 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • keep query engines exposed as ASAPQueryEngine and ThanosQueryEngine
  • rename backend storage variants to SketchStore and GorillaObjectStore
  • remove stale alias/duplicate references such as thanos_archive, register_aliased, and ThanosForwardEngine
  • fix routing and Thanos HTTP tests after removing alias tuple registration

Verification

  • cargo test -p asap_types streaming_config::tests::deserialize_with_explicit_archive_pin -- --nocapture
  • cargo check -p query_engine_rust --lib
  • cargo check -p controller --lib
  • cargo test -p query_engine_rust --lib --no-run
  • git diff --check
  • rg "SketchWarmTier|GorillaS3Archive|sketch_warm_tier|gorilla_s3_archive|thanos_archive|register_aliased|with_query_engine_aliased|ThanosForwardEngine|ThanosForwardConfig|ThanosForwardError|DATA_SOURCE_THANOS_ARCHIVE" crates/asap_types/src asap-query-engine/src controller/src --glob "*.rs"

@zzylol
zzylol force-pushed the refactor/query-engine-storage-naming branch 2 times, most recently from 7133929 to 126c0a7 Compare May 11, 2026 23:27
zz_y and others added 4 commits May 11, 2026 21:25
After splitting StorageBackend enum names (SketchStore /
GorillaObjectStore), several routing tests still referenced the
pre-rename engine-id strings ('asap_query' / 'thanos_query') where
they should use the snake-case serde tags ('sketch_store' /
'gorilla_object_store') — YAML parses through serde, which only
accepts the canonical snake_case form.

Also:
- engine_by_id sort-order assertion now lists ids in ascending order
  (matching ids.sort() output).
- parse_storage_backend_engine_id now recognises 'double_write' /
  'prometheus_remote' (the JSON 'engine:' string for Mode-3 /
  double-write configurations), so json_payload_prometheus_remote_*
  resolves the engine correctly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zzylol
zzylol force-pushed the refactor/query-engine-storage-naming branch from 0f5bde2 to 392cc4f Compare May 12, 2026 03:35
@zzylol
zzylol merged commit c1373aa into main May 12, 2026
zzylol added a commit that referenced this pull request May 12, 2026
…op of #137

Builds on top of PR #137's storage/engine naming split. Where #137
stopped at `query-engines/` + kept `data_model/`, `precompute_operators/`,
`routing/`, two `controller_client.rs` files, and the `SimpleEngine`
type, this PR finishes the reorg:

- Crate rename: `asap-query-engine/` → `data_plane/` (folder + cargo
  package + binary name); the controller sibling is the "control plane"
- `query-engines/` → `query_engines/` (snake_case)
- Per-engine `_engine` suffix:
  - `asap_query/` → `asap_query_engine/`
  - `thanos_query/` → `thanos_query_engine/`
  - `prometheus/` → `prometheus_query_engine/`
- `warm_tier/` promoted from `asap_query_engine/warm_tier/` to a
  top-level `query_engines/warm_tier/` (it's shared infra, not
  asap_query-specific)
- `data_model/` → `stores/schema/` (storage schema types belong with
  storage)
- `precompute_operators/` → `precompute_engine/operators/` (accumulator
  impls belong under the engine that orchestrates them)
- `routing/` → `query_engines/routing/` (engine dispatcher, scoped to
  query path)
- `drivers/controller_client.rs` + `drivers/query/controller_client.rs`
  co-located into `drivers/controller_client/{config_fetcher.rs,
  miss_notifier.rs, mod.rs}`
- `stores/promsketch_store/` deleted (was commented out of the public
  API; not referenced)
- `SimpleEngine` struct renamed to `ASAPQueryEngine` (was a type alias on
  main); compat alias removed

Test counts after the reorg match origin/main:
- data_plane lib: 804 passed / 2 pre-existing failures
  (schema_timeline_dispatch_tests, documented in controller_todo §5) /
  4 ignored
- controller lib: 710/710; bins: 27/27

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
zzylol added a commit that referenced this pull request May 12, 2026
…nsolidate MutableEpoch dedup, write phase 5 plan doc

Three follow-ups:

1) Move `query_engines/warm_tier/` back into
   `query_engines/asap_query_engine/warm_tier/`. The earlier reorg
   promoted it on the assumption it was shared infra; audit shows
   only `asap_query_engine::engine` consumes it. PR #137's original
   nesting was correct.

2) Consolidate the duplicate `MutableEpoch` / `SealedEpoch` /
   `InternTable` implementations. Before: ~290 LOC of identical
   storage logic in `sketch_db/store/common.rs` (non-generic, payload
   = `Arc<dyn AggregateCore>`) and `sketch_db/index/epoch_columnar.rs`
   (generic over `P`). After: `store/common.rs` is a 50-LOC alias
   shim (`pub type MutableEpoch = epoch_columnar::MutableEpoch<Arc<dyn AggregateCore>>`,
   etc.); the generic version is the single implementation.

   Required adapter methods added on the generic side, gated on
   `P: Clone` where the legacy semantics needed owning copies:
   - `MutableEpoch::range_query_into_grouped` — emits the
     `HashMap<LabelValuesId, Vec<(TimestampRange, P)>>` shape
     `SketchStore` callers consume.
   - `MutableEpoch::exact_query_owned` — `Option<Vec<(LabelValuesId, P)>>`
     for cross-lock-boundary handoff.
   - `MutableEpoch::remove_windows` — ReadBased / CircularBuffer
     cleanup primitive.
   - `MutableEpoch::time_bounds` / `seal` — convenience wrappers.
   - Same triplet on `SealedEpoch` plus `distinct_window_count` and
     `unique_windows`.

   Fixed a latent UB in `SealedEpoch::from_mutable`: previously used
   `MaybeUninit::zeroed().assume_init()` + `mem::forget` to drain the
   payload column, which is undefined behavior for any `P` with
   non-trivial Drop. Replaced with safe `into_iter().zip(...)` —
   same O(M) cost, works for arbitrary `P` (including
   `Arc<dyn AggregateCore>`).

   Made `SealedEpoch.entries` public to match the legacy access
   pattern (a handful of call sites in `store/{global,per_key}.rs`
   read it directly for diagnostics + persistence flush).

3) Wrote `data_plane/docs/phase5-unification-plan.md` covering the
   three in-flight Phase-5 migrations:
   - M1: `AggSchema` → `SketchInstanceMetadata` (lifecycle fold)
   - M2: `aggregation_id` → `sid` (data-path identifier)
   - M3: legacy `Arc<dyn AggregateCore>` payload type retires
   File-by-file phases A–E, ordering, dependencies on the analyzer
   chain α-ε and Step Z legacy_expr, and a ~5-day estimate.

Test counts unchanged:
- data_plane lib: 792 passed / 2 pre-existing failures / 4 ignored
- controller lib: 710/710; bins: 27/27

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zzylol
zzylol deleted the refactor/query-engine-storage-naming branch July 17, 2026 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant