Fan out an aggregate request and reduce partial aggregates from all shards. Each shard receives its own `shard_hilbert_range` so it can apply a Hilbert-prefix pre-filter and only count cells in its partition. This prevents double-counting in configurations where multiple vShards share a single Data Plane executor (e.g. single-node harnesses).
(&self, req: ArrayShardAggReq)
| 195 | /// prevents double-counting in configurations where multiple vShards share |
| 196 | /// a single Data Plane executor (e.g. single-node harnesses). |
| 197 | pub async fn coord_agg(&self, req: ArrayShardAggReq) -> Result<Vec<ArrayAggPartial>> { |
| 198 | let prefix_bits = self.params.prefix_bits; |
| 199 | let per_shard: Vec<(u32, Vec<u8>)> = self |
| 200 | .params |
| 201 | .shard_ids |
| 202 | .iter() |
| 203 | .map(|&shard_id| { |
| 204 | let hilbert_range = if prefix_bits > 0 { |
| 205 | Some(shard_hilbert_range_for_vshard(shard_id, prefix_bits)) |
| 206 | } else { |
| 207 | None |
| 208 | }; |
| 209 | let per_shard_req = ArrayShardAggReq { |
| 210 | shard_hilbert_range: hilbert_range, |
| 211 | ..req.clone() |
| 212 | }; |
| 213 | let bytes = |
| 214 | zerompk::to_msgpack_vec(&per_shard_req).map_err(|e| ClusterError::Codec { |
| 215 | detail: format!("ArrayShardAggReq serialise: {e}"), |
| 216 | })?; |
| 217 | Ok((shard_id, bytes)) |
| 218 | }) |
| 219 | .collect::<Result<Vec<_>>>()?; |
| 220 | |
| 221 | let fo_params = FanOutPartitionedParams { |
| 222 | source_node: self.params.source_node, |
| 223 | timeout_ms: self.params.timeout_ms, |
| 224 | }; |
| 225 | let raw = fan_out_partitioned( |
| 226 | &fo_params, |
| 227 | super::super::opcodes::ARRAY_SHARD_AGG_REQ, |
| 228 | &per_shard, |
| 229 | &self.dispatch, |
| 230 | &self.circuit_breaker, |
| 231 | ) |
| 232 | .await?; |
| 233 | let resps = decode_resps::<ArrayShardAggResp>(&raw)?; |
| 234 | Ok(reduce_agg_partials(&resps)) |
| 235 | } |
| 236 | |
| 237 | /// Forward a coord-based delete to the shard(s) that own the cells. |
| 238 | pub async fn coord_delete( |
no test coverage detected