From 920dbcad30333ea91e34c8c5da07bb6f499c4925 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Thu, 11 Apr 2024 12:16:24 +0200 Subject: file chunker: remove average chunk size from interface ... as the typical chunk size is mainly determined by the masks used internally. So, as long as we hard code them, we should be honest to ourselves and accept that the chunking parameters are hard-coded as well. --- src/buildtool/storage/file_chunker.hpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/buildtool/storage/file_chunker.hpp b/src/buildtool/storage/file_chunker.hpp index c4611c48..f2aea001 100644 --- a/src/buildtool/storage/file_chunker.hpp +++ b/src/buildtool/storage/file_chunker.hpp @@ -32,7 +32,7 @@ /// A read buffer is used to progressively process the file content instead of /// reading the entire file content in memory. class FileChunker { - static constexpr std::uint32_t kDefaultChunkSize{1024 * 8}; // 8 KB + static constexpr std::uint32_t kAverageChunkSize{1024 * 8}; // 8 KB static constexpr std::uint32_t kDefaultSeed{0}; public: @@ -40,20 +40,19 @@ class FileChunker { /// @param path The path to the file to be splitted. /// @param average_chunk_size Targeted average chunk size in bytes /// (default: 8 KB). - explicit FileChunker(std::filesystem::path const& path, - std::uint32_t average_chunk_size = kDefaultChunkSize) + explicit FileChunker(std::filesystem::path const& path) // According to section 4.1 of the paper // https://ieeexplore.ieee.org/document/9055082, maximum and minimum // chunk sizes are configured to the 8x and the 1/4x of the average // chunk size. - : min_chunk_size_(average_chunk_size >> 2U), - average_chunk_size_(average_chunk_size), - max_chunk_size_(average_chunk_size << 3U), + : min_chunk_size_(kAverageChunkSize >> 2U), + average_chunk_size_(kAverageChunkSize), + max_chunk_size_(kAverageChunkSize << 3U), stream_{path, std::ios::in | std::ios::binary} { // The buffer size needs to be at least max_chunk_size_ large, otherwise // max_chunk_size_ is not fully exhausted and the buffer size determines // the maximum chunk size. - buffer_.resize(max_chunk_size_ << 4U); + buffer_.resize(max_chunk_size_ << 1U); } FileChunker() noexcept = delete; -- cgit v1.2.3