From 3e590d303da096ed2f7a451c08f74f5a99511844 Mon Sep 17 00:00:00 2001 From: chrislu Date: Tue, 27 Dec 2022 15:44:56 -0800 Subject: [PATCH] add SeparateGarbageChunks --- weed/filer/filechunks.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/weed/filer/filechunks.go b/weed/filer/filechunks.go index 2a20a5992..d1007b6e5 100644 --- a/weed/filer/filechunks.go +++ b/weed/filer/filechunks.go @@ -66,6 +66,12 @@ func CompactFileChunks(lookupFileIdFn wdclient.LookupFileIdFunctionType, chunks visibles, _ := NonOverlappingVisibleIntervals(lookupFileIdFn, chunks, 0, math.MaxInt64) + compacted, garbage = SeparateGarbageChunks(visibles, chunks) + + return +} + +func SeparateGarbageChunks(visibles []VisibleInterval, chunks []*filer_pb.FileChunk) (compacted []*filer_pb.FileChunk, garbage []*filer_pb.FileChunk) { fileIds := make(map[string]bool) for _, interval := range visibles { fileIds[interval.fileId] = true @@ -77,8 +83,7 @@ func CompactFileChunks(lookupFileIdFn wdclient.LookupFileIdFunctionType, chunks garbage = append(garbage, chunk) } } - - return + return compacted, garbage } func MinusChunks(lookupFileIdFn wdclient.LookupFileIdFunctionType, as, bs []*filer_pb.FileChunk) (delta []*filer_pb.FileChunk, err error) {