本文整理汇总了Golang中github.com/cockroachdb/cockroach/client.Txn.GetProto方法的典型用法代码示例。如果您正苦于以下问题:Golang Txn.GetProto方法的具体用法?Golang Txn.GetProto怎么用?Golang Txn.GetProto使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cockroachdb/cockroach/client.Txn
的用法示例。
在下文中一共展示了Txn.GetProto方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: getRangeTree
// GetRangeTree fetches the RangeTree proto and sets up the range tree context.
func getRangeTree(txn *client.Txn) (*treeContext, *roachpb.Error) {
tree := new(RangeTree)
if pErr := txn.GetProto(keys.RangeTreeRoot, tree); pErr != nil {
return nil, pErr
}
return &treeContext{
txn: txn,
tree: tree,
dirty: false,
nodes: map[string]cachedNode{},
}, nil
}
示例2: getRangeTree
// GetRangeTree fetches the RangeTree proto and sets up the range tree context.
func getRangeTree(txn *client.Txn) (*treeContext, error) {
tree := &proto.RangeTree{}
if err := txn.GetProto(keys.RangeTreeRoot, tree); err != nil {
return nil, err
}
return &treeContext{
txn: txn,
tree: tree,
dirty: false,
nodes: map[string]cachedNode{},
}, nil
}
示例3: getTableDescFromID
// get the table descriptor for the ID passed in using the planner's txn.
func getTableDescFromID(txn *client.Txn, id ID) (*TableDescriptor, *roachpb.Error) {
desc := &Descriptor{}
descKey := MakeDescMetadataKey(id)
if pErr := txn.GetProto(descKey, desc); pErr != nil {
return nil, pErr
}
tableDesc := desc.GetTable()
if tableDesc == nil {
return nil, roachpb.NewErrorf("ID %d is not a table", id)
}
return tableDesc, nil
}
示例4: getTableDescFromID
// getTableDescFromID retrieves the table descriptor for the table
// ID passed in using an existing txn. Teturns an error if the
// descriptor doesn't exist or if it exists and is not a table.
func getTableDescFromID(txn *client.Txn, id sqlbase.ID) (*sqlbase.TableDescriptor, error) {
desc := &sqlbase.Descriptor{}
descKey := sqlbase.MakeDescMetadataKey(id)
if err := txn.GetProto(descKey, desc); err != nil {
return nil, err
}
table := desc.GetTable()
if table == nil {
return nil, errDescriptorNotFound
}
return table, nil
}