Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refac: deprecate vitess/go/maps2 for golang.org/x/exp/maps #14960

Merged
merged 5 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions go/maps2/maps.go

This file was deleted.

5 changes: 3 additions & 2 deletions go/vt/vtctl/workflow/switcher_dry_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"strings"
"time"

"vitess.io/vitess/go/maps2"
"golang.org/x/exp/maps"

"vitess.io/vitess/go/mysql/replication"

binlogdatapb "vitess.io/vitess/go/vt/proto/binlogdata"
Expand Down Expand Up @@ -380,7 +381,7 @@
}

func (dr *switcherDryRun) initializeTargetSequences(ctx context.Context, sequencesByBackingTable map[string]*sequenceMetadata) error {
sortedBackingTableNames := maps2.Keys(sequencesByBackingTable)
sortedBackingTableNames := maps.Keys(sequencesByBackingTable)

Check warning on line 384 in go/vt/vtctl/workflow/switcher_dry_run.go

View check run for this annotation

Codecov / codecov/patch

go/vt/vtctl/workflow/switcher_dry_run.go#L384

Added line #L384 was not covered by tests
slices.Sort(sortedBackingTableNames)
dr.drLog.Log(fmt.Sprintf("The following sequence backing tables used by tables being moved will be initialized: %s",
strings.Join(sortedBackingTableNames, ",")))
Expand Down
4 changes: 2 additions & 2 deletions go/vt/vtctl/workflow/traffic_switcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
"sync"
"time"

"golang.org/x/exp/maps"
"golang.org/x/sync/errgroup"

"vitess.io/vitess/go/json2"
"vitess.io/vitess/go/maps2"
"vitess.io/vitess/go/sqlescape"
"vitess.io/vitess/go/sqltypes"
"vitess.io/vitess/go/vt/binlog/binlogplayer"
Expand Down Expand Up @@ -1347,7 +1347,7 @@
// error if any is seen.
func (ts *trafficSwitcher) findSequenceUsageInKeyspace(vschema *vschemapb.Keyspace) (map[string]*sequenceMetadata, bool, error) {
allFullyQualified := true
targets := maps2.Values(ts.Targets())
targets := maps.Values(ts.Targets())

Check warning on line 1350 in go/vt/vtctl/workflow/traffic_switcher.go

View check run for this annotation

Codecov / codecov/patch

go/vt/vtctl/workflow/traffic_switcher.go#L1350

Added line #L1350 was not covered by tests
if len(targets) == 0 || targets[0].GetPrimary() == nil { // This should never happen
return nil, false, vterrors.Errorf(vtrpcpb.Code_INTERNAL, "no primary tablet found for target keyspace %s", ts.targetKeyspace)
}
Expand Down
8 changes: 4 additions & 4 deletions go/vt/vttablet/tabletserver/schema/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import (
"testing"

"github.com/stretchr/testify/require"
"golang.org/x/exp/maps"

"vitess.io/vitess/go/constants/sidecar"
"vitess.io/vitess/go/maps2"
"vitess.io/vitess/go/mysql/collations"
"vitess.io/vitess/go/mysql/config"
"vitess.io/vitess/go/mysql/fakesqldb"
Expand Down Expand Up @@ -150,7 +150,7 @@ func TestGetChangedViewNames(t *testing.T) {
got, err := getChangedViewNames(context.Background(), conn, true)
require.NoError(t, err)
require.Len(t, got, 3)
require.ElementsMatch(t, maps2.Keys(got), []string{"v1", "v2", "lead"})
require.ElementsMatch(t, maps.Keys(got), []string{"v1", "v2", "lead"})
require.NoError(t, db.LastError())

// Not serving primary
Expand Down Expand Up @@ -187,7 +187,7 @@ func TestGetViewDefinition(t *testing.T) {
got, err := collectGetViewDefinitions(conn, bv)
require.NoError(t, err)
require.Len(t, got, 2)
require.ElementsMatch(t, maps2.Keys(got), []string{"v1", "lead"})
require.ElementsMatch(t, maps.Keys(got), []string{"v1", "lead"})
require.Equal(t, "create_view_v1", got["v1"])
require.Equal(t, "create_view_lead", got["lead"])
require.NoError(t, db.LastError())
Expand Down Expand Up @@ -358,7 +358,7 @@ func TestGetMismatchedTableNames(t *testing.T) {
if tc.expectedError != "" {
require.ErrorContains(t, err, tc.expectedError)
} else {
require.ElementsMatch(t, maps2.Keys(mismatchedTableNames), tc.expectedTableNames)
require.ElementsMatch(t, maps.Keys(mismatchedTableNames), tc.expectedTableNames)
require.NoError(t, db.LastError())
}
})
Expand Down
6 changes: 3 additions & 3 deletions go/vt/vttablet/tabletserver/schema/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ import (
"context"
"encoding/json"
"fmt"
"maps"
"net/http"
"strings"
"sync"
"time"

"golang.org/x/exp/maps"

"vitess.io/vitess/go/constants/sidecar"
"vitess.io/vitess/go/maps2"
"vitess.io/vitess/go/mysql/collations"
"vitess.io/vitess/go/mysql/config"
"vitess.io/vitess/go/mysql/replication"
Expand Down Expand Up @@ -589,7 +589,7 @@ func (se *Engine) getDroppedTables(curTables map[string]bool, changedViews map[s
}
}

return maps2.Values(dropped)
return maps.Values(dropped)
}

func getTableData(ctx context.Context, conn *connpool.Conn, includeStats bool) (*sqltypes.Result, error) {
Expand Down
5 changes: 3 additions & 2 deletions go/vt/wrangler/switcher_dry_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import (
"strings"
"time"

"vitess.io/vitess/go/maps2"
"golang.org/x/exp/maps"
EshaanAgg marked this conversation as resolved.
Show resolved Hide resolved

"vitess.io/vitess/go/mysql/replication"
"vitess.io/vitess/go/vt/vtctl/workflow"

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

func (dr *switcherDryRun) initializeTargetSequences(ctx context.Context, sequencesByBackingTable map[string]*sequenceMetadata) error {
sortedBackingTableNames := maps2.Keys(sequencesByBackingTable)
sortedBackingTableNames := maps.Keys(sequencesByBackingTable)
slices.Sort(sortedBackingTableNames)
dr.drLog.Log(fmt.Sprintf("The following sequence backing tables used by tables being moved will be initialized: %s",
strings.Join(sortedBackingTableNames, ",")))
Expand Down
4 changes: 2 additions & 2 deletions go/vt/wrangler/traffic_switcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ import (
"sync"
"time"

"golang.org/x/exp/maps"
"golang.org/x/sync/errgroup"

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

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