本文整理汇总了Golang中github.com/cockroachdb/cockroach/sql/sqlbase.Descriptor类的典型用法代码示例。如果您正苦于以下问题:Golang Descriptor类的具体用法?Golang Descriptor怎么用?Golang Descriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Descriptor类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: GetZoneConfig
// GetZoneConfig returns the zone config for the object with 'id'.
func GetZoneConfig(cfg config.SystemConfig, id uint32) (config.ZoneConfig, bool, error) {
// Look in the zones table.
if zoneVal := cfg.GetValue(sqlbase.MakeZoneKey(sqlbase.ID(id))); zoneVal != nil {
var zone config.ZoneConfig
// We're done.
return zone, true, zoneVal.GetProto(&zone)
}
// No zone config for this ID. We need to figure out if it's a database
// or table. Lookup its descriptor.
if descVal := cfg.GetValue(sqlbase.MakeDescMetadataKey(sqlbase.ID(id))); descVal != nil {
// Determine whether this is a database or table.
var desc sqlbase.Descriptor
if err := descVal.GetProto(&desc); err != nil {
return config.ZoneConfig{}, false, err
}
if tableDesc := desc.GetTable(); tableDesc != nil {
// This is a table descriptor. Lookup its parent database zone config.
return GetZoneConfig(cfg, uint32(tableDesc.ParentID))
}
}
// Retrieve the default zone config, but only as long as that wasn't the ID
// we were trying to retrieve (avoid infinite recursion).
if id != keys.RootNamespaceID {
return GetZoneConfig(cfg, keys.RootNamespaceID)
}
// No descriptor or not a table.
return config.ZoneConfig{}, false, nil
}
开发者ID:yangxuanjia,项目名称:cockroach,代码行数:32,代码来源:config.go
示例2: isDeleted
func isDeleted(tableID sqlbase.ID, cfg config.SystemConfig) bool {
descKey := sqlbase.MakeDescMetadataKey(tableID)
val := cfg.GetValue(descKey)
if val == nil {
return false
}
var descriptor sqlbase.Descriptor
if err := val.GetProto(&descriptor); err != nil {
panic("unable to unmarshal table descriptor")
}
table := descriptor.GetTable()
return table.Deleted()
}
开发者ID:JKhawaja,项目名称:cockroach,代码行数:13,代码来源:lease_test.go
示例3: isRenamed
// isRenamed tests if a descriptor is updated by gossip to the specified name
// and version.
func isRenamed(
tableID sqlbase.ID,
expectedName string,
expectedVersion sqlbase.DescriptorVersion,
cfg config.SystemConfig,
) bool {
descKey := sqlbase.MakeDescMetadataKey(tableID)
val := cfg.GetValue(descKey)
if val == nil {
return false
}
var descriptor sqlbase.Descriptor
if err := val.GetProto(&descriptor); err != nil {
panic("unable to unmarshal table descriptor")
}
table := descriptor.GetTable()
return table.Name == expectedName && table.Version == expectedVersion
}
开发者ID:CubeLite,项目名称:cockroach,代码行数:20,代码来源:rename_test.go
示例4: waitForConfigChange
func waitForConfigChange(t *testing.T, s *testServer) config.SystemConfig {
var foundDesc sqlbase.Descriptor
var cfg config.SystemConfig
util.SucceedsSoon(t, func() error {
var ok bool
if cfg, ok = s.Gossip().GetSystemConfig(); ok {
if val := cfg.GetValue(configDescKey); val != nil {
if err := val.GetProto(&foundDesc); err != nil {
t.Fatal(err)
}
if id := foundDesc.GetDatabase().GetID(); id != configID {
return util.Errorf("expected database id %d; got %d", configID, id)
}
return nil
}
}
return util.Errorf("got nil system config")
})
return cfg
}
开发者ID:GitGoldie,项目名称:cockroach,代码行数:20,代码来源:config_test.go
注:本文中的github.com/cockroachdb/cockroach/sql/sqlbase.Descriptor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论