Skip to main content

Module array_routing

Module array_routing 

Source
Expand description

Tile-aware array routing — maps (array_name, coord) → vShard id.

A distributed Origin shards each array’s op-log by tile: ops for tile T of array A land on the vShard computed from the bytes array_name || tile_id. This spreads a large array across 1 024 vShards without any coordination beyond the deterministic hash already used for all other shard routing.

§Key invariant

Ops for the same (array, tile) always route to the same vShard. Ops for different tiles of the same array typically route to different vShards (with high probability for arrays whose tile grid is large enough to avoid hash collisions on a 10-bit output).

§Returned type

Functions here return a raw u16 vShard ID (0..1023). Callers in the nodedb crate wrap this in VShardId::new(…). VShardId lives in nodedb::types which nodedb-cluster cannot depend on without creating a circular dependency.

§Fallbacks

  • Empty coord or tile_extents: fall back to array_vshard_for_name.
  • Zero tile extent in any dimension: same fallback (no division by zero).
  • coord.len() != tile_extents.len(): fallback.

Constants§

VSHARD_COUNT
Number of virtual shards — must match VShardId::COUNT in nodedb::types.

Functions§

array_vshard_for_name
Compute a vShard ID from an array name alone.
tile_id_of_coord
Compute the tile identifier for a coordinate given tile extents.
vshard_for_array_coord
Compute the vShard ID for an array op at the given coordinate.
vshard_for_array_tile
Compute the vShard ID for an array tile by tile identifier.