||Mechiel Lukkien <email@example.com>|
||Thu, 30 Aug 2007 19:39:02 +0200|
||some more small fixes.
rabin \- rabin fingerprinting
rabin := load Rabin Rabin->PATH;
Rcfg, Rfile: import rabin;
init: fn(bufio: Bufio);
open: fn(rcfg: ref Rcfg, b: ref Iobuf, min, max: int): (ref Rfile, string);
mk: fn(prime, width, mod: int): (ref Rcfg, string);
read: fn(r: self ref Rfile): (array of byte, big, string);
implements a data fingerprinting algorithm. A rolling checksum is calculated while reading data. Certain checksum values are taken to be data boundaries and used for splitting the data into chunks.
represents the parameters to the algorithm,
creates a new instance.
should be a prime number.
is the width of the rolling checksum window in bytes. A wider window results in more diverse boundary patterns. A window of 30 bytes should be reasonable for most uses.
effectively sets the mean desired chunk size. The rolling checksum is calculated modulo
All three parameters influence where chunk boundaries will be found.
represents a file to read chunks from.
returns an initialised Rfile or an error string.
are the minimum and maximum size in bytes of chunks that will be returned. Only the last chunk in a file can be smaller than the minimum chunk size. Note that the mean chunk size may be off due to these parameters.
returns subsequent chunks of data and the file offset at which they were found, or an error message. After end of file, the returned chunks are zero bytes long.