Skip to content
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
21 changes: 10 additions & 11 deletions cmd/mo-service/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package main

import (
"bytes"
"cmp"
"compress/gzip"
"context"
"flag"
Expand All @@ -28,7 +29,7 @@ import (
"path"
"runtime"
"runtime/pprof"
"sort"
"slices"
"strings"
"time"
"unsafe"
Expand Down Expand Up @@ -175,9 +176,7 @@ func init() {
allInfos = append(allInfos, infos)
}

sort.Slice(allInfos, func(i, j int) bool {
aInfos := allInfos[i]
bInfos := allInfos[j]
slices.SortFunc(allInfos, func(aInfos, bInfos []positionInfo) int {
aNumMOFrame := 0
for _, info := range aInfos {
if strings.Contains(info.PackagePath, "matrixone") ||
Expand All @@ -193,14 +192,14 @@ func init() {
}
}
if aNumMOFrame != bNumMOFrame {
return aNumMOFrame > bNumMOFrame
return cmp.Compare(bNumMOFrame, aNumMOFrame)
}
a := aInfos[len(aInfos)-1]
b := bInfos[len(bInfos)-1]
if a.FileOnDisk != b.FileOnDisk {
return a.FileOnDisk < b.FileOnDisk
return cmp.Compare(a.FileOnDisk, b.FileOnDisk)
}
return a.Line < b.Line
return cmp.Compare(a.Line, b.Line)
})

for i, infos := range allInfos {
Expand Down Expand Up @@ -253,10 +252,10 @@ func init() {
}
liveBytes[sum] += record.AllocBytes - record.FreeBytes
}
sort.Slice(positions, func(i, j int) bool {
_, sum1 := getStackInfo(positions[i][:])
_, sum2 := getStackInfo(positions[j][:])
return liveBytes[sum1] > liveBytes[sum2]
slices.SortFunc(positions, func(a, b position) int {
_, sum1 := getStackInfo(a[:])
_, sum2 := getStackInfo(b[:])
return cmp.Compare(liveBytes[sum2], liveBytes[sum1])
})

for i, pos := range positions {
Expand Down
12 changes: 9 additions & 3 deletions pkg/backup/tae.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"os"
"path"
runtime2 "runtime"
"sort"
"slices"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -570,8 +570,14 @@ func copyFileAndGetMetaFiles(
if len(metaFiles) == 0 {
return taeFileList, metaFiles, mFiles, nil
}
sort.Slice(metaFiles, func(i, j int) bool {
return metaFiles[i].GetEnd().LT(metaFiles[j].GetEnd())
slices.SortFunc(metaFiles, func(a, b ioutil.TSRangeFile) int {
if a.GetEnd().LT(b.GetEnd()) {
return -1
}
if b.GetEnd().LT(a.GetEnd()) {
return 1
}
return 0
})

return taeFileList, metaFiles, mFiles, nil
Expand Down
7 changes: 4 additions & 3 deletions pkg/backup/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
package backup

import (
"cmp"
"fmt"
"sort"
"slices"
"strings"

"github.com/matrixorigin/matrixone/pkg/container/types"
Expand Down Expand Up @@ -153,8 +154,8 @@ func (m *Metas) orderTypes() []int {
for i := range m.metas {
idx = append(idx, i)
}
sort.Slice(idx, func(i, j int) bool {
return m.metas[idx[i]].Typ < m.metas[idx[j]].Typ
slices.SortFunc(idx, func(a, b int) int {
return cmp.Compare(m.metas[a].Typ, m.metas[b].Typ)
})
return idx
}
Expand Down
7 changes: 4 additions & 3 deletions pkg/clusterservice/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
package clusterservice

import (
"cmp"
"context"
"sort"
"slices"
"sync"
"sync/atomic"
"time"
Expand Down Expand Up @@ -495,8 +496,8 @@ func (c *cluster) refreshWithContext(ctx context.Context) error {
}
}
// sort as the tick, with the bigger one at the front.
sort.Slice(details.TNStores, func(i, j int) bool {
return details.TNStores[i].Tick > details.TNStores[j].Tick
slices.SortFunc(details.TNStores, func(a, b logpb.TNStore) int {
return cmp.Compare(b.Tick, a.Tick)
})
for _, tn := range details.TNStores {
v := newTNService(tn)
Expand Down
7 changes: 4 additions & 3 deletions pkg/fileservice/aws_sdk_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ package fileservice

import (
"bytes"
"cmp"
"context"
"errors"
"fmt"
"io"
"iter"
"math"
gotrace "runtime/trace"
"sort"
"slices"
"strings"
"sync"
"sync/atomic"
Expand Down Expand Up @@ -711,8 +712,8 @@ func (a *AwsSDKv2) WriteMultipartParallel(
return moerr.NewInternalErrorNoCtxf("multipart upload incomplete, expect %d parts got %d", partNum, len(parts))
}

sort.Slice(parts, func(i, j int) bool {
return *parts[i].PartNumber < *parts[j].PartNumber
slices.SortFunc(parts, func(a, b types.CompletedPart) int {
return cmp.Compare(*a.PartNumber, *b.PartNumber)
})

_, err = DoWithRetry("complete multipart upload", func() (*s3.CompleteMultipartUploadOutput, error) {
Expand Down
7 changes: 4 additions & 3 deletions pkg/fileservice/local_etl_fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ package fileservice

import (
"bytes"
"cmp"
"context"
"io"
"iter"
"os"
pathpkg "path"
"path/filepath"
"sort"
"slices"
"strings"
"sync"
"sync/atomic"
Expand Down Expand Up @@ -123,8 +124,8 @@ func (l *LocalETLFS) write(ctx context.Context, vector IOVector) error {
nativePath := l.toNativeFilePath(path.File)

// sort
sort.Slice(vector.Entries, func(i, j int) bool {
return vector.Entries[i].Offset < vector.Entries[j].Offset
slices.SortFunc(vector.Entries, func(a, b IOEntry) int {
return cmp.Compare(a.Offset, b.Offset)
})

// size
Expand Down
7 changes: 4 additions & 3 deletions pkg/fileservice/local_fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package fileservice

import (
"bytes"
"cmp"
"context"
"encoding/binary"
"errors"
Expand All @@ -26,7 +27,7 @@ import (
"os"
pathpkg "path"
"path/filepath"
"sort"
"slices"
"strings"
"sync"
"sync/atomic"
Expand Down Expand Up @@ -368,8 +369,8 @@ func (l *LocalFS) write(ctx context.Context, vector IOVector) (bytesWritten int,
nativePath := l.toNativeFilePath(path.File)

// sort
sort.Slice(vector.Entries, func(i, j int) bool {
return vector.Entries[i].Offset < vector.Entries[j].Offset
slices.SortFunc(vector.Entries, func(a, b IOEntry) int {
return cmp.Compare(a.Offset, b.Offset)
})

// size
Expand Down
7 changes: 4 additions & 3 deletions pkg/fileservice/memory_fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ package fileservice

import (
"bytes"
"cmp"
"context"
"io"
"iter"
pathpkg "path"
"sort"
"slices"
"strings"
"sync"

Expand Down Expand Up @@ -168,8 +169,8 @@ func (m *MemoryFS) write(ctx context.Context, vector IOVector) error {
}
}

sort.Slice(vector.Entries, func(i, j int) bool {
return vector.Entries[i].Offset < vector.Entries[j].Offset
slices.SortFunc(vector.Entries, func(a, b IOEntry) int {
return cmp.Compare(a.Offset, b.Offset)
})

r := newIOEntriesReader(ctx, vector.Entries)
Expand Down
7 changes: 4 additions & 3 deletions pkg/fileservice/qcloud_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package fileservice

import (
"bytes"
"cmp"
"context"
"errors"
"fmt"
Expand All @@ -25,7 +26,7 @@ import (
"net/url"
"os"
gotrace "runtime/trace"
"sort"
"slices"
"strconv"
"sync"
"time"
Expand Down Expand Up @@ -565,8 +566,8 @@ func (a *QCloudSDK) WriteMultipartParallel(
return moerr.NewInternalErrorNoCtxf("multipart upload incomplete, expect %d parts got %d", partNum, len(parts))
}

sort.Slice(parts, func(i, j int) bool {
return parts[i].PartNumber < parts[j].PartNumber
slices.SortFunc(parts, func(a, b cos.Object) int {
return cmp.Compare(a.PartNumber, b.PartNumber)
})

completeOpt := &cos.CompleteMultipartUploadOptions{
Expand Down
7 changes: 4 additions & 3 deletions pkg/fileservice/s3_fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ package fileservice

import (
"bytes"
"cmp"
"context"
"errors"
"io"
"iter"
pathpkg "path"
"runtime"
"sort"
"slices"
"strings"
"sync/atomic"
"time"
Expand Down Expand Up @@ -429,8 +430,8 @@ func (s *S3FS) write(ctx context.Context, vector IOVector) (bytesWritten int, er
}

// sort
sort.Slice(vector.Entries, func(i, j int) bool {
return vector.Entries[i].Offset < vector.Entries[j].Offset
slices.SortFunc(vector.Entries, func(a, b IOEntry) int {
return cmp.Compare(a.Offset, b.Offset)
})

// reader
Expand Down
6 changes: 3 additions & 3 deletions pkg/frontend/compiler_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
package frontend

import (
"cmp"
"context"
"encoding/json"
"errors"
"fmt"
"slices"
"sort"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -729,8 +729,8 @@ func (tcc *TxnCompilerContext) ResolveUdf(name string, args []*plan.Expr) (udf *
return nil, err
}

sort.Slice(matchedList, func(i, j int) bool {
return matchedList[i].Cost < matchedList[j].Cost
slices.SortFunc(matchedList, func(a, b *MatchUdf) int {
return cmp.Compare(a.Cost, b.Cost)
})

minCost := matchedList[0].Cost
Expand Down
6 changes: 3 additions & 3 deletions pkg/frontend/data_branch_privilege.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package frontend
import (
"context"
"fmt"
"sort"
"slices"
"strconv"
"strings"

Expand Down Expand Up @@ -672,7 +672,7 @@ func validateDataBranchDeleteDatabaseTarget(
for id := range tableNames {
tableIDs = append(tableIDs, id)
}
sort.Slice(tableIDs, func(i, j int) bool { return tableIDs[i] < tableIDs[j] })
slices.Sort(tableIDs)
return tableIDs, nil
}

Expand Down Expand Up @@ -731,7 +731,7 @@ func validateActiveBranchChildTableIDs(
for id := range tableNames {
idList = append(idList, id)
}
sort.Slice(idList, func(i, j int) bool { return idList[i] < idList[j] })
slices.Sort(idList)
sysCtx := defines.AttachAccountId(ctx, sysAccountID)

active := make(map[uint64]struct{}, len(tableNames))
Expand Down
Loading
Loading