diff options
Diffstat (limited to 'weed/filer')
| -rw-r--r-- | weed/filer/filechunks2_test.go | 6 | ||||
| -rw-r--r-- | weed/filer/filechunks_read.go | 14 | ||||
| -rw-r--r-- | weed/filer/redis/universal_redis_store.go | 4 | ||||
| -rw-r--r-- | weed/filer/stream.go | 8 |
4 files changed, 13 insertions, 19 deletions
diff --git a/weed/filer/filechunks2_test.go b/weed/filer/filechunks2_test.go index 6728aec0d..6966360ad 100644 --- a/weed/filer/filechunks2_test.go +++ b/weed/filer/filechunks2_test.go @@ -73,11 +73,11 @@ func TestCompactFileChunksRealCase(t *testing.T) { } func printChunks(name string, chunks []*filer_pb.FileChunk) { - slices.SortFunc(chunks, func(a, b *filer_pb.FileChunk) int { + slices.SortFunc(chunks, func(a, b *filer_pb.FileChunk) bool { if a.Offset == b.Offset { - return int(a.ModifiedTsNs - b.ModifiedTsNs) + return a.ModifiedTsNs < b.ModifiedTsNs } - return int(a.Offset - b.Offset) + return a.Offset < b.Offset }) for _, chunk := range chunks { glog.V(0).Infof("%s chunk %s [%10d,%10d)", name, chunk.GetFileIdString(), chunk.Offset, chunk.Offset+int64(chunk.Size)) diff --git a/weed/filer/filechunks_read.go b/weed/filer/filechunks_read.go index b8768ed63..8b2d36e12 100644 --- a/weed/filer/filechunks_read.go +++ b/weed/filer/filechunks_read.go @@ -30,20 +30,14 @@ func readResolvedChunks(chunks []*filer_pb.FileChunk, startOffset int64, stopOff isStart: false, }) } - slices.SortFunc(points, func(a, b *Point) int { + slices.SortFunc(points, func(a, b *Point) bool { if a.x != b.x { - return int(a.x - b.x) + return a.x < b.x } if a.ts != b.ts { - return int(a.ts - b.ts) + return a.ts < b.ts } - if a.isStart { - return -1 - } - if b.isStart { - return 1 - } - return 0 + return !a.isStart }) var prevX int64 diff --git a/weed/filer/redis/universal_redis_store.go b/weed/filer/redis/universal_redis_store.go index 33c0ea342..e56a6bf3c 100644 --- a/weed/filer/redis/universal_redis_store.go +++ b/weed/filer/redis/universal_redis_store.go @@ -164,8 +164,8 @@ func (store *UniversalRedisStore) ListDirectoryEntries(ctx context.Context, dirP } // sort - slices.SortFunc(members, func(a, b string) int { - return strings.Compare(a, b) + slices.SortFunc(members, func(a, b string) bool { + return strings.Compare(a, b) < 0 }) // limit diff --git a/weed/filer/stream.go b/weed/filer/stream.go index eb8f0f3a1..9e3bb5f76 100644 --- a/weed/filer/stream.go +++ b/weed/filer/stream.go @@ -45,11 +45,11 @@ func isSameChunks(a, b []*filer_pb.FileChunk) bool { if len(a) != len(b) { return false } - slices.SortFunc(a, func(i, j *filer_pb.FileChunk) int { - return strings.Compare(i.ETag, j.ETag) + slices.SortFunc(a, func(i, j *filer_pb.FileChunk) bool { + return strings.Compare(i.ETag, j.ETag) < 0 }) - slices.SortFunc(b, func(i, j *filer_pb.FileChunk) int { - return strings.Compare(i.ETag, j.ETag) + slices.SortFunc(b, func(i, j *filer_pb.FileChunk) bool { + return strings.Compare(i.ETag, j.ETag) < 0 }) for i := 0; i < len(a); i++ { if a[i].ETag != b[i].ETag { |
