aboutsummaryrefslogtreecommitdiff
path: root/weed/filer
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2023-09-18 16:06:41 -0700
committerchrislu <chris.lu@gmail.com>2023-09-18 16:06:41 -0700
commit2e5aa06026750c99ea283181974d2ccfe5eb0468 (patch)
tree7360ecafeb9f8c81e46244b5da9b07e2b74f3fff /weed/filer
parent4d414f54a224142f3f4d934f4af3b5dceb6fec6b (diff)
parenta04bd4d26fb355fff6447dd8e508fa54f3c6c180 (diff)
downloadseaweedfs-2e5aa06026750c99ea283181974d2ccfe5eb0468.tar.xz
seaweedfs-2e5aa06026750c99ea283181974d2ccfe5eb0468.zip
Merge branch 'master' of https://github.com/seaweedfs/seaweedfs
Diffstat (limited to 'weed/filer')
-rw-r--r--weed/filer/filechunks2_test.go6
-rw-r--r--weed/filer/filechunks_read.go14
-rw-r--r--weed/filer/redis/universal_redis_store.go4
-rw-r--r--weed/filer/stream.go8
4 files changed, 19 insertions, 13 deletions
diff --git a/weed/filer/filechunks2_test.go b/weed/filer/filechunks2_test.go
index 6966360ad..6728aec0d 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) bool {
+ slices.SortFunc(chunks, func(a, b *filer_pb.FileChunk) int {
if a.Offset == b.Offset {
- return a.ModifiedTsNs < b.ModifiedTsNs
+ return int(a.ModifiedTsNs - b.ModifiedTsNs)
}
- return a.Offset < b.Offset
+ return int(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 8b2d36e12..b8768ed63 100644
--- a/weed/filer/filechunks_read.go
+++ b/weed/filer/filechunks_read.go
@@ -30,14 +30,20 @@ func readResolvedChunks(chunks []*filer_pb.FileChunk, startOffset int64, stopOff
isStart: false,
})
}
- slices.SortFunc(points, func(a, b *Point) bool {
+ slices.SortFunc(points, func(a, b *Point) int {
if a.x != b.x {
- return a.x < b.x
+ return int(a.x - b.x)
}
if a.ts != b.ts {
- return a.ts < b.ts
+ return int(a.ts - b.ts)
}
- return !a.isStart
+ if a.isStart {
+ return -1
+ }
+ if b.isStart {
+ return 1
+ }
+ return 0
})
var prevX int64
diff --git a/weed/filer/redis/universal_redis_store.go b/weed/filer/redis/universal_redis_store.go
index e56a6bf3c..33c0ea342 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) bool {
- return strings.Compare(a, b) < 0
+ slices.SortFunc(members, func(a, b string) int {
+ return strings.Compare(a, b)
})
// limit
diff --git a/weed/filer/stream.go b/weed/filer/stream.go
index 9e3bb5f76..eb8f0f3a1 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) bool {
- return strings.Compare(i.ETag, j.ETag) < 0
+ slices.SortFunc(a, 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
+ slices.SortFunc(b, func(i, j *filer_pb.FileChunk) int {
+ return strings.Compare(i.ETag, j.ETag)
})
for i := 0; i < len(a); i++ {
if a[i].ETag != b[i].ETag {