本文整理匯總了Golang中github.com/henryanand/vitess/go/vt/vtgate/planbuilder.VCursor類的典型用法代碼示例。如果您正苦於以下問題:Golang VCursor類的具體用法?Golang VCursor怎麽用?Golang VCursor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了VCursor類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Map
func (vind *LookupHashUnique) Map(vcursor planbuilder.VCursor, ids []interface{}) ([]key.KeyspaceId, error) {
out := make([]key.KeyspaceId, 0, len(ids))
bq := &tproto.BoundQuery{
Sql: vind.sel,
}
for _, id := range ids {
bq.BindVariables = map[string]interface{}{
vind.From: id,
}
result, err := vcursor.Execute(bq)
if err != nil {
return nil, err
}
if len(result.Rows) == 0 {
out = append(out, "")
continue
}
if len(result.Rows) != 1 {
return nil, fmt.Errorf("unexpected multiple results from vindex %s: %v", vind.Table, id)
}
inum, err := mproto.Convert(result.Fields[0].Type, result.Rows[0][0])
if err != nil {
return nil, err
}
num, err := getNumber(inum)
if err != nil {
return nil, err
}
out = append(out, vhash(num))
}
return out, nil
}
示例2: Delete
func (vind *HashVindex) Delete(vcursor planbuilder.VCursor, id interface{}, _ key.KeyspaceId) error {
bq := &tproto.BoundQuery{
Sql: vind.del,
BindVariables: map[string]interface{}{
vind.Column: id,
},
}
if _, err := vcursor.Execute(bq); err != nil {
return err
}
return nil
}
示例3: Generate
func (vind *HashVindex) Generate(vcursor planbuilder.VCursor) (id interface{}, err error) {
bq := &tproto.BoundQuery{
Sql: vind.ins,
BindVariables: map[string]interface{}{
vind.Column: nil,
},
}
result, err := vcursor.Execute(bq)
if err != nil {
return nil, err
}
return result.InsertId, err
}
示例4: Create
func (vind *LookupHashUnique) Create(vcursor planbuilder.VCursor, id interface{}, ksid key.KeyspaceId) error {
bq := &tproto.BoundQuery{
Sql: vind.ins,
BindVariables: map[string]interface{}{
vind.From: id,
vind.To: vunhash(ksid),
},
}
if _, err := vcursor.Execute(bq); err != nil {
return err
}
return nil
}
示例5: Generate
func (vind *LookupHashUnique) Generate(vcursor planbuilder.VCursor, ksid key.KeyspaceId) (id interface{}, err error) {
bq := &tproto.BoundQuery{
Sql: vind.ins,
BindVariables: map[string]interface{}{
vind.From: nil,
vind.To: vunhash(ksid),
},
}
result, err := vcursor.Execute(bq)
if err != nil {
return nil, err
}
return result.InsertId, err
}
示例6: Verify
func (vind *LookupHashUnique) Verify(vcursor planbuilder.VCursor, id interface{}, ksid key.KeyspaceId) (bool, error) {
bq := &tproto.BoundQuery{
Sql: vind.verify,
BindVariables: map[string]interface{}{
vind.From: id,
vind.To: vunhash(ksid),
},
}
result, err := vcursor.Execute(bq)
if err != nil {
return false, err
}
if len(result.Rows) == 0 {
return false, nil
}
return true, nil
}