From 57eacea1339e6d9c2acbe0924cfacd19816ce8dd Mon Sep 17 00:00:00 2001 From: Daniel Tischner Date: Fri, 28 Aug 2020 11:03:54 +0200 Subject: [PATCH] Linter --- .gitignore | 2 + .../fastcdc4j/examples/CompareFiles.java | 2 +- .../fastcdc4j/examples/LocalChunkCache.java | 2 +- .../fastcdc4j/examples/PatchBenchmark.java | 2 + .../fastcdc4j/examples/PatchSummary.java | 88 ++++++++------- .../fastcdc4j/external/chunking/Chunk.java | 28 ++--- .../external/chunking/ChunkMetadata.java | 28 ++--- .../internal/chunking/FastCdcChunkerCore.java | 16 +-- .../internal/chunking/HashTables.java | 100 +++++++++--------- .../chunking/IterativeStreamChunker.java | 16 +-- .../chunking/NlfiedlerRustChunkerCore.java | 16 +-- .../internal/chunking/SimpleChunk.java | 26 ++--- .../chunking/SimpleChunkMetadata.java | 34 +++--- .../zabuza/fastcdc4j/internal/util/Util.java | 8 +- 14 files changed, 185 insertions(+), 183 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6b859cd --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/benchmark_build_data.csv +/benchmark_patch_data.csv \ No newline at end of file diff --git a/de.zabuza.fastcdc4j.examples/src/de/zabuza/fastcdc4j/examples/CompareFiles.java b/de.zabuza.fastcdc4j.examples/src/de/zabuza/fastcdc4j/examples/CompareFiles.java index bc1ea2a..3a34531 100644 --- a/de.zabuza.fastcdc4j.examples/src/de/zabuza/fastcdc4j/examples/CompareFiles.java +++ b/de.zabuza.fastcdc4j.examples/src/de/zabuza/fastcdc4j/examples/CompareFiles.java @@ -16,7 +16,7 @@ * * @author Daniel Tischner {@literal } */ -@SuppressWarnings({ "UseOfSystemOutOrSystemErr", "ClassIndependentOfModule", "ClassOnlyUsedInOneModule" }) +@SuppressWarnings({"UseOfSystemOutOrSystemErr", "ClassIndependentOfModule", "ClassOnlyUsedInOneModule"}) enum CompareFiles { ; diff --git a/de.zabuza.fastcdc4j.examples/src/de/zabuza/fastcdc4j/examples/LocalChunkCache.java b/de.zabuza.fastcdc4j.examples/src/de/zabuza/fastcdc4j/examples/LocalChunkCache.java index ab36cdf..ac22dc3 100644 --- a/de.zabuza.fastcdc4j.examples/src/de/zabuza/fastcdc4j/examples/LocalChunkCache.java +++ b/de.zabuza.fastcdc4j.examples/src/de/zabuza/fastcdc4j/examples/LocalChunkCache.java @@ -12,7 +12,7 @@ * * @author Daniel Tischner {@literal } */ -@SuppressWarnings({ "UseOfSystemOutOrSystemErr", "ClassIndependentOfModule", "ClassOnlyUsedInOneModule" }) +@SuppressWarnings({"UseOfSystemOutOrSystemErr", "ClassIndependentOfModule", "ClassOnlyUsedInOneModule"}) enum LocalChunkCache { ; diff --git a/de.zabuza.fastcdc4j.examples/src/de/zabuza/fastcdc4j/examples/PatchBenchmark.java b/de.zabuza.fastcdc4j.examples/src/de/zabuza/fastcdc4j/examples/PatchBenchmark.java index 29f5cbc..8ce893c 100644 --- a/de.zabuza.fastcdc4j.examples/src/de/zabuza/fastcdc4j/examples/PatchBenchmark.java +++ b/de.zabuza.fastcdc4j.examples/src/de/zabuza/fastcdc4j/examples/PatchBenchmark.java @@ -49,6 +49,7 @@ public static void main(final String[] args) throws IOException { List patchDataLines = new ArrayList<>(); patchDataLines.add("patch,name,fsc2mb,fastcdc2mb,fastcdc8kb"); + // patchDataLines.add("patch,name,rtpal262kb"); List buildDataLines = new ArrayList<>(); buildDataLines.add("version,name,size"); int i = 1; @@ -69,6 +70,7 @@ public static void main(final String[] args) throws IOException { descriptionToChunker.put("fastcdc8kb", new ChunkerBuilder().fastCdc() .setExpectedChunkSize(8 * 1024) .build()); + // descriptionToChunker.put("rtpal262kb", new RtpalChunker()); System.out.printf("Summary for patching from previous (%s) to current (%s):%n", comparison.getKey(), comparison.getValue()); diff --git a/de.zabuza.fastcdc4j.examples/src/de/zabuza/fastcdc4j/examples/PatchSummary.java b/de.zabuza.fastcdc4j.examples/src/de/zabuza/fastcdc4j/examples/PatchSummary.java index cdb881a..9c9314e 100644 --- a/de.zabuza.fastcdc4j.examples/src/de/zabuza/fastcdc4j/examples/PatchSummary.java +++ b/de.zabuza.fastcdc4j.examples/src/de/zabuza/fastcdc4j/examples/PatchSummary.java @@ -95,16 +95,14 @@ public static void main(final String[] args) { // .setMaskGenerationSeed(4) // .build()); - System.out.printf("Summary for patching from previous (%s) to current (%s):%n", previousBuild, - currentBuild); + System.out.printf("Summary for patching from previous (%s) to current (%s):%n", previousBuild, currentBuild); System.out.println(); descriptionToChunker.forEach( (description, chunker) -> PatchSummary.executePatchSummary(description, chunker, previousBuild, - currentBuild)); + currentBuild)); } - static PatchSummary computePatchSummary(final Chunker chunker, final Path previousBuild, - final Path currentBuild) { + static PatchSummary computePatchSummary(final Chunker chunker, final Path previousBuild, final Path currentBuild) { final List previousChunks = Collections.synchronizedList(new ArrayList<>()); chunkPath(chunker, previousBuild, chunk -> previousChunks.add(chunk.toChunkMetadata())); final BuildSummary previousBuildSummary = new BuildSummary(previousChunks); @@ -116,6 +114,42 @@ static PatchSummary computePatchSummary(final Chunker chunker, final Path previo return new PatchSummary(previousBuildSummary, currentBuildSummary); } + static void executePatchSummary(final String description, final Chunker chunker, final Path previousBuild, + final Path currentBuild) { + final PatchSummary summary = computePatchSummary(chunker, previousBuild, currentBuild); + System.out.println("==== " + description); + System.out.printf("%-25s %12s total size, %12d total chunks, %12s unique size, %12d unique chunks%n", + "Build summary previous:", bytesToReadable(summary.getPreviousBuildSummary() + .getTotalSize()), summary.getPreviousBuildSummary() + .getTotalChunksCount(), bytesToReadable(summary.getPreviousBuildSummary() + .getTotalUniqueSize()), summary.getPreviousBuildSummary() + .getUniqueChunksCount()); + System.out.printf("%-25s %12s total size, %12d total chunks, %12s unique size, %12d unique chunks%n", + "Build summary current:", bytesToReadable(summary.getCurrentBuildSummary() + .getTotalSize()), summary.getCurrentBuildSummary() + .getTotalChunksCount(), bytesToReadable(summary.getCurrentBuildSummary() + .getTotalUniqueSize()), summary.getCurrentBuildSummary() + .getUniqueChunksCount()); + System.out.printf("%-25s %12s average chunk size, %12.2f%% deduplication ratio%n", "Build metrics previous:", + bytesToReadable(summary.getPreviousBuildSummary() + .getAverageChunkSize()), summary.getPreviousBuildSummary() + .getDeduplicationRatio()); + System.out.printf("%-25s %12s average chunk size, %12.2f%% deduplication ratio%n", "Build metrics current:", + bytesToReadable(summary.getCurrentBuildSummary() + .getAverageChunkSize()), summary.getCurrentBuildSummary() + .getDeduplicationRatio()); + System.out.printf("%-25s %12s%n", "Patch size:", bytesToReadable(summary.getPatchSize())); + System.out.printf("%-25s %12d%n", "Chunks to add:", summary.getChunksToAdd() + .size()); + System.out.printf("%-25s %12d%n", "Chunks to remove:", summary.getChunksToRemove() + .size()); + System.out.printf("%-25s %12d%n", "Chunks to move:", summary.getChunksToMove() + .size()); + System.out.printf("%-25s %12d%n", "Untouched chunks:", summary.getUntouchedChunks() + .size()); + System.out.println(); + } + private static String bytesToReadable(long bytes) { if (bytes < 1_000) { return bytes + " B"; @@ -193,42 +227,6 @@ private static void chunkPath(final Chunker chunker, final Path path, final Cons } } - static void executePatchSummary(final String description, final Chunker chunker, final Path previousBuild, - final Path currentBuild) { - final PatchSummary summary = computePatchSummary(chunker, previousBuild, currentBuild); - System.out.println("==== " + description); - System.out.printf("%-25s %12s total size, %12d total chunks, %12s unique size, %12d unique chunks%n", - "Build summary previous:", bytesToReadable(summary.getPreviousBuildSummary() - .getTotalSize()), summary.getPreviousBuildSummary() - .getTotalChunksCount(), bytesToReadable(summary.getPreviousBuildSummary() - .getTotalUniqueSize()), summary.getPreviousBuildSummary() - .getUniqueChunksCount()); - System.out.printf("%-25s %12s total size, %12d total chunks, %12s unique size, %12d unique chunks%n", - "Build summary current:", bytesToReadable(summary.getCurrentBuildSummary() - .getTotalSize()), summary.getCurrentBuildSummary() - .getTotalChunksCount(), bytesToReadable(summary.getCurrentBuildSummary() - .getTotalUniqueSize()), summary.getCurrentBuildSummary() - .getUniqueChunksCount()); - System.out.printf("%-25s %12s average chunk size, %12.2f%% deduplication ratio%n", "Build metrics previous:", - bytesToReadable(summary.getPreviousBuildSummary() - .getAverageChunkSize()), summary.getPreviousBuildSummary() - .getDeduplicationRatio()); - System.out.printf("%-25s %12s average chunk size, %12.2f%% deduplication ratio%n", "Build metrics current:", - bytesToReadable(summary.getCurrentBuildSummary() - .getAverageChunkSize()), summary.getCurrentBuildSummary() - .getDeduplicationRatio()); - System.out.printf("%-25s %12s%n", "Patch size:", bytesToReadable(summary.getPatchSize())); - System.out.printf("%-25s %12d%n", "Chunks to add:", summary.getChunksToAdd() - .size()); - System.out.printf("%-25s %12d%n", "Chunks to remove:", summary.getChunksToRemove() - .size()); - System.out.printf("%-25s %12d%n", "Chunks to move:", summary.getChunksToMove() - .size()); - System.out.printf("%-25s %12d%n", "Untouched chunks:", summary.getUntouchedChunks() - .size()); - System.out.println(); - } - private static String secondsToReadable(long seconds) { StringBuilder sb = new StringBuilder(); boolean entered = false; @@ -277,6 +275,10 @@ BuildSummary getCurrentBuildSummary() { return currentBuildSummary; } + long getPatchSize() { + return patchSize; + } + BuildSummary getPreviousBuildSummary() { return previousBuildSummary; } @@ -320,10 +322,6 @@ private List getChunksToRemove() { return Collections.unmodifiableList(chunksToRemove); } - long getPatchSize() { - return patchSize; - } - private List getUntouchedChunks() { return Collections.unmodifiableList(untouchedChunks); } diff --git a/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/external/chunking/Chunk.java b/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/external/chunking/Chunk.java index c9e8390..d887d09 100644 --- a/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/external/chunking/Chunk.java +++ b/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/external/chunking/Chunk.java @@ -18,20 +18,6 @@ public interface Chunk { */ byte[] getData(); - /** - * Gets the offset of this chunk, with respect to its source data stream. - * - * @return The offset - */ - long getOffset(); - - /** - * The length of this chunk, i.e. the amount of contained data. - * - * @return Gets the length - */ - int getLength(); - /** * A binary hash representation of the contained data. Using the algorithm specified during construction by the * {@link Chunker}. @@ -48,6 +34,20 @@ public interface Chunk { */ String getHexHash(); + /** + * The length of this chunk, i.e. the amount of contained data. + * + * @return Gets the length + */ + int getLength(); + + /** + * Gets the offset of this chunk, with respect to its source data stream. + * + * @return The offset + */ + long getOffset(); + /** * Converts this chunk to its corresponding metadata. * diff --git a/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/external/chunking/ChunkMetadata.java b/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/external/chunking/ChunkMetadata.java index bc15336..4171f11 100644 --- a/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/external/chunking/ChunkMetadata.java +++ b/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/external/chunking/ChunkMetadata.java @@ -8,20 +8,6 @@ * @author Daniel Tischner {@literal } */ public interface ChunkMetadata { - /** - * Gets the offset of this chunk, with respect to its source data stream. - * - * @return The offset - */ - long getOffset(); - - /** - * The length of this chunk, i.e. the amount of contained data. - * - * @return Gets the length - */ - int getLength(); - /** * A binary hash representation of the contained data. Using the algorithm specified during construction by the * {@link Chunker}. @@ -37,4 +23,18 @@ public interface ChunkMetadata { * @return A hexadecimal hash representation */ String getHexHash(); + + /** + * The length of this chunk, i.e. the amount of contained data. + * + * @return Gets the length + */ + int getLength(); + + /** + * Gets the offset of this chunk, with respect to its source data stream. + * + * @return The offset + */ + long getOffset(); } diff --git a/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/internal/chunking/FastCdcChunkerCore.java b/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/internal/chunking/FastCdcChunkerCore.java index f40cb23..ecc849f 100644 --- a/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/internal/chunking/FastCdcChunkerCore.java +++ b/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/internal/chunking/FastCdcChunkerCore.java @@ -18,14 +18,6 @@ public final class FastCdcChunkerCore implements IterativeStreamChunkerCore { * The expected average size for a single chunk, in bytes. */ private final int expectedSize; - /** - * The minimal size for a single chunk, in bytes. - */ - private final int minSize; - /** - * The maximal size for a single chunk, in bytes. - */ - private final int maxSize; /** * The hash table, also known as {@code gear} used as noise to improve the splitting behavior for relatively similar * content. @@ -39,6 +31,14 @@ public final class FastCdcChunkerCore implements IterativeStreamChunkerCore { * Mask for the fingerprint that is used for smaller windows, to decrease the likelihood of a split. */ private final long maskSmall; + /** + * The maximal size for a single chunk, in bytes. + */ + private final int maxSize; + /** + * The minimal size for a single chunk, in bytes. + */ + private final int minSize; /** * Creates a new core. diff --git a/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/internal/chunking/HashTables.java b/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/internal/chunking/HashTables.java index be011fa..0e8855d 100644 --- a/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/internal/chunking/HashTables.java +++ b/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/internal/chunking/HashTables.java @@ -8,12 +8,54 @@ */ public enum HashTables { ; + /** + * Table used by NlFielder-Rust. + */ + @SuppressWarnings("OverlyLargePrimitiveArrayInitializer") + private static final long[] NLFIEDLER_RUST = + {0x5c95c078L, 0x22408989L, 0x2d48a214L, 0x12842087L, 0x530f8afbL, 0x474536b9L, 0x2963b4f1L, 0x44cb738bL, + 0x4ea7403dL, 0x4d606b6eL, 0x074ec5d3L, 0x3af39d18L, 0x726003caL, 0x37a62a74L, 0x51a2f58eL, + 0x7506358eL, 0x5d4ab128L, 0x4d4ae17bL, 0x41e85924L, 0x470c36f7L, 0x4741cbe1L, 0x01bb7f30L, + 0x617c1de3L, 0x2b0c3a1fL, 0x50c48f73L, 0x21a82d37L, 0x6095ace0L, 0x419167a0L, 0x3caf49b0L, + 0x40cea62dL, 0x66bc1c66L, 0x545e1dadL, 0x2bfa77cdL, 0x6e85da24L, 0x5fb0bdc5L, 0x652cfc29L, + 0x3a0ae1abL, 0x2837e0f3L, 0x6387b70eL, 0x13176012L, 0x4362c2bbL, 0x66d8f4b1L, 0x37fce834L, + 0x2c9cd386L, 0x21144296L, 0x627268a8L, 0x650df537L, 0x2805d579L, 0x3b21ebbdL, 0x7357ed34L, + 0x3f58b583L, 0x7150ddcaL, 0x7362225eL, 0x620a6070L, 0x2c5ef529L, 0x7b522466L, 0x768b78c0L, + 0x4b54e51eL, 0x75fa07e5L, 0x06a35fc6L, 0x30b71024L, 0x1c8626e1L, 0x296ad578L, 0x28d7be2eL, + 0x1490a05aL, 0x7cee43bdL, 0x698b56e3L, 0x09dc0126L, 0x4ed6df6eL, 0x02c1bfc7L, 0x2a59ad53L, + 0x29c0e434L, 0x7d6c5278L, 0x507940a7L, 0x5ef6ba93L, 0x68b6af1eL, 0x46537276L, 0x611bc766L, + 0x155c587dL, 0x301ba847L, 0x2cc9dda7L, 0x0a438e2cL, 0x0a69d514L, 0x744c72d3L, 0x4f326b9bL, + 0x7ef34286L, 0x4a0ef8a7L, 0x6ae06ebeL, 0x669c5372L, 0x12402dcbL, 0x5feae99dL, 0x76c7f4a7L, + 0x6abdb79cL, 0x0dfaa038L, 0x20e2282cL, 0x730ed48bL, 0x069dac2fL, 0x168ecf3eL, 0x2610e61fL, + 0x2c512c8eL, 0x15fb8c06L, 0x5e62bc76L, 0x69555135L, 0x0adb864cL, 0x4268f914L, 0x349ab3aaL, + 0x20edfdb2L, 0x51727981L, 0x37b4b3d8L, 0x5dd17522L, 0x6b2cbfe4L, 0x5c47cf9fL, 0x30fa1ccdL, + 0x23dedb56L, 0x13d1f50aL, 0x64eddee7L, 0x0820b0f7L, 0x46e07308L, 0x1e2d1dfdL, 0x17b06c32L, + 0x250036d8L, 0x284dbf34L, 0x68292ee0L, 0x362ec87cL, 0x087cb1ebL, 0x76b46720L, 0x104130dbL, + 0x71966387L, 0x482dc43fL, 0x2388ef25L, 0x524144e1L, 0x44bd834eL, 0x448e7da3L, 0x3fa6eaf9L, + 0x3cda215cL, 0x3a500cf3L, 0x395cb432L, 0x5195129fL, 0x43945f87L, 0x51862ca4L, 0x56ea8ff1L, + 0x201034dcL, 0x4d328ff5L, 0x7d73a909L, 0x6234d379L, 0x64cfbf9cL, 0x36f6589aL, 0x0a2ce98aL, + 0x5fe4d971L, 0x03bc15c5L, 0x44021d33L, 0x16c1932bL, 0x37503614L, 0x1acaf69dL, 0x3f03b779L, + 0x49e61a03L, 0x1f52d7eaL, 0x1c6ddd5cL, 0x062218ceL, 0x07e7a11aL, 0x1905757aL, 0x7ce00a53L, + 0x49f44f29L, 0x4bcc70b5L, 0x39feea55L, 0x5242cee8L, 0x3ce56b85L, 0x00b81672L, 0x46beecccL, + 0x3ca0ad56L, 0x2396cee8L, 0x78547f40L, 0x6b08089bL, 0x66a56751L, 0x781e7e46L, 0x1e2cf856L, + 0x3bc13591L, 0x494a4202L, 0x520494d7L, 0x2d87459aL, 0x757555b6L, 0x42284cc1L, 0x1f478507L, + 0x75c95dffL, 0x35ff8dd7L, 0x4e4757edL, 0x2e11f88cL, 0x5e1b5048L, 0x420e6699L, 0x226b0695L, + 0x4d1679b4L, 0x5a22646fL, 0x161d1131L, 0x125c68d9L, 0x1313e32eL, 0x4aa85724L, 0x21dc7ec1L, + 0x4ffa29feL, 0x72968382L, 0x1ca8eef3L, 0x3f3b1c28L, 0x39c2fb6cL, 0x6d76493fL, 0x7a22a62eL, + 0x789b1c2aL, 0x16e0cb53L, 0x7deceeebL, 0x0dc7e1c6L, 0x5c75bf3dL, 0x52218333L, 0x106de4d6L, + 0x7dc64422L, 0x65590ff4L, 0x2c02ec30L, 0x64a9ac67L, 0x59cab2e9L, 0x4a21d2f3L, 0x0f616e57L, + 0x23b54ee8L, 0x02730aaaL, 0x2f3c634dL, 0x7117fc6cL, 0x01ac6f05L, 0x5a9ed20cL, 0x158c4e2aL, + 0x42b699f0L, 0x0c7c14b3L, 0x02bd9641L, 0x15ad56fcL, 0x1c722f60L, 0x7da1af91L, 0x23e0dbcbL, + 0x0e93e12bL, 0x64b2791dL, 0x440d2476L, 0x588ea8ddL, 0x4665a658L, 0x7446c418L, 0x1877a774L, + 0x5626407eL, 0x7f63bd46L, 0x32d2dbd8L, 0x3c790f4aL, 0x772b7239L, 0x6f8b2826L, 0x677ff609L, + 0x0dc82c11L, 0x23ffe354L, 0x2eac53a6L, 0x16139e09L, 0x0afd0dbcL, 0x2a4d4237L, 0x56a368c7L, + 0x234325e4L, 0x2dce9187L, 0x32e8ea7eL}; /** * Table used by RTPal. */ @SuppressWarnings("OverlyLargePrimitiveArrayInitializer") private static final long[] RTPAL = - { 0x5a16b18f2aac863eL, 0x05fad735784f09eaL, 0x355c6a3868fe64afL, 0x57df89c95716c702L, 0x46ea7572135544a6L, + {0x5a16b18f2aac863eL, 0x05fad735784f09eaL, 0x355c6a3868fe64afL, 0x57df89c95716c702L, 0x46ea7572135544a6L, 0x6291d5376cd79d73L, 0x2a6e072b609b0bbfL, 0x110f7f895ec438b7L, 0x2fc580f60659f690L, 0x15ce33c924a8880bL, 0x1f3fabc44c091f5fL, 0x76e7512d0f53c142L, 0x30ff6d65448b44b3L, 0x16db576e7ecfe3c9L, 0x7009bea841de2e20L, 0x0ad460d80f3fe181L, 0x0a1e6fed6ece42dbL, @@ -76,65 +118,23 @@ public enum HashTables { 0x45e90bc2494ad436L, 0x5291bcf62f0b6bdbL, 0x72ea193619f06853L, 0x5a5a2bd77114b311L, 0x5445faa82e02e158L, 0x0065712926726beaL, 0x1bed3b9a62fbf757L, 0x1767b815257b83d4L, 0x000eab4e77327b81L, 0x0fd333301966ff16L, 0x6780eb8339b83286L, 0x7652a5e647799673L, - 0x43c0db665e364315L, 0x6fe4fe01606d405dL, 0x6833dbd876b03920L }; - /** - * Table used by NlFielder-Rust. - */ - @SuppressWarnings("OverlyLargePrimitiveArrayInitializer") - private static final long[] NLFIEDLER_RUST = - { 0x5c95c078L, 0x22408989L, 0x2d48a214L, 0x12842087L, 0x530f8afbL, 0x474536b9L, 0x2963b4f1L, 0x44cb738bL, - 0x4ea7403dL, 0x4d606b6eL, 0x074ec5d3L, 0x3af39d18L, 0x726003caL, 0x37a62a74L, 0x51a2f58eL, - 0x7506358eL, 0x5d4ab128L, 0x4d4ae17bL, 0x41e85924L, 0x470c36f7L, 0x4741cbe1L, 0x01bb7f30L, - 0x617c1de3L, 0x2b0c3a1fL, 0x50c48f73L, 0x21a82d37L, 0x6095ace0L, 0x419167a0L, 0x3caf49b0L, - 0x40cea62dL, 0x66bc1c66L, 0x545e1dadL, 0x2bfa77cdL, 0x6e85da24L, 0x5fb0bdc5L, 0x652cfc29L, - 0x3a0ae1abL, 0x2837e0f3L, 0x6387b70eL, 0x13176012L, 0x4362c2bbL, 0x66d8f4b1L, 0x37fce834L, - 0x2c9cd386L, 0x21144296L, 0x627268a8L, 0x650df537L, 0x2805d579L, 0x3b21ebbdL, 0x7357ed34L, - 0x3f58b583L, 0x7150ddcaL, 0x7362225eL, 0x620a6070L, 0x2c5ef529L, 0x7b522466L, 0x768b78c0L, - 0x4b54e51eL, 0x75fa07e5L, 0x06a35fc6L, 0x30b71024L, 0x1c8626e1L, 0x296ad578L, 0x28d7be2eL, - 0x1490a05aL, 0x7cee43bdL, 0x698b56e3L, 0x09dc0126L, 0x4ed6df6eL, 0x02c1bfc7L, 0x2a59ad53L, - 0x29c0e434L, 0x7d6c5278L, 0x507940a7L, 0x5ef6ba93L, 0x68b6af1eL, 0x46537276L, 0x611bc766L, - 0x155c587dL, 0x301ba847L, 0x2cc9dda7L, 0x0a438e2cL, 0x0a69d514L, 0x744c72d3L, 0x4f326b9bL, - 0x7ef34286L, 0x4a0ef8a7L, 0x6ae06ebeL, 0x669c5372L, 0x12402dcbL, 0x5feae99dL, 0x76c7f4a7L, - 0x6abdb79cL, 0x0dfaa038L, 0x20e2282cL, 0x730ed48bL, 0x069dac2fL, 0x168ecf3eL, 0x2610e61fL, - 0x2c512c8eL, 0x15fb8c06L, 0x5e62bc76L, 0x69555135L, 0x0adb864cL, 0x4268f914L, 0x349ab3aaL, - 0x20edfdb2L, 0x51727981L, 0x37b4b3d8L, 0x5dd17522L, 0x6b2cbfe4L, 0x5c47cf9fL, 0x30fa1ccdL, - 0x23dedb56L, 0x13d1f50aL, 0x64eddee7L, 0x0820b0f7L, 0x46e07308L, 0x1e2d1dfdL, 0x17b06c32L, - 0x250036d8L, 0x284dbf34L, 0x68292ee0L, 0x362ec87cL, 0x087cb1ebL, 0x76b46720L, 0x104130dbL, - 0x71966387L, 0x482dc43fL, 0x2388ef25L, 0x524144e1L, 0x44bd834eL, 0x448e7da3L, 0x3fa6eaf9L, - 0x3cda215cL, 0x3a500cf3L, 0x395cb432L, 0x5195129fL, 0x43945f87L, 0x51862ca4L, 0x56ea8ff1L, - 0x201034dcL, 0x4d328ff5L, 0x7d73a909L, 0x6234d379L, 0x64cfbf9cL, 0x36f6589aL, 0x0a2ce98aL, - 0x5fe4d971L, 0x03bc15c5L, 0x44021d33L, 0x16c1932bL, 0x37503614L, 0x1acaf69dL, 0x3f03b779L, - 0x49e61a03L, 0x1f52d7eaL, 0x1c6ddd5cL, 0x062218ceL, 0x07e7a11aL, 0x1905757aL, 0x7ce00a53L, - 0x49f44f29L, 0x4bcc70b5L, 0x39feea55L, 0x5242cee8L, 0x3ce56b85L, 0x00b81672L, 0x46beecccL, - 0x3ca0ad56L, 0x2396cee8L, 0x78547f40L, 0x6b08089bL, 0x66a56751L, 0x781e7e46L, 0x1e2cf856L, - 0x3bc13591L, 0x494a4202L, 0x520494d7L, 0x2d87459aL, 0x757555b6L, 0x42284cc1L, 0x1f478507L, - 0x75c95dffL, 0x35ff8dd7L, 0x4e4757edL, 0x2e11f88cL, 0x5e1b5048L, 0x420e6699L, 0x226b0695L, - 0x4d1679b4L, 0x5a22646fL, 0x161d1131L, 0x125c68d9L, 0x1313e32eL, 0x4aa85724L, 0x21dc7ec1L, - 0x4ffa29feL, 0x72968382L, 0x1ca8eef3L, 0x3f3b1c28L, 0x39c2fb6cL, 0x6d76493fL, 0x7a22a62eL, - 0x789b1c2aL, 0x16e0cb53L, 0x7deceeebL, 0x0dc7e1c6L, 0x5c75bf3dL, 0x52218333L, 0x106de4d6L, - 0x7dc64422L, 0x65590ff4L, 0x2c02ec30L, 0x64a9ac67L, 0x59cab2e9L, 0x4a21d2f3L, 0x0f616e57L, - 0x23b54ee8L, 0x02730aaaL, 0x2f3c634dL, 0x7117fc6cL, 0x01ac6f05L, 0x5a9ed20cL, 0x158c4e2aL, - 0x42b699f0L, 0x0c7c14b3L, 0x02bd9641L, 0x15ad56fcL, 0x1c722f60L, 0x7da1af91L, 0x23e0dbcbL, - 0x0e93e12bL, 0x64b2791dL, 0x440d2476L, 0x588ea8ddL, 0x4665a658L, 0x7446c418L, 0x1877a774L, - 0x5626407eL, 0x7f63bd46L, 0x32d2dbd8L, 0x3c790f4aL, 0x772b7239L, 0x6f8b2826L, 0x677ff609L, - 0x0dc82c11L, 0x23ffe354L, 0x2eac53a6L, 0x16139e09L, 0x0afd0dbcL, 0x2a4d4237L, 0x56a368c7L, - 0x234325e4L, 0x2dce9187L, 0x32e8ea7eL }; + 0x43c0db665e364315L, 0x6fe4fe01606d405dL, 0x6833dbd876b03920L}; /** - * Gets the table used by RTPal. + * Gets the table used by Nlfiedler-Rust * * @return The table */ - public static long[] getRtpal() { - return HashTables.RTPAL.clone(); + public static long[] getNlfiedlerRust() { + return HashTables.NLFIEDLER_RUST.clone(); } /** - * Gets the table used by Nlfiedler-Rust + * Gets the table used by RTPal. * * @return The table */ - public static long[] getNlfiedlerRust() { - return HashTables.NLFIEDLER_RUST.clone(); + public static long[] getRtpal() { + return HashTables.RTPAL.clone(); } } diff --git a/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/internal/chunking/IterativeStreamChunker.java b/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/internal/chunking/IterativeStreamChunker.java index 3af9738..0128e34 100644 --- a/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/internal/chunking/IterativeStreamChunker.java +++ b/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/internal/chunking/IterativeStreamChunker.java @@ -48,14 +48,6 @@ public Iterable chunk(final InputStream stream, final long size) { * @author Daniel Tischner {@literal } */ private static final class ChunkerIterator implements Iterator { - /** - * The amount of bytes available in the stream that are subject to be chunked. - */ - private final long size; - /** - * The data stream to chunk. - */ - private final InputStream stream; /** * The core to use for chunking. */ @@ -64,6 +56,14 @@ private static final class ChunkerIterator implements Iterator { * The method to use for hashing the data of a chunk. */ private final String hashMethod; + /** + * The amount of bytes available in the stream that are subject to be chunked. + */ + private final long size; + /** + * The data stream to chunk. + */ + private final InputStream stream; /** * The current offset in the data stream, marking the beginning of the next chunk. */ diff --git a/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/internal/chunking/NlfiedlerRustChunkerCore.java b/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/internal/chunking/NlfiedlerRustChunkerCore.java index 56d0b26..d2ff936 100644 --- a/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/internal/chunking/NlfiedlerRustChunkerCore.java +++ b/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/internal/chunking/NlfiedlerRustChunkerCore.java @@ -18,14 +18,6 @@ public final class NlfiedlerRustChunkerCore implements IterativeStreamChunkerCor * The expected average size for a single chunk, in bytes. */ private final int expectedSize; - /** - * The minimal size for a single chunk, in bytes. - */ - private final int minSize; - /** - * The maximal size for a single chunk, in bytes. - */ - private final int maxSize; /** * The hash table, also known as {@code gear} used as noise to improve the splitting behavior for relatively similar * content. @@ -39,6 +31,14 @@ public final class NlfiedlerRustChunkerCore implements IterativeStreamChunkerCor * Mask for the fingerprint that is used for smaller windows, to decrease the likelihood of a split. */ private final long maskSmall; + /** + * The maximal size for a single chunk, in bytes. + */ + private final int maxSize; + /** + * The minimal size for a single chunk, in bytes. + */ + private final int minSize; /** * Creates a new core. diff --git a/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/internal/chunking/SimpleChunk.java b/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/internal/chunking/SimpleChunk.java index 442fd42..a593486 100644 --- a/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/internal/chunking/SimpleChunk.java +++ b/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/internal/chunking/SimpleChunk.java @@ -15,10 +15,6 @@ public final class SimpleChunk implements Chunk { * The data contained in this chunk. */ private final byte[] data; - /** - * The offset of this chunk, with respect to its source data stream. - */ - private final long offset; /** * A binary hash representation of the contained data. Using the algorithm specified during construction by the * {@link de.zabuza.fastcdc4j.external.chunking.Chunker}. @@ -29,6 +25,10 @@ public final class SimpleChunk implements Chunk { * {@link de.zabuza.fastcdc4j.external.chunking.Chunker}. */ private final String hexHash; + /** + * The offset of this chunk, with respect to its source data stream. + */ + private final long offset; /** * Creates a new simple chunk. @@ -56,23 +56,23 @@ public byte[] getData() { } @Override - public long getOffset() { - return offset; + public byte[] getHash() { + //noinspection AssignmentOrReturnOfFieldWithMutableType + return hash; } @Override - public int getLength() { - return data.length; + public String getHexHash() { + return hexHash; } @Override - public byte[] getHash() { - //noinspection AssignmentOrReturnOfFieldWithMutableType - return hash; + public int getLength() { + return data.length; } @Override - public String getHexHash() { - return hexHash; + public long getOffset() { + return offset; } } diff --git a/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/internal/chunking/SimpleChunkMetadata.java b/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/internal/chunking/SimpleChunkMetadata.java index 95f2b1f..3744945 100644 --- a/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/internal/chunking/SimpleChunkMetadata.java +++ b/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/internal/chunking/SimpleChunkMetadata.java @@ -8,14 +8,6 @@ * @author Daniel Tischner {@literal } */ public final class SimpleChunkMetadata implements ChunkMetadata { - /** - * The offset of this chunk, with respect to its source data stream. - */ - private final long offset; - /** - * The length of this chunk, i.e. the amount of contained data. - */ - private final int length; /** * A binary hash representation of the contained data. Using the algorithm specified during construction by the * {@link de.zabuza.fastcdc4j.external.chunking.Chunker}. @@ -26,6 +18,14 @@ public final class SimpleChunkMetadata implements ChunkMetadata { * {@link de.zabuza.fastcdc4j.external.chunking.Chunker}. */ private final String hexHash; + /** + * The length of this chunk, i.e. the amount of contained data. + */ + private final int length; + /** + * The offset of this chunk, with respect to its source data stream. + */ + private final long offset; /** * Creates a new simple chunk. @@ -46,23 +46,23 @@ public SimpleChunkMetadata(final long offset, final int length, final byte[] has } @Override - public long getOffset() { - return offset; + public byte[] getHash() { + //noinspection AssignmentOrReturnOfFieldWithMutableType + return hash; } @Override - public int getLength() { - return length; + public String getHexHash() { + return hexHash; } @Override - public byte[] getHash() { - //noinspection AssignmentOrReturnOfFieldWithMutableType - return hash; + public int getLength() { + return length; } @Override - public String getHexHash() { - return hexHash; + public long getOffset() { + return offset; } } diff --git a/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/internal/util/Util.java b/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/internal/util/Util.java index caa9247..f292633 100644 --- a/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/internal/util/Util.java +++ b/de.zabuza.fastcdc4j/src/de/zabuza/fastcdc4j/internal/util/Util.java @@ -11,15 +11,15 @@ */ public enum Util { ; - /** - * All characters available in the hexadecimal-system, as UTF-8 encoded array. - */ - private static final byte[] HEX_ARRAY = "0123456789ABCDEF".getBytes(StandardCharsets.UTF_8); /** * Small delta to counter floating point issues when rounding down would accidentally round down a full integer to * much. */ private static final double FLOATING_DELTA = 1.0e-12; + /** + * All characters available in the hexadecimal-system, as UTF-8 encoded array. + */ + private static final byte[] HEX_ARRAY = "0123456789ABCDEF".getBytes(StandardCharsets.UTF_8); /** * Creates a hexadecimal representation of the given binary data.