本文整理匯總了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
}