diff options
| author | Chris Lu <chris.lu@gmail.com> | 2018-11-18 21:59:53 -0800 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2018-11-18 21:59:53 -0800 |
| commit | ee3fe07acfc48467af83cd4a81535f29e9b626b2 (patch) | |
| tree | 49a23fd1284b7dd9283783b40bfe6cb341fa94b5 | |
| parent | 469863f7f07e2e9396df99e510a13e6fe8685a1f (diff) | |
| download | seaweedfs-ee3fe07acfc48467af83cd4a81535f29e9b626b2.tar.xz seaweedfs-ee3fe07acfc48467af83cd4a81535f29e9b626b2.zip | |
fix sort bug
| -rw-r--r-- | weed/filer2/filechunks.go | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/weed/filer2/filechunks.go b/weed/filer2/filechunks.go index 473aeb54e..538d10afa 100644 --- a/weed/filer2/filechunks.go +++ b/weed/filer2/filechunks.go @@ -96,10 +96,10 @@ func ViewFromChunks(chunks []*filer_pb.FileChunk, offset int64, size int) (views func logPrintf(name string, visibles []*visibleInterval) { /* - log.Printf("%s len %d", name, len(visibles)) - for _, v := range visibles { - log.Printf("%s: => %+v", name, v) - } + log.Printf("%s len %d", name, len(visibles)) + for _, v := range visibles { + log.Printf("%s: => %+v", name, v) + } */ } @@ -151,14 +151,17 @@ func mergeIntoVisibles(visibles, newVisibles []*visibleInterval, chunk *filer_pb } newVisibles = append(newVisibles, newV) - for i := len(newVisibles) - 1; i > 0; i-- { - if newV.start < newVisibles[i-1].start { + logPrintf(" append", newVisibles) + + for i := len(newVisibles) - 1; i >= 0; i-- { + if i > 0 && newV.start < newVisibles[i-1].start { newVisibles[i] = newVisibles[i-1] } else { newVisibles[i] = newV break } } + logPrintf(" sorted", newVisibles) return newVisibles } @@ -175,9 +178,10 @@ func nonOverlappingVisibleIntervals(chunks []*filer_pb.FileChunk) (visibles []*v t := visibles[:0] visibles = newVislbles newVislbles = t - } - logPrintf("visibles", visibles) + logPrintf("add", visibles) + + } return } |
