From ad38e12c15af10a73447196ac0b0f1a5df8bf865 Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Mon, 30 Aug 2021 16:35:09 +0200 Subject: fix: chunkId added multiple times for same superFeature --- repo.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'repo.go') diff --git a/repo.go b/repo.go index 8df6fdf..457dadd 100644 --- a/repo.go +++ b/repo.go @@ -223,12 +223,25 @@ func hashChunks(chunks <-chan StoredChunk) (FingerprintMap, SketchMap) { fingerprints[h] = c.Id() sketch, _ := SketchChunk(c, 32, 3, 4) for _, s := range sketch { - sketches[s] = append(sketches[s], c.Id()) + prev := sketches[s] + if contains(prev, c.Id()) { + continue + } + sketches[s] = append(prev, c.Id()) } } return fingerprints, sketches } +func contains(s []*ChunkId, id *ChunkId) bool { + for _, v := range s { + if v == id { + return true + } + } + return false +} + func findSimilarChunk(chunk Chunk, sketches SketchMap) (*ChunkId, bool) { var similarChunks = make(map[ChunkId]int) var max int -- cgit v1.2.3