本文整理汇总了Golang中github.com/youtube/vitess/go/vt/tabletserver/proto.BoundQueryToProto3函数的典型用法代码示例。如果您正苦于以下问题:Golang BoundQueryToProto3函数的具体用法?Golang BoundQueryToProto3怎么用?Golang BoundQueryToProto3使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BoundQueryToProto3函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: SplitQueryPartsToProto
// SplitQueryPartsToproto transforms a SplitQueryResponse into proto
func SplitQueryPartsToProto(sqp []SplitQueryPart) *pb.SplitQueryResponse {
result := &pb.SplitQueryResponse{}
if len(sqp) == 0 {
return result
}
result.Splits = make([]*pb.SplitQueryResponse_Part, len(sqp))
for i, split := range sqp {
result.Splits[i] = &pb.SplitQueryResponse_Part{
Size: split.Size,
}
if split.Query != nil {
result.Splits[i].Query = tproto.BoundQueryToProto3(split.Query.Sql, split.Query.BindVariables)
result.Splits[i].KeyRangePart = &pb.SplitQueryResponse_KeyRangePart{
Keyspace: split.Query.Keyspace,
KeyRanges: key.KeyRangesToProto(split.Query.KeyRanges),
}
}
if split.QueryShard != nil {
result.Splits[i].Query = tproto.BoundQueryToProto3(split.QueryShard.Sql, split.QueryShard.BindVariables)
result.Splits[i].ShardPart = &pb.SplitQueryResponse_ShardPart{
Keyspace: split.QueryShard.Keyspace,
Shards: split.QueryShard.Shards,
}
}
}
return result
}
开发者ID:ruiaylin,项目名称:vitess,代码行数:28,代码来源:proto3.go
示例2: ExecuteShards
func (conn *vtgateConn) ExecuteShards(ctx context.Context, query string, keyspace string, shards []string, bindVars map[string]interface{}, tabletType pbt.TabletType, notInTransaction bool, session interface{}) (*mproto.QueryResult, interface{}, error) {
var s *pb.Session
if session != nil {
s = session.(*pb.Session)
}
q, err := tproto.BoundQueryToProto3(query, bindVars)
if err != nil {
return nil, session, err
}
request := &pb.ExecuteShardsRequest{
CallerId: callerid.EffectiveCallerIDFromContext(ctx),
Session: s,
Query: q,
Keyspace: keyspace,
Shards: shards,
TabletType: tabletType,
NotInTransaction: notInTransaction,
}
response, err := conn.c.ExecuteShards(ctx, request)
if err != nil {
return nil, session, vterrors.FromGRPCError(err)
}
if response.Error != nil {
return nil, response.Session, vterrors.FromVtRPCError(response.Error)
}
return mproto.Proto3ToQueryResult(response.Result), response.Session, nil
}
开发者ID:hadmagic,项目名称:vitess,代码行数:27,代码来源:conn.go
示例3: StreamExecute
func (conn *vtgateConn) StreamExecute(ctx context.Context, query string, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (<-chan *sqltypes.Result, vtgateconn.ErrFunc, error) {
q, err := tproto.BoundQueryToProto3(query, bindVars)
if err != nil {
return nil, nil, err
}
req := &pb.StreamExecuteRequest{
CallerId: callerid.EffectiveCallerIDFromContext(ctx),
Query: q,
TabletType: tabletType,
}
stream, err := conn.c.StreamExecute(ctx, req)
if err != nil {
return nil, nil, vterrors.FromGRPCError(err)
}
sr := make(chan *sqltypes.Result, 10)
var finalError error
go func() {
for {
ser, err := stream.Recv()
if err != nil {
if err != io.EOF {
finalError = vterrors.FromGRPCError(err)
}
close(sr)
return
}
sr <- sqltypes.Proto3ToResult(ser.Result)
}
}()
return sr, func() error {
return finalError
}, nil
}
开发者ID:tjyang,项目名称:vitess,代码行数:33,代码来源:conn.go
示例4: ExecuteBatch
// ExecuteBatch sends a batch query to VTTablet.
func (conn *gRPCQueryClient) ExecuteBatch(ctx context.Context, queries []tproto.BoundQuery, asTransaction bool, transactionID int64) (*tproto.QueryResultList, error) {
conn.mu.RLock()
defer conn.mu.RUnlock()
if conn.cc == nil {
return nil, tabletconn.ConnClosed
}
req := &pb.ExecuteBatchRequest{
Queries: make([]*pb.BoundQuery, len(queries)),
AsTransaction: asTransaction,
TransactionId: transactionID,
SessionId: conn.sessionID,
}
for i, q := range queries {
req.Queries[i] = tproto.BoundQueryToProto3(q.Sql, q.BindVariables)
}
ebr, err := conn.c.ExecuteBatch(ctx, req)
if err != nil {
return nil, tabletErrorFromGRPC(err)
}
if ebr.Error != nil {
return nil, tabletErrorFromRPCError(ebr.Error)
}
return tproto.Proto3ToQueryResultList(ebr.Results), nil
}
开发者ID:afrolovskiy,项目名称:vitess,代码行数:26,代码来源:conn.go
示例5: StreamExecuteKeyspaceIds
func (conn *vtgateConn) StreamExecuteKeyspaceIds(ctx context.Context, query string, keyspace string, keyspaceIds [][]byte, bindVars map[string]interface{}, tabletType pbt.TabletType) (<-chan *mproto.QueryResult, vtgateconn.ErrFunc, error) {
req := &pb.StreamExecuteKeyspaceIdsRequest{
CallerId: callerid.EffectiveCallerIDFromContext(ctx),
Query: tproto.BoundQueryToProto3(query, bindVars),
Keyspace: keyspace,
KeyspaceIds: keyspaceIds,
TabletType: tabletType,
}
stream, err := conn.c.StreamExecuteKeyspaceIds(ctx, req)
if err != nil {
return nil, nil, vterrors.FromGRPCError(err)
}
sr := make(chan *mproto.QueryResult, 10)
var finalError error
go func() {
for {
ser, err := stream.Recv()
if err != nil {
if err != io.EOF {
finalError = vterrors.FromGRPCError(err)
}
close(sr)
return
}
sr <- mproto.Proto3ToQueryResult(ser.Result)
}
}()
return sr, func() error {
return finalError
}, nil
}
开发者ID:xgwubin,项目名称:vitess,代码行数:31,代码来源:conn.go
示例6: ExecuteEntityIds
func (conn *vtgateConn) ExecuteEntityIds(ctx context.Context, query string, keyspace string, entityColumnName string, entityKeyspaceIDs []*pb.ExecuteEntityIdsRequest_EntityId, bindVars map[string]interface{}, tabletType topodatapb.TabletType, notInTransaction bool, session interface{}) (*sqltypes.Result, interface{}, error) {
var s *pb.Session
if session != nil {
s = session.(*pb.Session)
}
q, err := tproto.BoundQueryToProto3(query, bindVars)
if err != nil {
return nil, session, err
}
request := &pb.ExecuteEntityIdsRequest{
CallerId: callerid.EffectiveCallerIDFromContext(ctx),
Session: s,
Query: q,
Keyspace: keyspace,
EntityColumnName: entityColumnName,
EntityKeyspaceIds: entityKeyspaceIDs,
TabletType: tabletType,
NotInTransaction: notInTransaction,
}
response, err := conn.c.ExecuteEntityIds(ctx, request)
if err != nil {
return nil, session, vterrors.FromGRPCError(err)
}
if response.Error != nil {
return nil, response.Session, vterrors.FromVtRPCError(response.Error)
}
return sqltypes.Proto3ToResult(response.Result), response.Session, nil
}
开发者ID:tjyang,项目名称:vitess,代码行数:28,代码来源:conn.go
示例7: StreamExecuteKeyspaceIds
func (conn *vtgateConn) StreamExecuteKeyspaceIds(ctx context.Context, query string, keyspace string, keyspaceIds []key.KeyspaceId, bindVars map[string]interface{}, tabletType topo.TabletType) (<-chan *mproto.QueryResult, vtgateconn.ErrFunc, error) {
req := &pb.StreamExecuteKeyspaceIdsRequest{
Query: tproto.BoundQueryToProto3(query, bindVars),
Keyspace: keyspace,
KeyspaceIds: key.KeyspaceIdsToProto(keyspaceIds),
TabletType: topo.TabletTypeToProto(tabletType),
}
stream, err := conn.c.StreamExecuteKeyspaceIds(ctx, req)
if err != nil {
return nil, nil, err
}
sr := make(chan *mproto.QueryResult, 10)
var finalError error
go func() {
for {
ser, err := stream.Recv()
if err != nil {
if err != io.EOF {
finalError = err
}
close(sr)
return
}
if ser.Error != nil {
finalError = vterrors.FromVtRPCError(ser.Error)
close(sr)
return
}
sr <- mproto.Proto3ToQueryResult(ser.Result)
}
}()
return sr, func() error {
return finalError
}, nil
}
开发者ID:afrolovskiy,项目名称:vitess,代码行数:35,代码来源:conn.go
示例8: Execute
// Execute sends the query to VTTablet.
func (conn *gRPCQueryClient) Execute(ctx context.Context, query string, bindVars map[string]interface{}, transactionID int64) (*sqltypes.Result, error) {
conn.mu.RLock()
defer conn.mu.RUnlock()
if conn.cc == nil {
return nil, tabletconn.ConnClosed
}
q, err := tproto.BoundQueryToProto3(query, bindVars)
if err != nil {
return nil, err
}
req := &pb.ExecuteRequest{
Target: conn.target,
EffectiveCallerId: callerid.EffectiveCallerIDFromContext(ctx),
ImmediateCallerId: callerid.ImmediateCallerIDFromContext(ctx),
Query: q,
TransactionId: transactionID,
SessionId: conn.sessionID,
}
er, err := conn.c.Execute(ctx, req)
if err != nil {
return nil, tabletconn.TabletErrorFromGRPC(err)
}
return sqltypes.Proto3ToResult(er.Result), nil
}
开发者ID:c3p0hz,项目名称:vitess,代码行数:27,代码来源:conn.go
示例9: SplitQuery
// SplitQuery is the stub for TabletServer.SplitQuery RPC
func (conn *gRPCQueryClient) SplitQuery(ctx context.Context, query tproto.BoundQuery, splitColumn string, splitCount int) (queries []tproto.QuerySplit, err error) {
conn.mu.RLock()
defer conn.mu.RUnlock()
if conn.cc == nil {
err = tabletconn.ConnClosed
return
}
q, err := tproto.BoundQueryToProto3(query.Sql, query.BindVariables)
if err != nil {
return nil, tabletconn.TabletErrorFromGRPC(err)
}
req := &pb.SplitQueryRequest{
Target: conn.target,
EffectiveCallerId: callerid.EffectiveCallerIDFromContext(ctx),
ImmediateCallerId: callerid.ImmediateCallerIDFromContext(ctx),
Query: q,
SplitColumn: splitColumn,
SplitCount: int64(splitCount),
SessionId: conn.sessionID,
}
sqr, err := conn.c.SplitQuery(ctx, req)
if err != nil {
return nil, tabletconn.TabletErrorFromGRPC(err)
}
split, err := tproto.Proto3ToQuerySplits(sqr.Queries)
if err != nil {
return nil, tabletconn.TabletErrorFromGRPC(err)
}
return split, nil
}
开发者ID:c3p0hz,项目名称:vitess,代码行数:32,代码来源:conn.go
示例10: ExecuteBatch
// ExecuteBatch sends a batch query to VTTablet.
func (conn *gRPCQueryClient) ExecuteBatch(ctx context.Context, queries []tproto.BoundQuery, asTransaction bool, transactionID int64) (*tproto.QueryResultList, error) {
conn.mu.RLock()
defer conn.mu.RUnlock()
if conn.cc == nil {
return nil, tabletconn.ConnClosed
}
req := &pb.ExecuteBatchRequest{
Target: conn.target,
EffectiveCallerId: callerid.EffectiveCallerIDFromContext(ctx),
ImmediateCallerId: callerid.ImmediateCallerIDFromContext(ctx),
Queries: make([]*pb.BoundQuery, len(queries)),
AsTransaction: asTransaction,
TransactionId: transactionID,
SessionId: conn.sessionID,
}
for i, q := range queries {
qq, err := tproto.BoundQueryToProto3(q.Sql, q.BindVariables)
if err != nil {
return nil, err
}
req.Queries[i] = qq
}
ebr, err := conn.c.ExecuteBatch(ctx, req)
if err != nil {
return nil, tabletconn.TabletErrorFromGRPC(err)
}
return tproto.Proto3ToQueryResultList(ebr.Results), nil
}
开发者ID:c3p0hz,项目名称:vitess,代码行数:30,代码来源:conn.go
示例11: StreamExecute
func (conn *vtgateConn) StreamExecute(ctx context.Context, query string, bindVars map[string]interface{}, tabletType pbt.TabletType) (<-chan *mproto.QueryResult, vtgateconn.ErrFunc, error) {
req := &pb.StreamExecuteRequest{
CallerId: callerid.EffectiveCallerIDFromContext(ctx),
Query: tproto.BoundQueryToProto3(query, bindVars),
TabletType: tabletType,
}
stream, err := conn.c.StreamExecute(ctx, req)
if err != nil {
return nil, nil, vterrors.FromGRPCError(err)
}
sr := make(chan *mproto.QueryResult, 10)
// TODO(aaijazi): I'm pretty sure ther error handling going on down here is overkill now...
var finalError error
go func() {
for {
ser, err := stream.Recv()
if err != nil {
if err != io.EOF {
finalError = err
}
close(sr)
return
}
if ser.Error != nil {
finalError = vterrors.FromVtRPCError(ser.Error)
close(sr)
return
}
sr <- mproto.Proto3ToQueryResult(ser.Result)
}
}()
return sr, func() error {
return finalError
}, nil
}
开发者ID:ruiaylin,项目名称:vitess,代码行数:35,代码来源:conn.go
示例12: SplitQuery
func (conn *vtgateConn) SplitQuery(ctx context.Context, keyspace string, query tproto.BoundQuery, splitColumn string, splitCount int) ([]proto.SplitQueryPart, error) {
request := &pb.SplitQueryRequest{
Keyspace: keyspace,
Query: tproto.BoundQueryToProto3(query.Sql, query.BindVariables),
SplitColumn: splitColumn,
SplitCount: int64(splitCount),
}
response, err := conn.c.SplitQuery(ctx, request)
if err != nil {
return nil, err
}
return proto.ProtoToSplitQueryParts(response), nil
}
开发者ID:afrolovskiy,项目名称:vitess,代码行数:13,代码来源:conn.go
示例13: SplitQuery
func (conn *vtgateConn) SplitQuery(ctx context.Context, keyspace string, query string, bindVars map[string]interface{}, splitColumn string, splitCount int) ([]*pb.SplitQueryResponse_Part, error) {
request := &pb.SplitQueryRequest{
CallerId: callerid.EffectiveCallerIDFromContext(ctx),
Keyspace: keyspace,
Query: tproto.BoundQueryToProto3(query, bindVars),
SplitColumn: splitColumn,
SplitCount: int64(splitCount),
}
response := &pb.SplitQueryResponse{}
if err := conn.rpcConn.Call(ctx, "VTGateP3.SplitQuery", request, response); err != nil {
return nil, vterrors.FromJSONError(err)
}
return response.Splits, nil
}
开发者ID:richarwu,项目名称:vitess,代码行数:14,代码来源:conn.go
示例14: SplitQuery
func (conn *vtgateConn) SplitQuery(ctx context.Context, keyspace string, query string, bindVars map[string]interface{}, splitColumn string, splitCount int) ([]proto.SplitQueryPart, error) {
request := &pb.SplitQueryRequest{
CallerId: callerid.EffectiveCallerIDFromContext(ctx),
Keyspace: keyspace,
Query: tproto.BoundQueryToProto3(query, bindVars),
SplitColumn: splitColumn,
SplitCount: int64(splitCount),
}
response, err := conn.c.SplitQuery(ctx, request)
if err != nil {
return nil, vterrors.FromGRPCError(err)
}
return proto.ProtoToSplitQueryParts(response), nil
}
开发者ID:xgwubin,项目名称:vitess,代码行数:14,代码来源:conn.go
示例15: BoundKeyspaceIdQueriesToProto
// BoundKeyspaceIdQueriesToProto transforms a list of BoundKeyspaceIdQuery to proto3
func BoundKeyspaceIdQueriesToProto(bsq []BoundKeyspaceIdQuery) []*pb.BoundKeyspaceIdQuery {
if len(bsq) == 0 {
return nil
}
result := make([]*pb.BoundKeyspaceIdQuery, len(bsq))
for i, q := range bsq {
result[i] = &pb.BoundKeyspaceIdQuery{
Query: tproto.BoundQueryToProto3(q.Sql, q.BindVariables),
Keyspace: q.Keyspace,
KeyspaceIds: key.KeyspaceIdsToProto(q.KeyspaceIds),
}
}
return result
}
开发者ID:ruiaylin,项目名称:vitess,代码行数:15,代码来源:proto3.go
示例16: testEchoSplitQuery
func testEchoSplitQuery(t *testing.T, conn *vtgateconn.VTGateConn) {
want := &pbg.SplitQueryResponse_Part{
Query: tproto.BoundQueryToProto3(echoPrefix+query+":split_column:123", bindVars),
KeyRangePart: &pbg.SplitQueryResponse_KeyRangePart{Keyspace: keyspace},
}
got, err := conn.SplitQuery(context.Background(), keyspace, echoPrefix+query, bindVars, "split_column", 123)
if err != nil {
t.Fatalf("SplitQuery error: %v", err)
}
// For some reason, proto.Equal() is calling them unequal even though no diffs
// are found.
gotstr, wantstr := got[0].String(), want.String()
if gotstr != wantstr {
t.Errorf("SplitQuery() = %v, want %v", gotstr, wantstr)
}
}
开发者ID:richarwu,项目名称:vitess,代码行数:16,代码来源:echo.go
示例17: StreamExecute2
func (conn *vtgateConn) StreamExecute2(ctx context.Context, query string, bindVars map[string]interface{}, tabletType topopb.TabletType) (<-chan *mproto.QueryResult, vtgateconn.ErrFunc, error) {
req := &pb.StreamExecuteRequest{
CallerId: callerid.EffectiveCallerIDFromContext(ctx),
Query: tproto.BoundQueryToProto3(query, bindVars),
TabletType: tabletType,
}
sr := make(chan *pb.StreamExecuteResponse, 10)
c := conn.rpcConn.StreamGo("VTGateP3.StreamExecute2", req, sr)
srr := make(chan streamResult)
go func() {
for v := range sr {
srr <- streamResult{qr: v.Result, err: v.Error}
}
close(srr)
}()
return sendStreamResults(c, srr)
}
开发者ID:payintel,项目名称:vitess,代码行数:17,代码来源:conn.go
示例18: StreamExecute
// StreamExecute starts a streaming query to VTTablet.
func (conn *gRPCQueryClient) StreamExecute(ctx context.Context, query string, bindVars map[string]interface{}, transactionID int64) (<-chan *sqltypes.Result, tabletconn.ErrFunc, error) {
conn.mu.RLock()
defer conn.mu.RUnlock()
if conn.cc == nil {
return nil, nil, tabletconn.ConnClosed
}
q, err := tproto.BoundQueryToProto3(query, bindVars)
if err != nil {
return nil, nil, err
}
req := &querypb.StreamExecuteRequest{
Target: conn.target,
EffectiveCallerId: callerid.EffectiveCallerIDFromContext(ctx),
ImmediateCallerId: callerid.ImmediateCallerIDFromContext(ctx),
Query: q,
SessionId: conn.sessionID,
}
stream, err := conn.c.StreamExecute(ctx, req)
if err != nil {
return nil, nil, tabletconn.TabletErrorFromGRPC(err)
}
sr := make(chan *sqltypes.Result, 10)
var finalError error
go func() {
var fields []*querypb.Field
for {
ser, err := stream.Recv()
if err != nil {
if err != io.EOF {
finalError = tabletconn.TabletErrorFromGRPC(err)
}
close(sr)
return
}
if fields == nil {
fields = ser.Result.Fields
}
sr <- sqltypes.CustomProto3ToResult(fields, ser.Result)
}
}()
return sr, func() error {
return finalError
}, nil
}
开发者ID:zhangzzl,项目名称:vitess,代码行数:46,代码来源:conn.go
示例19: BoundKeyspaceIdQueriesToProto
// BoundKeyspaceIdQueriesToProto transforms a list of BoundKeyspaceIdQuery to proto3
func BoundKeyspaceIdQueriesToProto(bsq []BoundKeyspaceIdQuery) ([]*vtgatepb.BoundKeyspaceIdQuery, error) {
if len(bsq) == 0 {
return nil, nil
}
result := make([]*vtgatepb.BoundKeyspaceIdQuery, len(bsq))
for i, q := range bsq {
qq, err := tproto.BoundQueryToProto3(q.Sql, q.BindVariables)
if err != nil {
return nil, err
}
result[i] = &vtgatepb.BoundKeyspaceIdQuery{
Query: qq,
Keyspace: q.Keyspace,
KeyspaceIds: q.KeyspaceIds,
}
}
return result, nil
}
开发者ID:BobbWu,项目名称:vitess,代码行数:19,代码来源:proto3.go
示例20: Execute
func (conn *vtgateConn) Execute(ctx context.Context, query string, bindVars map[string]interface{}, tabletType topo.TabletType, notInTransaction bool, session interface{}) (*mproto.QueryResult, interface{}, error) {
var s *pb.Session
if session != nil {
s = session.(*pb.Session)
}
request := &pb.ExecuteRequest{
Session: s,
Query: tproto.BoundQueryToProto3(query, bindVars),
TabletType: topo.TabletTypeToProto(tabletType),
NotInTransaction: notInTransaction,
}
response, err := conn.c.Execute(ctx, request)
if err != nil {
return nil, session, err
}
if response.Error != nil {
return nil, response.Session, vterrors.FromVtRPCError(response.Error)
}
return mproto.Proto3ToQueryResult(response.Result), response.Session, nil
}
开发者ID:afrolovskiy,项目名称:vitess,代码行数:20,代码来源:conn.go
注:本文中的github.com/youtube/vitess/go/vt/tabletserver/proto.BoundQueryToProto3函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论