(&self, args: AggArgs<'_>)
| 386 | } |
| 387 | |
| 388 | async fn execute_agg(&self, args: AggArgs<'_>) -> crate::Result<Vec<u8>> { |
| 389 | let AggArgs { |
| 390 | array_id, |
| 391 | attr_idx, |
| 392 | reducer_msgpack, |
| 393 | group_by_dim, |
| 394 | slice_hilbert_ranges, |
| 395 | prefix_bits, |
| 396 | system_as_of, |
| 397 | valid_at_ms, |
| 398 | } = args; |
| 399 | let coordinator = ArrayCoordinator::for_slice( |
| 400 | self.source_node, |
| 401 | ARRAY_RPC_TIMEOUT_MS, |
| 402 | slice_hilbert_ranges, |
| 403 | prefix_bits, |
| 404 | self.total_shards, |
| 405 | Arc::clone(&self.dispatch), |
| 406 | Arc::clone(&self.circuit_breaker), |
| 407 | ) |
| 408 | .map_err(cluster_err)?; |
| 409 | |
| 410 | let array_id_msgpack = zerompk::to_msgpack_vec(array_id).map_err(encode_err)?; |
| 411 | let req = ArrayShardAggReq { |
| 412 | array_id_msgpack, |
| 413 | attr_idx, |
| 414 | reducer_msgpack: reducer_msgpack.to_vec(), |
| 415 | group_by_dim, |
| 416 | cell_filter_msgpack: vec![], |
| 417 | shard_hilbert_range: None, |
| 418 | system_as_of, |
| 419 | valid_at_ms, |
| 420 | }; |
| 421 | let partials: Vec<ArrayAggPartial> = |
| 422 | coordinator.coord_agg(req).await.map_err(cluster_err)?; |
| 423 | |
| 424 | // Decode the reducer so we know which field to finalize. |
| 425 | let reducer: nodedb_physical::physical_plan::ArrayReducer = |
| 426 | zerompk::from_msgpack(reducer_msgpack).map_err(|e| crate::Error::Serialization { |
| 427 | format: "msgpack".into(), |
| 428 | detail: format!("agg reducer decode: {e}"), |
| 429 | })?; |
| 430 | |
| 431 | // Finalize each partial into the same {"group", "result"} / {"result"} |
| 432 | // shape the local ArrayOp::Aggregate path produces. This ensures |
| 433 | // payload_to_response → decode_payload_to_json emits the same JSON |
| 434 | // structure for both single-node and cluster agg queries. |
| 435 | let rows = finalize_agg_partials(&partials, &reducer, group_by_dim); |
| 436 | zerompk::to_msgpack_vec(&rows).map_err(encode_err) |
| 437 | } |
| 438 | |
| 439 | async fn execute_put( |
| 440 | &self, |
no test coverage detected