From 65760565fd8b6d72f7a31bfe8ffda4386fc8d8de Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 3 Jun 2018 13:20:19 -0400 Subject: cow-dedupe: Choose fiemap with fewest extents AND the most files --- go/src/cow-dedupe/dedupe.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/go/src/cow-dedupe/dedupe.go b/go/src/cow-dedupe/dedupe.go index bc543f1..742cd60 100644 --- a/go/src/cow-dedupe/dedupe.go +++ b/go/src/cow-dedupe/dedupe.go @@ -254,14 +254,18 @@ func main() { for _, filename := range filenames { fiemaps = append(fiemaps, filename2fiemap[filename]) } - // Now we choose the fiemap with the fewest extents + // Now we choose the fiemap with the fewest + // extents and the most files minFiemap := fiemaps[0] minFiemapLen := strings.Count(minFiemap, "\n") + minFiemapCnt := len(fiemap2filenames[minFiemap]) for _, fiemap := range fiemaps { fiemapLen := strings.Count(fiemap, "\n") - if fiemapLen < minFiemapLen { + fiemapCnt := len(fiemap2filenames[fiemap]) + if fiemapLen < minFiemapLen || (fiemapLen == minFiemapLen && fiemapCnt > minFiemapCnt) { minFiemap = fiemap minFiemapLen = fiemapLen + minFiemapCnt = fiemapCnt } } // Set srcFile and dupFiles based on that -- cgit v1.2.3-2-g168b