Removing last use of key.KeyRange in vtgate gorpc code.

And then removing key.KeyRange.
This commit is contained in:
Alain Jobart 2015-11-06 09:45:04 -08:00
Родитель 948b2049d0
Коммит 9b59e8f782
15 изменённых файлов: 60 добавлений и 246 удалений

Просмотреть файл

@ -11,7 +11,6 @@ import (
"github.com/youtube/vitess/go/sqltypes"
"github.com/youtube/vitess/go/vt/callerid"
"github.com/youtube/vitess/go/vt/key"
"github.com/youtube/vitess/go/vt/vtgate/vtgateconn"
mproto "github.com/youtube/vitess/go/mysql/proto"
@ -35,8 +34,7 @@ var (
[]byte{1, 2, 3, 4},
[]byte{5, 6, 7, 8},
}
keyspaceIDsEcho = "[[1 2 3 4] [5 6 7 8]]"
keyspaceIDsEchoOld = "[01020304 05060708]"
keyspaceIDsEcho = "[[1 2 3 4] [5 6 7 8]]"
keyRanges = []*pbt.KeyRange{
&pbt.KeyRange{Start: []byte{1, 2, 3, 4}, End: []byte{5, 6, 7, 8}},
@ -165,7 +163,7 @@ func testEchoExecute(t *testing.T, conn *vtgateconn.VTGateConn) {
gproto.BoundKeyspaceIdQuery{
Sql: echoPrefix + query,
Keyspace: keyspace,
KeyspaceIds: key.ProtoToKeyspaceIds(keyspaceIDs),
KeyspaceIds: keyspaceIDs,
BindVariables: bindVars,
},
}, tabletType, true)
@ -173,7 +171,7 @@ func testEchoExecute(t *testing.T, conn *vtgateconn.VTGateConn) {
"callerId": callerIDEcho,
"query": echoPrefix + query,
"keyspace": keyspace,
"keyspaceIds": keyspaceIDsEchoOld,
"keyspaceIds": keyspaceIDsEcho,
"bindVars": bindVarsEcho,
"tabletType": tabletTypeEcho,
"asTransaction": "true",
@ -328,7 +326,7 @@ func testEchoTransactionExecute(t *testing.T, conn *vtgateconn.VTGateConn) {
gproto.BoundKeyspaceIdQuery{
Sql: echoPrefix + query,
Keyspace: keyspace,
KeyspaceIds: key.ProtoToKeyspaceIds(keyspaceIDs),
KeyspaceIds: keyspaceIDs,
BindVariables: bindVars,
},
}, tabletType, true)
@ -336,7 +334,7 @@ func testEchoTransactionExecute(t *testing.T, conn *vtgateconn.VTGateConn) {
"callerId": callerIDEcho,
"query": echoPrefix + query,
"keyspace": keyspace,
"keyspaceIds": keyspaceIDsEchoOld,
"keyspaceIds": keyspaceIDsEcho,
"bindVars": bindVarsEcho,
"tabletType": tabletTypeEcho,
"session": sessionEcho,

Просмотреть файл

@ -104,18 +104,9 @@ func ParseKeyspaceIDType(param string) (pb.KeyspaceIdType, error) {
}
//
// KeyRange definitions
// KeyRange helper methods
//
// KeyRange is an interval of KeyspaceId values. It contains Start,
// but excludes End. In other words, it is: [Start, End)
type KeyRange struct {
Start KeyspaceId
End KeyspaceId
}
//go:generate bsongen -file $GOFILE -type KeyRange -o key_range_bson.go
// KeyRangeContains returns true if the provided id is in the keyrange.
func KeyRangeContains(kr *pb.KeyRange, id []byte) bool {
if kr == nil {
@ -125,10 +116,6 @@ func KeyRangeContains(kr *pb.KeyRange, id []byte) bool {
(len(kr.End) == 0 || string(id) < string(kr.End))
}
func (kr KeyRange) String() string {
return fmt.Sprintf("{Start: %v, End: %v}", string(kr.Start.Hex()), string(kr.End.Hex()))
}
// ParseKeyRangeParts parses a start and end hex values and build a proto KeyRange
func ParseKeyRangeParts(start, end string) (*pb.KeyRange, error) {
s, err := hex.DecodeString(start)
@ -256,26 +243,6 @@ func (p KeyspaceIdArray) Swap(i, j int) {
func (p KeyspaceIdArray) Sort() { sort.Sort(p) }
//
// KeyRangeArray definitions
//
// KeyRangeArray is an array of KeyRange that can be sorted
// We use it only if we need to sort []KeyRange
type KeyRangeArray []KeyRange
func (p KeyRangeArray) Len() int { return len(p) }
func (p KeyRangeArray) Less(i, j int) bool {
return p[i].Start < p[j].Start
}
func (p KeyRangeArray) Swap(i, j int) {
p[i], p[j] = p[j], p[i]
}
func (p KeyRangeArray) Sort() { sort.Sort(p) }
// ParseShardingSpec parses a string that describes a sharding
// specification. a-b-c-d will be parsed as a-b, b-c, c-d. The empty
// string may serve both as the start and end of the keyspace: -a-b-

Просмотреть файл

@ -1,50 +0,0 @@
// Copyright 2012, Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package key
// DO NOT EDIT.
// FILE GENERATED BY BSONGEN.
import (
"bytes"
"github.com/youtube/vitess/go/bson"
"github.com/youtube/vitess/go/bytes2"
)
// MarshalBson bson-encodes KeyRange.
func (keyRange *KeyRange) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
bson.EncodeOptionalPrefix(buf, bson.Object, key)
lenWriter := bson.NewLenWriter(buf)
keyRange.Start.MarshalBson(buf, "Start")
keyRange.End.MarshalBson(buf, "End")
lenWriter.Close()
}
// UnmarshalBson bson-decodes into KeyRange.
func (keyRange *KeyRange) UnmarshalBson(buf *bytes.Buffer, kind byte) {
switch kind {
case bson.EOO, bson.Object:
// valid
case bson.Null:
return
default:
panic(bson.NewBsonError("unexpected kind %v for KeyRange", kind))
}
bson.Next(buf, 4)
for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
switch bson.ReadCString(buf) {
case "Start":
keyRange.Start.UnmarshalBson(buf, kind)
case "End":
keyRange.End.UnmarshalBson(buf, kind)
default:
bson.Skip(buf, kind)
}
}
}

Просмотреть файл

@ -1,76 +0,0 @@
// Copyright 2015, Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package key
import pb "github.com/youtube/vitess/go/vt/proto/topodata"
// This file contains the functions to convert topo data to and from proto3
// KeyRangeToProto translates a KeyRange to proto, or panics
func KeyRangeToProto(k KeyRange) *pb.KeyRange {
return &pb.KeyRange{
Start: []byte(k.Start),
End: []byte(k.End),
}
}
// ProtoToKeyRange translates a proto KeyRange, or panics
func ProtoToKeyRange(k *pb.KeyRange) KeyRange {
if k == nil {
return KeyRange{}
}
return KeyRange{
Start: KeyspaceId(k.Start),
End: KeyspaceId(k.End),
}
}
// KeyRangesToProto translates an array of KeyRange to proto
func KeyRangesToProto(ks []KeyRange) []*pb.KeyRange {
if len(ks) == 0 {
return nil
}
result := make([]*pb.KeyRange, len(ks))
for i, k := range ks {
result[i] = KeyRangeToProto(k)
}
return result
}
// ProtoToKeyRanges translates a proto into an array of KeyRanges
func ProtoToKeyRanges(ks []*pb.KeyRange) []KeyRange {
if len(ks) == 0 {
return nil
}
result := make([]KeyRange, len(ks))
for i, k := range ks {
result[i] = ProtoToKeyRange(k)
}
return result
}
// KeyspaceIdsToProto translates an array of KeyspaceId to proto
func KeyspaceIdsToProto(l []KeyspaceId) [][]byte {
if len(l) == 0 {
return nil
}
result := make([][]byte, len(l))
for i, k := range l {
result[i] = []byte(k)
}
return result
}
// ProtoToKeyspaceIds translates a proto into an array of KeyspaceIds
func ProtoToKeyspaceIds(l [][]byte) []KeyspaceId {
if len(l) == 0 {
return nil
}
result := make([]KeyspaceId, len(l))
for i, k := range l {
result[i] = KeyspaceId(k)
}
return result
}

Просмотреть файл

@ -13,7 +13,6 @@ import (
"github.com/youtube/vitess/go/rpcplus"
"github.com/youtube/vitess/go/rpcwrap/bsonrpc"
"github.com/youtube/vitess/go/vt/callerid"
"github.com/youtube/vitess/go/vt/key"
"github.com/youtube/vitess/go/vt/rpc"
tproto "github.com/youtube/vitess/go/vt/tabletserver/proto"
"github.com/youtube/vitess/go/vt/vterrors"
@ -132,7 +131,7 @@ func (conn *vtgateConn) ExecuteKeyspaceIds(ctx context.Context, query string, ke
Sql: query,
BindVariables: bindVars,
Keyspace: keyspace,
KeyspaceIds: key.ProtoToKeyspaceIds(keyspaceIds),
KeyspaceIds: keyspaceIds,
TabletType: tabletType,
Session: s,
NotInTransaction: notInTransaction,
@ -154,7 +153,7 @@ func (conn *vtgateConn) ExecuteKeyRanges(ctx context.Context, query string, keys
Sql: query,
BindVariables: bindVars,
Keyspace: keyspace,
KeyRanges: key.ProtoToKeyRanges(keyRanges),
KeyRanges: keyRanges,
TabletType: tabletType,
Session: s,
NotInTransaction: notInTransaction,
@ -292,7 +291,7 @@ func (conn *vtgateConn) StreamExecuteKeyRanges(ctx context.Context, query string
Sql: query,
BindVariables: bindVars,
Keyspace: keyspace,
KeyRanges: key.ProtoToKeyRanges(keyRanges),
KeyRanges: keyRanges,
TabletType: tabletType,
Session: nil,
}
@ -307,7 +306,7 @@ func (conn *vtgateConn) StreamExecuteKeyRanges2(ctx context.Context, query strin
Sql: query,
BindVariables: bindVars,
Keyspace: keyspace,
KeyRanges: key.ProtoToKeyRanges(keyRanges),
KeyRanges: keyRanges,
TabletType: tabletType,
Session: nil,
}
@ -322,7 +321,7 @@ func (conn *vtgateConn) StreamExecuteKeyspaceIds(ctx context.Context, query stri
Sql: query,
BindVariables: bindVars,
Keyspace: keyspace,
KeyspaceIds: key.ProtoToKeyspaceIds(keyspaceIds),
KeyspaceIds: keyspaceIds,
TabletType: tabletType,
Session: nil,
}
@ -337,7 +336,7 @@ func (conn *vtgateConn) StreamExecuteKeyspaceIds2(ctx context.Context, query str
Sql: query,
BindVariables: bindVars,
Keyspace: keyspace,
KeyspaceIds: key.ProtoToKeyspaceIds(keyspaceIds),
KeyspaceIds: keyspaceIds,
TabletType: tabletType,
Session: nil,
}

Просмотреть файл

@ -12,7 +12,6 @@ import (
"golang.org/x/net/context"
"github.com/youtube/vitess/go/vt/callerid"
"github.com/youtube/vitess/go/vt/key"
"github.com/youtube/vitess/go/vt/rpc"
"github.com/youtube/vitess/go/vt/servenv"
"github.com/youtube/vitess/go/vt/vtgate"
@ -111,7 +110,7 @@ func (vtg *VTGate) ExecuteKeyspaceIds(ctx context.Context, request *proto.Keyspa
request.Sql,
request.BindVariables,
request.Keyspace,
key.KeyspaceIdsToProto(request.KeyspaceIds),
request.KeyspaceIds,
request.TabletType,
request.Session,
request.NotInTransaction,
@ -134,7 +133,7 @@ func (vtg *VTGate) ExecuteKeyRanges(ctx context.Context, request *proto.KeyRange
request.Sql,
request.BindVariables,
request.Keyspace,
key.KeyRangesToProto(request.KeyRanges),
request.KeyRanges,
request.TabletType,
request.Session,
request.NotInTransaction,
@ -298,7 +297,7 @@ func (vtg *VTGate) StreamExecuteKeyspaceIds(ctx context.Context, request *proto.
request.Sql,
request.BindVariables,
request.Keyspace,
key.KeyspaceIdsToProto(request.KeyspaceIds),
request.KeyspaceIds,
request.TabletType,
func(value *proto.QueryResult) error {
return sendReply(value)
@ -316,7 +315,7 @@ func (vtg *VTGate) StreamExecuteKeyspaceIds2(ctx context.Context, request *proto
request.Sql,
request.BindVariables,
request.Keyspace,
key.KeyspaceIdsToProto(request.KeyspaceIds),
request.KeyspaceIds,
request.TabletType,
func(value *proto.QueryResult) error {
return sendReply(value)
@ -341,7 +340,7 @@ func (vtg *VTGate) StreamExecuteKeyRanges(ctx context.Context, request *proto.Ke
request.Sql,
request.BindVariables,
request.Keyspace,
key.KeyRangesToProto(request.KeyRanges),
request.KeyRanges,
request.TabletType,
func(value *proto.QueryResult) error {
return sendReply(value)
@ -359,7 +358,7 @@ func (vtg *VTGate) StreamExecuteKeyRanges2(ctx context.Context, request *proto.K
request.Sql,
request.BindVariables,
request.Keyspace,
key.KeyRangesToProto(request.KeyRanges),
request.KeyRanges,
request.TabletType,
func(value *proto.QueryResult) error {
return sendReply(value)

Просмотреть файл

@ -5,7 +5,6 @@
package proto
import (
"github.com/youtube/vitess/go/vt/key"
tproto "github.com/youtube/vitess/go/vt/tabletserver/proto"
pbq "github.com/youtube/vitess/go/vt/proto/query"
@ -39,7 +38,7 @@ func ProtoToEntityIds(l []*pb.ExecuteEntityIdsRequest_EntityId) []EntityId {
}
result := make([]EntityId, len(l))
for i, e := range l {
result[i].KeyspaceID = key.KeyspaceId(e.KeyspaceId)
result[i].KeyspaceID = e.KeyspaceId
bv := &pbq.BindVariable{
Type: e.XidType,
Value: e.XidValue,
@ -106,7 +105,7 @@ func BoundKeyspaceIdQueriesToProto(bsq []BoundKeyspaceIdQuery) ([]*pb.BoundKeysp
result[i] = &pb.BoundKeyspaceIdQuery{
Query: qq,
Keyspace: q.Keyspace,
KeyspaceIds: key.KeyspaceIdsToProto(q.KeyspaceIds),
KeyspaceIds: q.KeyspaceIds,
}
}
return result, nil
@ -126,7 +125,7 @@ func ProtoToBoundKeyspaceIdQueries(bsq []*pb.BoundKeyspaceIdQuery) ([]BoundKeysp
result[i].Sql = string(q.Query.Sql)
result[i].BindVariables = bv
result[i].Keyspace = q.Keyspace
result[i].KeyspaceIds = key.ProtoToKeyspaceIds(q.KeyspaceIds)
result[i].KeyspaceIds = q.KeyspaceIds
}
return result, nil
}

Просмотреть файл

@ -6,7 +6,6 @@ package proto
import (
mproto "github.com/youtube/vitess/go/mysql/proto"
"github.com/youtube/vitess/go/vt/key"
tproto "github.com/youtube/vitess/go/vt/tabletserver/proto"
pbt "github.com/youtube/vitess/go/vt/proto/topodata"
@ -43,7 +42,7 @@ type KeyspaceIdQuery struct {
Sql string
BindVariables map[string]interface{}
Keyspace string
KeyspaceIds []key.KeyspaceId
KeyspaceIds [][]byte
TabletType pbt.TabletType
Session *pb.Session
NotInTransaction bool
@ -56,7 +55,7 @@ type KeyRangeQuery struct {
Sql string
BindVariables map[string]interface{}
Keyspace string
KeyRanges []key.KeyRange
KeyRanges []*pbt.KeyRange
TabletType pbt.TabletType
Session *pb.Session
NotInTransaction bool
@ -65,7 +64,7 @@ type KeyRangeQuery struct {
// EntityId represents a tuple of external_id and keyspace_id
type EntityId struct {
ExternalID interface{}
KeyspaceID key.KeyspaceId
KeyspaceID []byte
}
// EntityIdsQuery represents a query request for the specified KeyspaceId map.
@ -116,7 +115,7 @@ type BoundKeyspaceIdQuery struct {
Sql string
BindVariables map[string]interface{}
Keyspace string
KeyspaceIds []key.KeyspaceId
KeyspaceIds [][]byte
}
// KeyspaceIdBatchQuery represents a batch query request

Просмотреть файл

@ -15,7 +15,6 @@ import (
mproto "github.com/youtube/vitess/go/mysql/proto"
"github.com/youtube/vitess/go/sqltypes"
"github.com/youtube/vitess/go/vt/key"
"github.com/youtube/vitess/go/vt/tabletserver/tabletconn"
"github.com/youtube/vitess/go/vt/topo"
"github.com/youtube/vitess/go/vt/vtgate/proto"
@ -83,21 +82,16 @@ func TestResolverExecuteEntityIds(t *testing.T) {
func TestResolverExecuteBatchKeyspaceIds(t *testing.T) {
testResolverGeneric(t, "TestResolverExecuteBatchKeyspaceIds", func() (*mproto.QueryResult, error) {
kid10, err := key.HexKeyspaceId("10").Unhex()
if err != nil {
return nil, err
}
kid25, err := key.HexKeyspaceId("25").Unhex()
if err != nil {
return nil, err
}
res := NewResolver(nil, topo.Server{}, new(sandboxTopo), "", "aa", retryDelay, 0, connTimeoutTotal, connTimeoutPerConn, connLife, "")
qrs, err := res.ExecuteBatchKeyspaceIds(context.Background(),
[]proto.BoundKeyspaceIdQuery{{
Sql: "query",
BindVariables: nil,
Keyspace: "TestResolverExecuteBatchKeyspaceIds",
KeyspaceIds: []key.KeyspaceId{kid10, kid25},
KeyspaceIds: [][]byte{
[]byte{0x10},
[]byte{0x25},
},
}},
pb.TabletType_MASTER,
false,

Просмотреть файл

@ -213,7 +213,7 @@ func boundShardQueriesToScatterBatchRequest(boundQueries []proto.BoundShardQuery
func boundKeyspaceIDQueriesToBoundShardQueries(ctx context.Context, topoServ SrvTopoServer, cell string, tabletType pb.TabletType, idQueries []proto.BoundKeyspaceIdQuery) ([]proto.BoundShardQuery, error) {
shardQueries := make([]proto.BoundShardQuery, len(idQueries))
for i, idQuery := range idQueries {
keyspace, shards, err := mapKeyspaceIdsToShards(ctx, topoServ, cell, idQuery.Keyspace, tabletType, key.KeyspaceIdsToProto(idQuery.KeyspaceIds))
keyspace, shards, err := mapKeyspaceIdsToShards(ctx, topoServ, cell, idQuery.Keyspace, tabletType, idQuery.KeyspaceIds)
if err != nil {
return nil, err
}

Просмотреть файл

@ -212,14 +212,8 @@ func TestBoundShardQueriesToScatterBatchRequest(t *testing.T) {
func TestBoundKeyspaceIdQueriesToBoundShardQueries(t *testing.T) {
ts := new(sandboxTopo)
kid10, err := key.HexKeyspaceId("10").Unhex()
if err != nil {
t.Error(err)
}
kid25, err := key.HexKeyspaceId("25").Unhex()
if err != nil {
t.Error(err)
}
kid10 := []byte{0x10}
kid25 := []byte{0x25}
var testCases = []struct {
idQueries []proto.BoundKeyspaceIdQuery
shardQueries []proto.BoundShardQuery
@ -230,12 +224,12 @@ func TestBoundKeyspaceIdQueriesToBoundShardQueries(t *testing.T) {
Sql: "q1",
BindVariables: map[string]interface{}{"q1var": 1},
Keyspace: KsTestSharded,
KeyspaceIds: []key.KeyspaceId{kid10, kid25},
KeyspaceIds: [][]byte{kid10, kid25},
}, {
Sql: "q2",
BindVariables: map[string]interface{}{"q2var": 2},
Keyspace: KsTestSharded,
KeyspaceIds: []key.KeyspaceId{kid25, kid25},
KeyspaceIds: [][]byte{kid25, kid25},
},
},
shardQueries: []proto.BoundShardQuery{

Просмотреть файл

@ -517,26 +517,20 @@ func TestVTGateExecuteBatchKeyspaceIds(t *testing.T) {
s := createSandbox("TestVTGateExecuteBatchKeyspaceIds")
s.MapTestConn("-20", &sandboxConn{})
s.MapTestConn("20-40", &sandboxConn{})
kid10, err := key.HexKeyspaceId("10").Unhex()
if err != nil {
t.Errorf("want nil, got %v", err)
}
kid30, err := key.HexKeyspaceId("30").Unhex()
if err != nil {
t.Errorf("want nil, got %v", err)
}
kid10 := []byte{0x10}
kid30 := []byte{0x30}
qrl := new(proto.QueryResultList)
err = rpcVTGate.ExecuteBatchKeyspaceIds(context.Background(),
err := rpcVTGate.ExecuteBatchKeyspaceIds(context.Background(),
[]proto.BoundKeyspaceIdQuery{{
Sql: "query",
BindVariables: nil,
Keyspace: "TestVTGateExecuteBatchKeyspaceIds",
KeyspaceIds: []key.KeyspaceId{kid10, kid30},
KeyspaceIds: [][]byte{kid10, kid30},
}, {
Sql: "query",
BindVariables: nil,
Keyspace: "TestVTGateExecuteBatchKeyspaceIds",
KeyspaceIds: []key.KeyspaceId{kid10, kid30},
KeyspaceIds: [][]byte{kid10, kid30},
}},
pb.TabletType_MASTER,
false,
@ -562,12 +556,12 @@ func TestVTGateExecuteBatchKeyspaceIds(t *testing.T) {
Sql: "query",
BindVariables: nil,
Keyspace: "TestVTGateExecuteBatchKeyspaceIds",
KeyspaceIds: []key.KeyspaceId{kid10, kid30},
KeyspaceIds: [][]byte{kid10, kid30},
}, {
Sql: "query",
BindVariables: nil,
Keyspace: "TestVTGateExecuteBatchKeyspaceIds",
KeyspaceIds: []key.KeyspaceId{kid10, kid30},
KeyspaceIds: [][]byte{kid10, kid30},
}},
pb.TabletType_MASTER,
false,
@ -963,17 +957,17 @@ func TestAnnotatingExecuteBatchKeyspaceIds(t *testing.T) {
proto.BoundKeyspaceIdQuery{
Sql: "INSERT INTO table () VALUES();",
Keyspace: keyspace,
KeyspaceIds: []key.KeyspaceId{key.KeyspaceId([]byte{0x10})},
KeyspaceIds: [][]byte{[]byte{0x10}},
},
proto.BoundKeyspaceIdQuery{
Sql: "UPDATE table SET col1=1 WHERE col2>3;",
Keyspace: keyspace,
KeyspaceIds: []key.KeyspaceId{key.KeyspaceId([]byte{0x15})},
KeyspaceIds: [][]byte{[]byte{0x15}},
},
proto.BoundKeyspaceIdQuery{
Sql: "DELETE FROM table WHERE col1==4;",
Keyspace: keyspace,
KeyspaceIds: []key.KeyspaceId{key.KeyspaceId([]byte{0x25})},
KeyspaceIds: [][]byte{[]byte{0x25}},
},
},
pb.TabletType_MASTER,
@ -1002,9 +996,9 @@ func TestAnnotatingExecuteBatchKeyspaceIdsMultipleIds(t *testing.T) {
proto.BoundKeyspaceIdQuery{
Sql: "INSERT INTO table () VALUES();",
Keyspace: keyspace,
KeyspaceIds: []key.KeyspaceId{
key.KeyspaceId([]byte{0x10}),
key.KeyspaceId([]byte{0x15}),
KeyspaceIds: [][]byte{
[]byte{0x10},
[]byte{0x15},
},
},
},

Просмотреть файл

@ -18,7 +18,6 @@ import (
"github.com/youtube/vitess/go/sqltypes"
"github.com/youtube/vitess/go/tb"
"github.com/youtube/vitess/go/vt/callerid"
"github.com/youtube/vitess/go/vt/key"
"github.com/youtube/vitess/go/vt/vterrors"
"github.com/youtube/vitess/go/vt/vtgate/proto"
"github.com/youtube/vitess/go/vt/vtgate/vtgateconn"
@ -1114,7 +1113,7 @@ func testExecuteBatchKeyspaceIds(t *testing.T, conn *vtgateconn.VTGateConn) {
t.Errorf("Unexpected result from Execute: got %+v want %+v", ql, execCase.reply.Result)
}
_, err = conn.ExecuteBatchKeyspaceIds(ctx, []proto.BoundKeyspaceIdQuery{proto.BoundKeyspaceIdQuery{Sql: "none", KeyspaceIds: []key.KeyspaceId{}}}, pb.TabletType_REPLICA, false)
_, err = conn.ExecuteBatchKeyspaceIds(ctx, []proto.BoundKeyspaceIdQuery{proto.BoundKeyspaceIdQuery{Sql: "none", KeyspaceIds: [][]byte{}}}, pb.TabletType_REPLICA, false)
want := "no match for: none"
if err == nil || !strings.Contains(err.Error(), want) {
t.Errorf("none request: %v, want %v", err, want)
@ -2358,8 +2357,8 @@ var execMap = map[string]struct {
"bind1": int64(0),
},
Keyspace: "ks",
KeyspaceIds: []key.KeyspaceId{
key.KeyspaceId("ki1"),
KeyspaceIds: [][]byte{
[]byte{'k', 'i', '1'},
},
},
},
@ -2459,8 +2458,8 @@ var execMap = map[string]struct {
"bind1": int64(0),
},
Keyspace: "ks",
KeyspaceIds: []key.KeyspaceId{
key.KeyspaceId("ki1"),
KeyspaceIds: [][]byte{
[]byte{'k', 'i', '1'},
},
},
},
@ -2564,8 +2563,8 @@ var execMap = map[string]struct {
"bind1": int64(0),
},
Keyspace: "ks",
KeyspaceIds: []key.KeyspaceId{
key.KeyspaceId("ki1"),
KeyspaceIds: [][]byte{
[]byte{'k', 'i', '1'},
},
},
},
@ -2670,8 +2669,8 @@ var execMap = map[string]struct {
"bind1": int64(0),
},
Keyspace: "ks",
KeyspaceIds: []key.KeyspaceId{
key.KeyspaceId("ki1"),
KeyspaceIds: [][]byte{
[]byte{'k', 'i', '1'},
},
},
},

Просмотреть файл

@ -75,7 +75,6 @@ public abstract class RpcClientTest {
private static final List<byte[]> KEYSPACE_IDS =
Arrays.asList(new byte[] {1, 2, 3, 4}, new byte[] {5, 6, 7, 8});
private static final String KEYSPACE_IDS_ECHO = "[[1 2 3 4] [5 6 7 8]]";
private static final String KEYSPACE_IDS_ECHO_OLD = "[01020304 05060708]";
private static final List<KeyRange> KEY_RANGES = Arrays.asList(
KeyRange.newBuilder()
@ -208,7 +207,7 @@ public abstract class RpcClientTest {
Assert.assertEquals(CALLER_ID_ECHO, echo.get("callerId"));
Assert.assertEquals(ECHO_PREFIX + QUERY, echo.get("query"));
Assert.assertEquals(KEYSPACE, echo.get("keyspace"));
Assert.assertEquals(KEYSPACE_IDS_ECHO_OLD, echo.get("keyspaceIds"));
Assert.assertEquals(KEYSPACE_IDS_ECHO, echo.get("keyspaceIds"));
Assert.assertEquals(BIND_VARS_ECHO, echo.get("bindVars"));
Assert.assertEquals(TABLET_TYPE_ECHO, echo.get("tabletType"));
Assert.assertEquals("true", echo.get("asTransaction"));
@ -333,7 +332,7 @@ public abstract class RpcClientTest {
Assert.assertEquals(CALLER_ID_ECHO, echo.get("callerId"));
Assert.assertEquals(ECHO_PREFIX + QUERY, echo.get("query"));
Assert.assertEquals(KEYSPACE, echo.get("keyspace"));
Assert.assertEquals(KEYSPACE_IDS_ECHO_OLD, echo.get("keyspaceIds"));
Assert.assertEquals(KEYSPACE_IDS_ECHO, echo.get("keyspaceIds"));
Assert.assertEquals(BIND_VARS_ECHO, echo.get("bindVars"));
Assert.assertEquals(TABLET_TYPE_ECHO, echo.get("tabletType"));
Assert.assertEquals(SESSION_ECHO, echo.get("session"));

Просмотреть файл

@ -32,7 +32,6 @@ class VTGateConnTest extends PHPUnit_Framework_TestCase {
private static $SHARDS_ECHO = '[-80 80-]';
private static $KEYSPACE_IDS; // initialized in setUpBeforeClass()
private static $KEYSPACE_IDS_ECHO = '[[128 0 0 0 0 0 0 0] [255 0 0 0 0 0 0 239]]';
private static $KEYSPACE_IDS_ECHO_OLD = '[8000000000000000 ff000000000000ef]';
private static $KEY_RANGES; // initialized in setUpBeforeClass()
private static $KEY_RANGES_ECHO = '[end:"\200\000\000\000\000\000\000\000" start:"\200\000\000\000\000\000\000\000" ]';
private static $ENTITY_COLUMN_NAME = 'test_column';
@ -203,7 +202,7 @@ class VTGateConnTest extends PHPUnit_Framework_TestCase {
$this->assertEquals(self::$CALLER_ID_ECHO, $echo['callerId']);
$this->assertEquals(self::$ECHO_QUERY, $echo['query']);
$this->assertEquals(self::$KEYSPACE, $echo['keyspace']);
$this->assertEquals(self::$KEYSPACE_IDS_ECHO_OLD, $echo['keyspaceIds']);
$this->assertEquals(self::$KEYSPACE_IDS_ECHO, $echo['keyspaceIds']);
$this->assertEquals(self::$BIND_VARS_ECHO, $echo['bindVars']);
$this->assertEquals(self::$TABLET_TYPE_ECHO, $echo['tabletType']);
$this->assertEquals('true', $echo['asTransaction']);
@ -322,7 +321,7 @@ class VTGateConnTest extends PHPUnit_Framework_TestCase {
$this->assertEquals(self::$CALLER_ID_ECHO, $echo['callerId']);
$this->assertEquals(self::$ECHO_QUERY, $echo['query']);
$this->assertEquals(self::$KEYSPACE, $echo['keyspace']);
$this->assertEquals(self::$KEYSPACE_IDS_ECHO_OLD, $echo['keyspaceIds']);
$this->assertEquals(self::$KEYSPACE_IDS_ECHO, $echo['keyspaceIds']);
$this->assertEquals(self::$BIND_VARS_ECHO, $echo['bindVars']);
$this->assertEquals(self::$TABLET_TYPE_ECHO, $echo['tabletType']);
$this->assertEquals(self::$SESSION_ECHO, $echo['session']);