Expand description
Joint count-and-sum no-prove executor surface — backs the AVG no-prove path’s unified single-walk dispatch. See its module docstring for the perf / atomicity contract. Server-only because the surface only fires on the no-prove (server-materialized) path. Joint count-and-sum executor surface for the AVG no-prove path.
Drive::execute_document_count_and_sum_request consumes the same
DocumentAverageRequest / DocumentAverageResponse pair used
by the prove path and dispatches to one of three per-mode executors
depending on the resolved [DocumentSumMode].
§Per-shape execution
Total/PerInValue(empty-where, or Equal/Inon asummable + countableindex): point-lookup walk against the index, decoding(count, sum)from each visitedCountSumTree/ProvableCountSumTreeterminator in one call viaElement::count_sum_value_or_default. One grovedb read per In branch yields both metrics together.RangeNoProofdistinct shapes (GroupByRange/GroupByCompound+ range on arangeAverageableindex): one grovedb walk againstcrate::query::drive_document_sum_query::DriveDocumentSumQuery::distinct_sum_path_query’sProvableCountProvableSumTreeterminators, emitting one(count, sum)per visited distinct in-range key. Bounded by the request’slimit(default falls back todrive_config.default_query_limit, explicit limits are clamped todrive_config.max_query_limit).RangeNoProofaggregate shapes (Aggregate/GroupByIn+ range): grovedb’s combined merk-internal accumulator —query_aggregate_count_and_sumagainst the PCPS path query — yielding(u64, i64)from a single O(log n) traversal. CompoundIn + rangeper-In fans out (≤100 branches per theIn::in_values()validator cap) and issues one combined accumulator call per branch under a shared read transaction.
§Routing
Mode resolution reuses sum’s versioned routing table
(crate::query::drive_document_sum_query::mode_detection::detect_sum_mode_from_inputs)
— the routing decision is consensus-relevant and identical for
count, sum, and joint count+sum on the no-prove path, so forking
the table here would invite the drift bug PR #3661 caught (count’s
GroupByCompound row had diverged from sum’s). A trivial
AverageMode → SumMode adapter feeds sum’s mode detector;
prove = false is passed unconditionally because the prove path
never enters this module.
§Engine-side primitive note
grovedb exposes query_aggregate_count_and_sum as the combined
no-prove accumulator (proof-side analog
AggregateCountAndSumOnRange is what the prove path uses for the
same shape). The aggregate RangeNoProof branch routes through it
directly — one merk-internal (u128, i128) walk per request,
narrowed to (u64, i64) at the grovedb entry. Same cost class
and the same shape the prove path uses, just without the proof
envelope.
Modules§
- drive_
dispatcher - Joint count-and-sum dispatcher entry point for the AVG no-prove path.
- executors
- Per-
DocumentSumModejoint count-and-sum no-prove executors.