diff options
author | n-peugnet <n.peugnet@free.fr> | 2021-09-06 16:57:47 +0200 |
---|---|---|
committer | n-peugnet <n.peugnet@free.fr> | 2021-09-06 17:26:30 +0200 |
commit | e2d64a027a72f7db99d98ab9652f3e509b86d344 (patch) | |
tree | f3d23663568bdf52cd4737e31630e4766910f6be /sketch.go | |
parent | b31f22ff61b69a0cb3e0a9d7955133b5304f4ff7 (diff) | |
download | dna-backup-e2d64a027a72f7db99d98ab9652f3e509b86d344.tar.gz dna-backup-e2d64a027a72f7db99d98ab9652f3e509b86d344.zip |
generate new Polynomial only once
Diffstat (limited to 'sketch.go')
-rw-r--r-- | sketch.go | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -22,7 +22,7 @@ const fBytes = 8 // SketchChunk produces a sketch for a chunk based on wSize: the window size, // sfCount: the number of super-features, and fCount: the number of feature // per super-feature -func SketchChunk(chunk Chunk, chunkSize int, wSize int, sfCount int, fCount int) (Sketch, error) { +func SketchChunk(chunk Chunk, pol rabinkarp64.Pol, chunkSize int, wSize int, sfCount int, fCount int) (Sketch, error) { var wg sync.WaitGroup var fSize = FeatureSize(chunkSize, sfCount, fCount) superfeatures := make([]uint64, 0, sfCount) @@ -37,9 +37,9 @@ func SketchChunk(chunk Chunk, chunkSize int, wSize int, sfCount int, fCount int) } features = append(features, 0) wg.Add(1) - go calcFeature(&wg, &fBuff, wSize, fSize, &features[f]) + go calcFeature(&wg, pol, &fBuff, wSize, fSize, &features[f]) } - hasher := rabinkarp64.New() + hasher := rabinkarp64.NewFromPol(pol) wg.Wait() for sf := 0; sf < len(features)/fCount; sf++ { for i := 0; i < fCount; i++ { @@ -52,9 +52,9 @@ func SketchChunk(chunk Chunk, chunkSize int, wSize int, sfCount int, fCount int) return superfeatures, nil } -func calcFeature(wg *sync.WaitGroup, r ReadByteReader, wSize int, fSize int, result *uint64) { +func calcFeature(wg *sync.WaitGroup, p rabinkarp64.Pol, r ReadByteReader, wSize int, fSize int, result *uint64) { defer wg.Done() - hasher := rabinkarp64.New() + hasher := rabinkarp64.NewFromPol(p) n, err := io.CopyN(hasher, r, int64(wSize)) if err != nil { log.Println(n, err) |