本文整理汇总了Golang中github.com/youtube/vitess/go/vt/key.KeyRange.IsPartial方法的典型用法代码示例。如果您正苦于以下问题:Golang KeyRange.IsPartial方法的具体用法?Golang KeyRange.IsPartial怎么用?Golang KeyRange.IsPartial使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/youtube/vitess/go/vt/key.KeyRange
的用法示例。
在下文中一共展示了KeyRange.IsPartial方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: resolveKeyRangeToShards
// This maps a list of keyranges to shard names.
func resolveKeyRangeToShards(topoServer SrvTopoServer, cell, keyspace string, tabletType topo.TabletType, kr key.KeyRange) ([]string, error) {
srvKeyspace, err := topoServer.GetSrvKeyspace(cell, keyspace)
if err != nil {
return nil, fmt.Errorf("Error in reading the keyspace %v", err)
}
tabletTypePartition, ok := srvKeyspace.Partitions[tabletType]
if !ok {
return nil, fmt.Errorf("No shards available for tablet type '%v' in keyspace '%v'", tabletType, keyspace)
}
topo.SrvShardArray(tabletTypePartition.Shards).Sort()
shards := make([]string, 0, 1)
if !kr.IsPartial() {
for j := 0; j < len(tabletTypePartition.Shards); j++ {
shards = append(shards, tabletTypePartition.Shards[j].ShardName())
}
return shards, nil
}
for j := 0; j < len(tabletTypePartition.Shards); j++ {
shard := tabletTypePartition.Shards[j]
if key.KeyRangesIntersect(kr, shard.KeyRange) {
shards = append(shards, shard.ShardName())
}
if kr.End != key.MaxKey && kr.End < shard.KeyRange.Start {
break
}
}
return shards, nil
}
示例2: resolveKeyRangeToShards
// This maps a list of keyranges to shard names.
func resolveKeyRangeToShards(allShards []topo.ShardReference, 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].Name)
}
return shards, nil
}
for j := 0; j < len(allShards); j++ {
shard := allShards[j]
if key.KeyRangesIntersect(kr, shard.KeyRange) {
shards = append(shards, shard.Name)
}
}
return shards, nil
}
示例3: resolveKeyRangeToShards
// This maps a list of keyranges to shard names.
func resolveKeyRangeToShards(allShards []topo.SrvShard, kr key.KeyRange) ([]string, error) {
shards := make([]string, 0, 1)
topo.SrvShardArray(allShards).Sort()
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())
}
if kr.End != key.MaxKey && kr.End < shard.KeyRange.Start {
break
}
}
return shards, nil
}