diff options
-rw-r--r-- | TODO.md | 1 | ||||
-rw-r--r-- | repo.go | 1 | ||||
-rw-r--r-- | repo_test.go | 24 |
3 files changed, 14 insertions, 12 deletions
@@ -2,6 +2,7 @@ priority 1 ---------- - join non-deduplicated chunks - choose when and how to +- delta encode chunks - read from repo priority 2 @@ -242,6 +242,7 @@ func findSimilarChunk(chunk Chunk, sketches SketchMap) (*ChunkId, bool) { for _, id := range chunkIds { count := similarChunks[*id] count += 1 + log.Printf("Found %d %d time(s)", id, count) if count > max { similarChunk = id } diff --git a/repo_test.go b/repo_test.go index 3a4af68..cbb54df 100644 --- a/repo_test.go +++ b/repo_test.go @@ -187,22 +187,22 @@ func TestBsdiff(t *testing.T) { go concatFiles(files, writer) fingerprints, sketches := hashChunks(oldChunks) recipe := repo.matchStream(reader, fingerprints) - buff := new(bytes.Buffer) - r2 := recipe[2].Reader() - r0 := recipe[0].Reader() - bsdiff.Reader(r2, r0, buff) - log.Println("Diff size:", buff.Len()) - if buff.Len() < 500 { - t.Errorf("Bsdiff of chunk is too small: %d", buff.Len()) - } - if buff.Len() >= chunkSize { - t.Errorf("Bsdiff of chunk is too large: %d", buff.Len()) - } newChunks := extractNewChunks(recipe) log.Println("Checking new chunks:", len(newChunks[0])) for _, chunks := range newChunks { for _, c := range chunks { - log.Println(findSimilarChunk(c, sketches)) + id, exists := findSimilarChunk(c, sketches) + log.Println(id, exists) + if exists { + patch := new(bytes.Buffer) + stored := id.Reader(repo.path) + new := c.Reader() + bsdiff.Reader(stored, new, patch) + log.Println("Patch size:", patch.Len()) + if patch.Len() >= chunkSize/10 { + t.Errorf("Bsdiff of chunk is too large: %d", patch.Len()) + } + } } } } |