A high performance Nim implementation of Rabin Karp algorithm. Can be used for content defined variable chunking.
Types
RabinKarpHash[H; C] = object hashValue*: H n: int wordSize: int hasher: CharacterHash[H, C] hashMask: H primeToN: H prime: H
Procs
proc newRabinKarpHash[H, C](myN: int; myWordSize: int): RabinKarpHash[H, C] {...}{.inline.}
-
Creates a new Rabin Karp with a quasi-random[*]_ initial has value of size myWordSize in bits.
Asserts that the bitsize of the required hash value is not smaller than the bitsize of myWordSzie
proc reset[H, C](y: var RabinKarpHash[H, C]) {...}{.inline.}
- Reset the hash values of rolling hash to 0
proc eat[H, C](y: var RabinKarpHash[H, C]; inChar: char) {...}{.inline.}
proc update[H, C](y: var RabinKarpHash[H, C]; outChar, inChar: char) {...}{.inline.}
proc trueHash[H, C](y: RabinKarpHash[H, C]; c: seq[char]): H {...}{.inline.}
- Hash complete sequence of char without the need to update. This is a helper proceedure to test whether the update proceedure below yeilds correct results in unit testing