Skip to content

Commit

Permalink
Remove routing multi equal optimization
Browse files Browse the repository at this point in the history
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
  • Loading branch information
frouioui committed Jan 28, 2025
1 parent 16a30f3 commit e9fb2c7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 44 deletions.
33 changes: 5 additions & 28 deletions go/vt/vtgate/engine/routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import (
"encoding/json"
"strconv"

"golang.org/x/exp/maps"

"vitess.io/vitess/go/sqltypes"
"vitess.io/vitess/go/vt/key"
"vitess.io/vitess/go/vt/log"
Expand Down Expand Up @@ -429,37 +427,16 @@ func (rp *RoutingParameters) multiEqual(ctx context.Context, vcursor VCursor, bi
if err != nil {
return nil, nil, err
}
rss, bvs, err := resolveShards(ctx, vcursor, rp.Vindex.(vindexes.SingleColumn), rp.Keyspace, value.TupleValues())
rss, _, err := resolveShards(ctx, vcursor, rp.Vindex.(vindexes.SingleColumn), rp.Keyspace, value.TupleValues())
if err != nil {
return nil, nil, err
}

tbv, ok := rp.Values[0].(*evalengine.TupleBindVariable)
if !ok {
multiBindVars := make([]map[string]*querypb.BindVariable, len(rss))
for i := range multiBindVars {
multiBindVars[i] = bindVars
}
return rss, multiBindVars, nil
}

var resultRss []*srvtopo.ResolvedShard
var resultBvs []map[string]*querypb.BindVariable
for i, rssVals := range rss {
resultRss = append(resultRss, rssVals)

clonedBindVars := maps.Clone(bindVars)

newBv := &querypb.BindVariable{
Type: querypb.Type_TUPLE,
Values: bvs[i],
}

clonedBindVars[tbv.Key] = newBv

resultBvs = append(resultBvs, clonedBindVars)
multiBindVars := make([]map[string]*querypb.BindVariable, len(rss))
for i := range multiBindVars {
multiBindVars[i] = bindVars
}
return resultRss, resultBvs, nil
return rss, multiBindVars, nil
}

func (rp *RoutingParameters) multiEqualMultiCol(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) {
Expand Down
16 changes: 0 additions & 16 deletions go/vt/vtgate/engine/routing_parameter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,4 @@ func TestFindRouteValuesJoin(t *testing.T) {
require.NoError(t, err)
require.Len(t, rss, 2)
require.Len(t, bvs, 2)

expectedIdsPerShard := [][]int64{
{1, 2},
{3, 4},
}
for i, ids := range expectedIdsPerShard {
var s []int64
for _, value := range bvs[i][valueBvName].Values {
v := sqltypes.ProtoToValue(value)
require.Equal(t, sqltypes.Int64, v.Type())
i, err := v.ToInt64()
require.NoError(t, err)
s = append(s, i)
}
require.Equal(t, ids, s)
}
}

0 comments on commit e9fb2c7

Please sign in to comment.