MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / vshard_for_op

Method vshard_for_op

nodedb/src/control/array_sync/inbound_propose.rs:182–210  ·  view source on GitHub ↗

Compute the vShard that owns this op's tile. Extracts tile extents from the schema registry and casts the op's coord to `u64` for tile routing. Falls back to collection-level routing with a warning when the schema is unavailable or coord cannot be cast.

(&self, op: &ArrayOp)

Source from the content-addressed store, hash-verified

180 /// to `u64` for tile routing. Falls back to collection-level routing with
181 /// a warning when the schema is unavailable or coord cannot be cast.
182 pub(super) fn vshard_for_op(&self, op: &ArrayOp) -> VShardId {
183 use nodedb_array::types::coord::value::CoordValue;
184
185 let tile_extents = self.schemas().tile_extents(&op.header.array);
186
187 let Some(tile_extents) = tile_extents else {
188 warn!(
189 array = %op.header.array,
190 "array_inbound: schema unavailable; routing by name only"
191 );
192 return VShardId::new(array_vshard_for_name(&op.header.array));
193 };
194
195 let coord_u64: Vec<u64> = op
196 .coord
197 .iter()
198 .map(|c| match c {
199 CoordValue::Int64(v) | CoordValue::TimestampMs(v) => *v as u64,
200 CoordValue::Float64(v) => v.to_bits(),
201 CoordValue::String(_) => 0,
202 })
203 .collect();
204
205 VShardId::new(vshard_for_array_coord(
206 &op.header.array,
207 &coord_u64,
208 &tile_extents,
209 ))
210 }
211
212 /// Convert a decoded `ArrayOp` (from sync) into a `PhysicalPlan::Array` variant.
213 pub(super) fn op_to_data_plane_plan(

Callers 2

apply_op_directMethod · 0.80
apply_opMethod · 0.80

Calls 6

array_vshard_for_nameFunction · 0.85
vshard_for_array_coordFunction · 0.85
schemasMethod · 0.80
collectMethod · 0.80
tile_extentsMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected