Skip to content

Commit 7a3ce0a

Browse files
authored
refac: deprecate vitess/go/maps2 for golang.org/x/exp/maps (#14960)
Signed-off-by: Eshaan Aggarwal <96648934+EshaanAgg@users.noreply.github.com>
1 parent 44299cf commit 7a3ce0a

File tree

7 files changed

+17
-52
lines changed

7 files changed

+17
-52
lines changed

go/maps2/maps.go

Lines changed: 0 additions & 37 deletions
This file was deleted.

go/vt/vtctl/workflow/switcher_dry_run.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ import (
2424
"strings"
2525
"time"
2626

27-
"vitess.io/vitess/go/maps2"
27+
"golang.org/x/exp/maps"
28+
2829
"vitess.io/vitess/go/mysql/replication"
2930

3031
binlogdatapb "vitess.io/vitess/go/vt/proto/binlogdata"
@@ -380,7 +381,7 @@ func (dr *switcherDryRun) resetSequences(ctx context.Context) error {
380381
}
381382

382383
func (dr *switcherDryRun) initializeTargetSequences(ctx context.Context, sequencesByBackingTable map[string]*sequenceMetadata) error {
383-
sortedBackingTableNames := maps2.Keys(sequencesByBackingTable)
384+
sortedBackingTableNames := maps.Keys(sequencesByBackingTable)
384385
slices.Sort(sortedBackingTableNames)
385386
dr.drLog.Log(fmt.Sprintf("The following sequence backing tables used by tables being moved will be initialized: %s",
386387
strings.Join(sortedBackingTableNames, ",")))

go/vt/vtctl/workflow/traffic_switcher.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ import (
2525
"sync"
2626
"time"
2727

28+
"golang.org/x/exp/maps"
2829
"golang.org/x/sync/errgroup"
2930

3031
"vitess.io/vitess/go/json2"
31-
"vitess.io/vitess/go/maps2"
3232
"vitess.io/vitess/go/sqlescape"
3333
"vitess.io/vitess/go/sqltypes"
3434
"vitess.io/vitess/go/vt/binlog/binlogplayer"
@@ -1347,7 +1347,7 @@ func (ts *trafficSwitcher) getTargetSequenceMetadata(ctx context.Context) (map[s
13471347
// error if any is seen.
13481348
func (ts *trafficSwitcher) findSequenceUsageInKeyspace(vschema *vschemapb.Keyspace) (map[string]*sequenceMetadata, bool, error) {
13491349
allFullyQualified := true
1350-
targets := maps2.Values(ts.Targets())
1350+
targets := maps.Values(ts.Targets())
13511351
if len(targets) == 0 || targets[0].GetPrimary() == nil { // This should never happen
13521352
return nil, false, vterrors.Errorf(vtrpcpb.Code_INTERNAL, "no primary tablet found for target keyspace %s", ts.targetKeyspace)
13531353
}

go/vt/vttablet/tabletserver/schema/db_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ import (
2323
"testing"
2424

2525
"github.com/stretchr/testify/require"
26+
"golang.org/x/exp/maps"
2627

2728
"vitess.io/vitess/go/constants/sidecar"
28-
"vitess.io/vitess/go/maps2"
2929
"vitess.io/vitess/go/mysql/collations"
3030
"vitess.io/vitess/go/mysql/config"
3131
"vitess.io/vitess/go/mysql/fakesqldb"
@@ -150,7 +150,7 @@ func TestGetChangedViewNames(t *testing.T) {
150150
got, err := getChangedViewNames(context.Background(), conn, true)
151151
require.NoError(t, err)
152152
require.Len(t, got, 3)
153-
require.ElementsMatch(t, maps2.Keys(got), []string{"v1", "v2", "lead"})
153+
require.ElementsMatch(t, maps.Keys(got), []string{"v1", "v2", "lead"})
154154
require.NoError(t, db.LastError())
155155

156156
// Not serving primary
@@ -187,7 +187,7 @@ func TestGetViewDefinition(t *testing.T) {
187187
got, err := collectGetViewDefinitions(conn, bv)
188188
require.NoError(t, err)
189189
require.Len(t, got, 2)
190-
require.ElementsMatch(t, maps2.Keys(got), []string{"v1", "lead"})
190+
require.ElementsMatch(t, maps.Keys(got), []string{"v1", "lead"})
191191
require.Equal(t, "create_view_v1", got["v1"])
192192
require.Equal(t, "create_view_lead", got["lead"])
193193
require.NoError(t, db.LastError())
@@ -358,7 +358,7 @@ func TestGetMismatchedTableNames(t *testing.T) {
358358
if tc.expectedError != "" {
359359
require.ErrorContains(t, err, tc.expectedError)
360360
} else {
361-
require.ElementsMatch(t, maps2.Keys(mismatchedTableNames), tc.expectedTableNames)
361+
require.ElementsMatch(t, maps.Keys(mismatchedTableNames), tc.expectedTableNames)
362362
require.NoError(t, db.LastError())
363363
}
364364
})

go/vt/vttablet/tabletserver/schema/engine.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ import (
2121
"context"
2222
"encoding/json"
2323
"fmt"
24-
"maps"
2524
"net/http"
2625
"strings"
2726
"sync"
2827
"time"
2928

29+
"golang.org/x/exp/maps"
30+
3031
"vitess.io/vitess/go/constants/sidecar"
31-
"vitess.io/vitess/go/maps2"
3232
"vitess.io/vitess/go/mysql/collations"
3333
"vitess.io/vitess/go/mysql/config"
3434
"vitess.io/vitess/go/mysql/replication"
@@ -589,7 +589,7 @@ func (se *Engine) getDroppedTables(curTables map[string]bool, changedViews map[s
589589
}
590590
}
591591

592-
return maps2.Values(dropped)
592+
return maps.Values(dropped)
593593
}
594594

595595
func getTableData(ctx context.Context, conn *connpool.Conn, includeStats bool) (*sqltypes.Result, error) {

go/vt/wrangler/switcher_dry_run.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ import (
2424
"strings"
2525
"time"
2626

27-
"vitess.io/vitess/go/maps2"
27+
"golang.org/x/exp/maps"
28+
2829
"vitess.io/vitess/go/mysql/replication"
2930
"vitess.io/vitess/go/vt/vtctl/workflow"
3031

@@ -399,7 +400,7 @@ func (dr *switcherDryRun) resetSequences(ctx context.Context) error {
399400
}
400401

401402
func (dr *switcherDryRun) initializeTargetSequences(ctx context.Context, sequencesByBackingTable map[string]*sequenceMetadata) error {
402-
sortedBackingTableNames := maps2.Keys(sequencesByBackingTable)
403+
sortedBackingTableNames := maps.Keys(sequencesByBackingTable)
403404
slices.Sort(sortedBackingTableNames)
404405
dr.drLog.Log(fmt.Sprintf("The following sequence backing tables used by tables being moved will be initialized: %s",
405406
strings.Join(sortedBackingTableNames, ",")))

go/vt/wrangler/traffic_switcher.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ import (
2626
"sync"
2727
"time"
2828

29+
"golang.org/x/exp/maps"
2930
"golang.org/x/sync/errgroup"
3031

3132
"vitess.io/vitess/go/mysql/collations"
3233

3334
"vitess.io/vitess/go/json2"
34-
"vitess.io/vitess/go/maps2"
3535
"vitess.io/vitess/go/sqlescape"
3636
"vitess.io/vitess/go/sqltypes"
3737
"vitess.io/vitess/go/vt/binlog/binlogplayer"
@@ -2108,7 +2108,7 @@ func (ts *trafficSwitcher) getTargetSequenceMetadata(ctx context.Context) (map[s
21082108
// error if any is seen.
21092109
func (ts *trafficSwitcher) findSequenceUsageInKeyspace(vschema *vschemapb.Keyspace) (map[string]*sequenceMetadata, bool, error) {
21102110
allFullyQualified := true
2111-
targets := maps2.Values(ts.Targets())
2111+
targets := maps.Values(ts.Targets())
21122112
if len(targets) == 0 || targets[0].GetPrimary() == nil { // This should never happen
21132113
return nil, false, vterrors.Errorf(vtrpcpb.Code_INTERNAL, "no primary tablet found for target keyspace %s", ts.targetKeyspace)
21142114
}

0 commit comments

Comments
 (0)