diff --git a/compress/parallel_compress.go b/compress/parallel_compress.go index 3ca2f2119..6988115f7 100644 --- a/compress/parallel_compress.go +++ b/compress/parallel_compress.go @@ -788,7 +788,7 @@ func reducedict(trace bool, logPrefix, segmentFilePath, tmpDir string, datFile * // No error channels for now func processSuperstring(superstringCh chan []byte, dictCollector *etl.Collector, minPatternScore uint64, completion *sync.WaitGroup) { defer completion.Done() - var dictVal [8]byte + dictVal := make([]byte, 8) dictKey := make([]byte, maxPatternLen) var lcp, sa, inv []int32 for superstring := range superstringCh { @@ -799,11 +799,14 @@ func processSuperstring(superstringCh chan []byte, dictCollector *etl.Collector, } //log.Info("Superstring", "len", len(superstring)) //start := time.Now() - sais.Sais(superstring, sa) + if err := sais.Sais(superstring, sa); err != nil { + panic(err) + } //log.Info("Suffix array built", "in", time.Since(start)) // filter out suffixes that start with odd positions n := len(sa) / 2 - filtered := make([]int32, n) + filtered := sa[:n] + //filtered := make([]int32, n) var j int for i := 0; i < len(sa); i++ { if sa[i]&1 == 0 { @@ -937,8 +940,8 @@ func processSuperstring(superstringCh chan []byte, dictCollector *etl.Collector, for s := 0; s < l; s++ { dictKey[s] = superstring[(int(filtered[i])+s)*2+1] } - binary.BigEndian.PutUint64(dictVal[:], score) - if err := dictCollector.Collect(dictKey, dictVal[:]); err != nil { + binary.BigEndian.PutUint64(dictVal, score) + if err := dictCollector.Collect(dictKey, dictVal); err != nil { log.Error("processSuperstring", "collect", err) } prevSkipped = false diff --git a/patricia/patricia.go b/patricia/patricia.go index 60a8c9157..14aa635a6 100644 --- a/patricia/patricia.go +++ b/patricia/patricia.go @@ -574,7 +574,9 @@ func (mf2 *MatchFinder2) FindLongestMatches(data []byte) []Match { } else { mf2.sa = mf2.sa[:n] } - sais.Sais(data, mf2.sa) + if err := sais.Sais(data, mf2.sa); err != nil { + panic(err) + } if cap(mf2.inv) < n { mf2.inv = make([]int32, n) } else {