Skip to content

Commit 5e7f19f

Browse files
committed
avoid exp
1 parent 34ea01a commit 5e7f19f

File tree

2 files changed

+11
-20
lines changed

2 files changed

+11
-20
lines changed

internal/verifier/migration_verifier.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ import (
2626
"github.com/olekukonko/tablewriter"
2727
"github.com/pkg/errors"
2828
"github.com/rs/zerolog"
29+
"github.com/samber/lo"
2930
"go.mongodb.org/mongo-driver/bson"
3031
"go.mongodb.org/mongo-driver/bson/primitive"
3132
"go.mongodb.org/mongo-driver/mongo"
3233
"go.mongodb.org/mongo-driver/mongo/options"
3334
"go.mongodb.org/mongo-driver/mongo/readconcern"
3435
"go.mongodb.org/mongo-driver/mongo/readpref"
3536
"go.mongodb.org/mongo-driver/mongo/writeconcern"
36-
"golang.org/x/exp/maps"
3737
"golang.org/x/sync/errgroup"
3838
)
3939

@@ -755,7 +755,7 @@ func (verifier *Verifier) getShardingInfo(ctx context.Context, namespaceAndUUID
755755

756756
verifier.logger.Debug().Msgf("Collection %s is sharded with shard key %v", namespace, result.Key)
757757

758-
shardKeys = maps.Keys(result.Key)
758+
shardKeys = lo.Keys(result.Key)
759759
sort.Strings(shardKeys)
760760
}
761761
if err = cursor.Err(); err != nil {

internal/verifier/summary.go

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package verifier
77
import (
88
"context"
99
"fmt"
10+
"sort"
1011
"strconv"
1112
"strings"
1213
"time"
@@ -15,8 +16,6 @@ import (
1516
"github.com/10gen/migration-verifier/internal/types"
1617
"github.com/olekukonko/tablewriter"
1718
"github.com/samber/lo"
18-
"golang.org/x/exp/maps"
19-
"golang.org/x/exp/slices"
2019
)
2120

2221
const changeEventsTableMaxSize = 10
@@ -392,31 +391,23 @@ func (verifier *Verifier) printChangeEventStatistics(builder *strings.Builder) {
392391
return
393392
}
394393

395-
sortedNamespaces := maps.Keys(nsTotals)
396-
slices.SortFunc(
397-
sortedNamespaces,
398-
func(ns1, ns2 string) int {
399-
if nsTotals[ns1] < nsTotals[ns2] {
400-
return 1
401-
}
402-
403-
if nsTotals[ns1] > nsTotals[ns2] {
404-
return -1
405-
}
406-
407-
return 0
394+
reverseSortedNamespaces := lo.Keys(nsTotals)
395+
sort.Slice(
396+
reverseSortedNamespaces,
397+
func(i, j int) bool {
398+
return reverseSortedNamespaces[i] > reverseSortedNamespaces[j]
408399
},
409400
)
410401

411402
// Only report the busiest namespaces.
412-
if len(sortedNamespaces) > changeEventsTableMaxSize {
413-
sortedNamespaces = sortedNamespaces[:changeEventsTableMaxSize]
403+
if len(reverseSortedNamespaces) > changeEventsTableMaxSize {
404+
reverseSortedNamespaces = reverseSortedNamespaces[:changeEventsTableMaxSize]
414405
}
415406

416407
table := tablewriter.NewWriter(builder)
417408
table.SetHeader([]string{"Namespace", "Insert", "Update", "Replace", "Delete", "Total"})
418409

419-
for _, ns := range sortedNamespaces {
410+
for _, ns := range reverseSortedNamespaces {
420411
curNsStats := nsStats[ns]
421412

422413
table.Append(

0 commit comments

Comments
 (0)