Example #1
0
// This maps a list of keyranges to shard names.
func resolveKeyRangeToShards(allShards []topo.SrvShard, kr key.KeyRange) ([]string, error) {
	shards := make([]string, 0, 1)

	if !kr.IsPartial() {
		for j := 0; j < len(allShards); j++ {
			shards = append(shards, allShards[j].ShardName())
		}
		return shards, nil
	}
	for j := 0; j < len(allShards); j++ {
		shard := allShards[j]
		if key.KeyRangesIntersect(kr, shard.KeyRange) {
			shards = append(shards, shard.ShardName())
		}
	}
	return shards, nil
}