Skip to content

Commit

Permalink
Linter
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Tischner committed Aug 28, 2020
1 parent 31ff333 commit 57eacea
Show file tree
Hide file tree
Showing 14 changed files with 185 additions and 183 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/benchmark_build_data.csv
/benchmark_patch_data.csv
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
* @author Daniel Tischner {@literal <[email protected]>}
*/
@SuppressWarnings({ "UseOfSystemOutOrSystemErr", "ClassIndependentOfModule", "ClassOnlyUsedInOneModule" })
@SuppressWarnings({"UseOfSystemOutOrSystemErr", "ClassIndependentOfModule", "ClassOnlyUsedInOneModule"})
enum CompareFiles {
;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* @author Daniel Tischner {@literal <[email protected]>}
*/
@SuppressWarnings({ "UseOfSystemOutOrSystemErr", "ClassIndependentOfModule", "ClassOnlyUsedInOneModule" })
@SuppressWarnings({"UseOfSystemOutOrSystemErr", "ClassIndependentOfModule", "ClassOnlyUsedInOneModule"})
enum LocalChunkCache {
;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public static void main(final String[] args) throws IOException {

List<String> patchDataLines = new ArrayList<>();
patchDataLines.add("patch,name,fsc2mb,fastcdc2mb,fastcdc8kb");
// patchDataLines.add("patch,name,rtpal262kb");
List<String> buildDataLines = new ArrayList<>();
buildDataLines.add("version,name,size");
int i = 1;
Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ChunkMetadata> previousChunks = Collections.synchronizedList(new ArrayList<>());
chunkPath(chunker, previousBuild, chunk -> previousChunks.add(chunk.toChunkMetadata()));
final BuildSummary previousBuildSummary = new BuildSummary(previousChunks);
Expand All @@ -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";
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -277,6 +275,10 @@ BuildSummary getCurrentBuildSummary() {
return currentBuildSummary;
}

long getPatchSize() {
return patchSize;
}

BuildSummary getPreviousBuildSummary() {
return previousBuildSummary;
}
Expand Down Expand Up @@ -320,10 +322,6 @@ private List<ChunkMetadata> getChunksToRemove() {
return Collections.unmodifiableList(chunksToRemove);
}

long getPatchSize() {
return patchSize;
}

private List<ChunkMetadata> getUntouchedChunks() {
return Collections.unmodifiableList(untouchedChunks);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand All @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,6 @@
* @author Daniel Tischner {@literal <[email protected]>}
*/
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}.
Expand All @@ -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();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
Loading

0 comments on commit 57eacea

Please sign in to comment.