ZsyncMake { static int strongChecksumLength(long fileLength, int blocksize, int sequenceMatches) { final double d = (Math.log(fileLength) + Math.log(1 + fileLength / blocksize)) / Math.log(2) + 20; final int l1 = (int) Math.ceil(d / sequenceMatches / 8); final int l2 = (int) ((Math.log(1 + fileLength / blocksize) / Math.log(2) + 20 + 7.9) / 8); return Math.min(16, Math.max(l1, l2)); } ZsyncMake(); Path make(Path inputFile); Result writeToStream(Path inputFile, OutputStream outputStream); Result writeToStream(Path inputFile, OutputStream outputStream, Options options); FileResult writeToFile(Path inputFile); FileResult writeToFile(Path inputFile, Path outputFile); FileResult writeToFile(Path inputFile, Options options); FileResult writeToFile(Path inputFile, Path outputFile, Options options); Result writeToChannel(Path inputFile, WritableByteChannel out, Options options); static void main(String[] args); static String ZSYNC_VERSION; }
@Test public void testStrongChecksumLength() { assertEquals(3, ZsyncMake.strongChecksumLength(1024, 2048, 2)); assertEquals(5, ZsyncMake.strongChecksumLength(100 * 1024 * 1024, 4096, 2)); assertEquals(8, ZsyncMake.strongChecksumLength(100 * 1024 * 1024, 4096, 1)); assertEquals(16, ZsyncMake.strongChecksumLength(Long.MAX_VALUE, 4096, 1)); assertEquals(5, ZsyncMake.strongChecksumLength(57323443l, 2048, 2)); }