Skip to content

feat(sketch_db): implement EpochSource for SketchIndex - #162

Merged
zzylol merged 1 commit into
mainfrom
feat/index-epoch-source
May 13, 2026
Merged

zzylol merged 1 commit into
mainfrom
feat/index-epoch-source

Conversation

@zzylol

@zzylol zzylol commented May 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Phase 5 M2.3.6b — first step of porting persistence over to SketchIndex. The existing persistence flusher (store/persistence/flusher.rs) can now drive SketchIndex without any flusher-side changes; the agg_id: u64 field on SealedEpochRef / EpochSnapshot is reused to carry a sid.

Implementation

Four trait methods in index/mod.rs:

  • list_sealed_epochs — iterates series DashMap; emits one SealedEpochRef per (sid, epoch_id) with summed payload size.
  • snapshot_sealed_epoch — resolves sid metadata to label sketch payloads with their sketch_kind; precompute payloads carry their AggregateCore::type_name(). Sketches use raw bytes; precomputes serialize via SerializableToSink.
  • evict_sealed_epoch — drops the named epoch.
  • approx_memory_bytes — on-demand walk; fine at flusher tick cadence.

Plus an AggPayload::approx_bytes() helper.

Test plan

  • 4 new unit tests: list-only-sealed, snapshot-round-trip, evict, approx_memory.
  • cargo test -p data_plane --lib — 808/810 (2 pre-existing schema_timeline_dispatch failures unrelated).
  • cargo check --workspace clean.

What's next

M2.3.6c: wire the flusher in main.rs against SketchIndex instead of SketchStorePerKey. Implement the deferred on-restart read-back path.

🤖 Generated with Claude Code

Phase 5 M2.3.6b — first step of porting persistence over to
`SketchIndex`. Lets the existing persistence flusher
(`store/persistence/flusher.rs`) drive `SketchIndex` without any
flusher-side changes; the `agg_id: u64` field on `SealedEpochRef` /
`EpochSnapshot` is reused to carry a `sid`.

Implementation lives next to the SketchIndex impl block in
`index/mod.rs`. Four trait methods:

- `list_sealed_epochs` — iterates the `series` DashMap, walks each
  sid's `sealed_epochs` BTreeMap, emits one `SealedEpochRef` per
  (sid, epoch_id) with its approximate byte size summed across
  payloads.
- `snapshot_sealed_epoch` — resolves the sid's metadata to label
  sketch payloads with their `sketch_kind` for read-back dispatch;
  precompute payloads emit their `AggregateCore::type_name()`.
  Serializes sketch bytes (already opaque) and precompute bytes (via
  `SerializableToSink`).
- `evict_sealed_epoch` — drops the named epoch from `sealed_epochs`.
- `approx_memory_bytes` — on-demand walk over all sealed payloads.
  O(total sealed entries); fine at the flusher's tick cadence.

`AggPayload::approx_bytes()` helper computes per-payload size
(`bytes.len()` + struct overhead for sketches, `approx_memory_bytes()`
for precomputes).

4 new unit tests: list-only-sealed, snapshot-round-trips-sketch,
evict-drops-epoch, approx_memory-grows-with-sealed-state. 808/810
data_plane lib tests pass (2 pre-existing schema_timeline_dispatch
failures unrelated).

Next: M2.3.6c wires the flusher's startup against SketchIndex in
main.rs and implements the on-restart read-back path.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zzylol
zzylol merged commit 71e2a3c into main May 13, 2026
zzylol added a commit that referenced this pull request May 13, 2026
Phase 5 M2.3.6c — adds `SketchIndex::start_persistence` and
`SketchIndexPersistence` (the live persistence harness — manifest +
part cache + flusher handle), and constructs one in `main.rs` when
`--persistence-enabled` is passed.

The new persistence layer writes to `<disk_path>/sketch_index/`, a
subdir distinct from the legacy `SketchStore` layout — keeps the
two coexisting until the legacy can be deleted in subsequent sub-PRs.

The flusher loop is unchanged — it's generic over `EpochSource`
(PR #162's `SketchIndex` impl drives the new path; the legacy
`SketchStorePerKey` impl drives the deprecated one which now sees
no writes after M2.3.6a / PR #160).

Read-back from disk on query is NOT in scope here — the in-memory
`query_range` / `query_precomputes_by_agg` paths don't yet consult
`PartCache`. That's a follow-up: subsequent M2.3.6 sub-PRs add the
disk-read glue (the legacy `SketchStorePerKey` similarly stubbed
this; see `source.rs:35`'s "Ok(None) until then" comment).

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zzylol
zzylol deleted the feat/index-epoch-source branch July 17, 2026 20:05
zzylol added a commit that referenced this pull request Jul 27, 2026
64df20d is ASAPController main's actual tip now that #162 merged --
replaces the temporary pre-merge pin at e4cea66.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
zzylol added a commit that referenced this pull request Jul 27, 2026
64df20d is ASAPController main's actual tip now that #162 merged --
replaces the temporary pre-merge pin at e4cea66, matching control_plane's
own pin from #413.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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