// 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 }
// 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 }
// 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 }
// 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 }