LoLBench / arrow_2 /solution /solution.patch
lolbench26's picture
Publish LoLBench Harbor tasks from artifact branch
d0faac4 verified
Raw History Blame Contribute Delete
104 kB
diff --git a/.gitattributes b/.gitattributes
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,4 +1,5 @@
cpp/src/arrow/util/bpacking_*_generated.h linguist-generated=true
+cpp/src/parquet/chunker_*_generated.h linguist-generated=true
cpp/src/generated/*.cpp linguist-generated=true
cpp/src/generated/*.h linguist-generated=true
go/**/*.s linguist-generated=true
diff --git a/cpp/src/parquet/CMakeLists.txt b/cpp/src/parquet/CMakeLists.txt
--- a/cpp/src/parquet/CMakeLists.txt
+++ b/cpp/src/parquet/CMakeLists.txt
@@ -160,6 +160,7 @@ set(PARQUET_SRCS
arrow/writer.cc
bloom_filter.cc
bloom_filter_reader.cc
+ chunker_internal.cc
column_reader.cc
column_scanner.cc
column_writer.cc
@@ -399,6 +400,8 @@ add_parquet_test(writer-test
file_serialize_test.cc
stream_writer_test.cc)
+add_parquet_test(chunker-test SOURCES chunker_internal_test.cc)
+
add_parquet_test(arrow-test
SOURCES
arrow/arrow_metadata_test.cc
diff --git a/cpp/src/parquet/chunker_internal.cc b/cpp/src/parquet/chunker_internal.cc
new file mode 100644
--- /dev/null
+++ b/cpp/src/parquet/chunker_internal.cc
@@ -0,0 +1,429 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "parquet/chunker_internal.h"
+
+#include <cstdint>
+#include <iterator>
+#include <string>
+#include <vector>
+
+#include "arrow/array.h"
+#include "arrow/util/bit_util.h"
+#include "arrow/util/logging_internal.h"
+#include "arrow/visit_type_inline.h"
+#include "parquet/chunker_internal_generated.h"
+#include "parquet/exception.h"
+#include "parquet/level_conversion.h"
+
+namespace parquet::internal {
+
+using ::arrow::internal::checked_cast;
+
+static_assert(std::size(kGearhashTable) == kNumGearhashTables,
+ "should update CDC code to reflect number of generated hash tables");
+static_assert(sizeof(kGearhashTable) == kNumGearhashTables * 256 * 8,
+ "each table should have 256 entries of 64 bit values");
+
+namespace {
+
+/// Calculate the mask to use for the rolling hash, the mask is used to determine if a
+/// new chunk should be created based on the rolling hash value. The mask is calculated
+/// based on the min_chunk_size, max_chunk_size and norm_level parameters.
+///
+/// Assuming that the gear hash hash random values with a uniform distribution, then each
+/// bit in the actual value of rolling_hash_ has even probability of being set so a mask
+/// with the top N bits set has a probability of 1/2^N of matching the rolling hash. This
+/// is the judgment criteria for the original gear hash based content-defined chunking.
+/// The main drawback of this approach is the non-uniform distribution of the chunk sizes.
+///
+/// Later on the FastCDC has improved the process by introducing:
+/// - sub-minimum chunk cut-point skipping (not hashing the first `min_chunk_size` bytes)
+/// - chunk size normalization (using two masks)
+///
+/// This implementation uses cut-point skipping because it improves the overall
+/// performance and a more accurate alternative to have less skewed chunk size
+/// distribution. Instead of using two different masks (one with a lower and one with a
+/// higher probability of matching and switching them based on the actual chunk size), we
+/// rather use 8 different gear hash tables and require having 8 consecutive matches while
+/// switching between the used hashtables. This approach is based on central limit theorem
+/// and approximates normal distribution of the chunk sizes.
+//
+// @param min_chunk_size The minimum chunk size (default 256KiB)
+// @param max_chunk_size The maximum chunk size (default 1MiB)
+// @param norm_level Normalization level (default 0)
+// @return The mask used to compare against the rolling hash
+uint64_t CalculateMask(int64_t min_chunk_size, int64_t max_chunk_size, int norm_level) {
+ if (min_chunk_size < 0) {
+ throw ParquetException("min_chunk_size must be non-negative");
+ }
+ if (max_chunk_size <= min_chunk_size) {
+ throw ParquetException("max_chunk_size must be greater than min_chunk_size");
+ }
+
+ // calculate the average size of the chunks
+ int64_t avg_chunk_size = (min_chunk_size + max_chunk_size) / 2;
+ // since we are skipping the first `min_chunk_size` bytes for each chunk, we need to
+ // target a smaller chunk size to reach the average size after skipping the first
+ // `min_chunk_size` bytes; also divide by the number of gearhash tables to have a
+ // a more gaussian-like distribution
+ int64_t target_size = (avg_chunk_size - min_chunk_size) / kNumGearhashTables;
+
+ // assuming that the gear hash has a uniform distribution, we can calculate the mask
+ // by taking the floor(log2(target_size))
+ int mask_bits = std::max(0, ::arrow::bit_util::NumRequiredBits(target_size) - 1);
+
+ // a user defined `norm_level` can be used to adjust the mask size, hence the matching
+ // probability, by increasing the norm_level we increase the probability of matching
+ // the mask, forcing the distribution closer to the average size; norm_level is 0 by
+ // default
+ int effective_bits = mask_bits - norm_level;
+
+ if (effective_bits < 1 || effective_bits > 63) {
+ throw ParquetException(
+ "The number of bits in the CDC mask must be between 1 and 63, got " +
+ std::to_string(effective_bits));
+ } else {
+ // create the mask by setting the top bits
+ return std::numeric_limits<uint64_t>::max() << (64 - effective_bits);
+ }
+}
+
+} // namespace
+
+class ContentDefinedChunker::Impl {
+ public:
+ Impl(const LevelInfo& level_info, int64_t min_chunk_size, int64_t max_chunk_size,
+ int norm_level)
+ : level_info_(level_info),
+ min_chunk_size_(min_chunk_size),
+ max_chunk_size_(max_chunk_size),
+ rolling_hash_mask_(CalculateMask(min_chunk_size, max_chunk_size, norm_level)) {}
+
+ uint64_t GetRollingHashMask() const { return rolling_hash_mask_; }
+
+ void Roll(bool value) {
+ // Update the rolling hash with a boolean value, set has_matched_ to true if the hash
+ // matches the
+ if (++chunk_size_ < min_chunk_size_) {
+ // short-circuit if we haven't reached the minimum chunk size, this speeds up the
+ // chunking process since the gearhash doesn't need to be updated
+ return;
+ }
+ rolling_hash_ = (rolling_hash_ << 1) + kGearhashTable[nth_run_][value];
+ has_matched_ = has_matched_ || ((rolling_hash_ & rolling_hash_mask_) == 0);
+ }
+
+ template <int kByteWidth>
+ void Roll(const uint8_t* value) {
+ // Update the rolling hash with a compile-time known sized value, set has_matched_ to
+ // true if the hash matches the mask.
+ chunk_size_ += kByteWidth;
+ if (chunk_size_ < min_chunk_size_) {
+ // short-circuit if we haven't reached the minimum chunk size, this speeds up the
+ // chunking process since the gearhash doesn't need to be updated
+ return;
+ }
+ for (size_t i = 0; i < kByteWidth; ++i) {
+ rolling_hash_ = (rolling_hash_ << 1) + kGearhashTable[nth_run_][value[i]];
+ has_matched_ = has_matched_ || ((rolling_hash_ & rolling_hash_mask_) == 0);
+ }
+ }
+
+ template <typename T>
+ void Roll(const T* value) {
+ return Roll<sizeof(T)>(reinterpret_cast<const uint8_t*>(value));
+ }
+
+ void Roll(const uint8_t* value, int64_t length) {
+ // Update the rolling hash with a binary-like value, set has_matched_ to true if the
+ // hash matches the mask.
+ chunk_size_ += length;
+ if (chunk_size_ < min_chunk_size_) {
+ // short-circuit if we haven't reached the minimum chunk size, this speeds up the
+ // chunking process since the gearhash doesn't need to be updated
+ return;
+ }
+ for (auto i = 0; i < length; ++i) {
+ rolling_hash_ = (rolling_hash_ << 1) + kGearhashTable[nth_run_][value[i]];
+ has_matched_ = has_matched_ || ((rolling_hash_ & rolling_hash_mask_) == 0);
+ }
+ }
+
+ bool NeedNewChunk() {
+ // decide whether to create a new chunk based on the rolling hash; has_matched_ is
+ // set to true if we encountered a match since the last NeedNewChunk() call
+ if (ARROW_PREDICT_FALSE(has_matched_)) {
+ has_matched_ = false;
+ // in order to have a normal distribution of chunk sizes, we only create a new chunk
+ // if the adjused mask matches the rolling hash 8 times in a row, each run uses a
+ // different gearhash table (gearhash's chunk size has geometric distribution, and
+ // we use central limit theorem to approximate normal distribution, see
+ // section 6.2.1 in paper https://www.cidrdb.org/cidr2023/papers/p43-low.pdf)
+ if (ARROW_PREDICT_FALSE(++nth_run_ >= kNumGearhashTables)) {
+ // note that we choose not to reset the rolling hash state here, nor anywhere else
+ // in the code, in practice this doesn't seem to affect the chunking effectiveness
+ nth_run_ = 0;
+ chunk_size_ = 0;
+ return true;
+ }
+ }
+ if (ARROW_PREDICT_FALSE(chunk_size_ >= max_chunk_size_)) {
+ // we have a hard limit on the maximum chunk size, note that we don't reset the
+ // rolling hash state here, so the next NeedNewChunk() call will continue from the
+ // current state
+ chunk_size_ = 0;
+ return true;
+ }
+ return false;
+ }
+
+ void ValidateChunks(const std::vector<Chunk>& chunks, int64_t num_levels) const {
+ // chunks must be non-empty and monotonic increasing
+ ARROW_DCHECK(!chunks.empty());
+
+ // the first chunk must start at the first level
+ auto first_chunk = chunks.front();
+ ARROW_DCHECK_EQ(first_chunk.level_offset, 0);
+ ARROW_DCHECK_EQ(first_chunk.value_offset, 0);
+
+ // the following chunks must be contiguous, non-overlapping and monotonically
+ // increasing
+ auto sum_levels = first_chunk.levels_to_write;
+ for (size_t i = 1; i < chunks.size(); ++i) {
+ auto chunk = chunks[i];
+ auto prev_chunk = chunks[i - 1];
+ ARROW_DCHECK_GT(chunk.levels_to_write, 0);
+ ARROW_DCHECK_GE(chunk.value_offset, prev_chunk.value_offset);
+ ARROW_DCHECK_EQ(chunk.level_offset,
+ prev_chunk.level_offset + prev_chunk.levels_to_write);
+ sum_levels += chunk.levels_to_write;
+ }
+ ARROW_DCHECK_EQ(sum_levels, num_levels);
+
+ // the last chunk must end at the last level
+ auto last_chunk = chunks.back();
+ ARROW_DCHECK_EQ(last_chunk.level_offset + last_chunk.levels_to_write, num_levels);
+ }
+
+ template <typename RollFunc>
+ std::vector<Chunk> Calculate(const int16_t* def_levels, const int16_t* rep_levels,
+ int64_t num_levels, const RollFunc& RollValue) {
+ // Calculate the chunk boundaries for typed Arrow arrays.
+ //
+ // The chunking state is maintained across the entire column without being reset
+ // between pages and row groups. This enables that the chunking process can be
+ // continued between different WriteArrow calls.
+ //
+ // Below we go over the (def_level, rep_level, value) triplets one by one while
+ // adjusting the column-global rolling hash based on the triplet. Whenever the
+ // rolling hash matches a predefined mask it sets the `has_matched_` flag to true.
+ //
+ // After each triplet NeedNewChunk() is called to evaluate if we need to create
+ // a new chunk. If the rolling hash matches the mask `kNumGearhashTables` times in
+ // row (required for better chunk size distribution) and satisfies the chunk size
+ // requirements, we create a new chunk. See the `NeedNewChunk()` method for more
+ // details.
+ std::vector<Chunk> chunks;
+ int64_t offset;
+ int64_t prev_offset = 0;
+ int64_t prev_value_offset = 0;
+ bool has_def_levels = level_info_.def_level > 0;
+ bool has_rep_levels = level_info_.rep_level > 0;
+
+ if (!has_rep_levels && !has_def_levels) {
+ // fastest path for non-nested non-null data
+ for (offset = 0; offset < num_levels; ++offset) {
+ RollValue(offset);
+ if (NeedNewChunk()) {
+ chunks.push_back({prev_offset, prev_offset, offset - prev_offset});
+ prev_offset = offset;
+ }
+ }
+ // set the previous value offset to add the last chunk
+ prev_value_offset = prev_offset;
+ } else if (!has_rep_levels) {
+ // non-nested data with nulls
+ int16_t def_level;
+ for (int64_t offset = 0; offset < num_levels; ++offset) {
+ def_level = def_levels[offset];
+
+ Roll(&def_level);
+ if (def_level == level_info_.def_level) {
+ RollValue(offset);
+ }
+ if (NeedNewChunk()) {
+ chunks.push_back({prev_offset, prev_offset, offset - prev_offset});
+ prev_offset = offset;
+ }
+ }
+ // set the previous value offset to add the last chunk
+ prev_value_offset = prev_offset;
+ } else {
+ // nested data with nulls
+ int16_t def_level;
+ int16_t rep_level;
+ int64_t value_offset = 0;
+
+ for (offset = 0; offset < num_levels; ++offset) {
+ def_level = def_levels[offset];
+ rep_level = rep_levels[offset];
+
+ Roll(&def_level);
+ Roll(&rep_level);
+ if (def_level == level_info_.def_level) {
+ RollValue(value_offset);
+ }
+
+ if (rep_level == 0 && NeedNewChunk()) {
+ // if we are at a record boundary and need a new chunk, we create a new chunk
+ auto levels_to_write = offset - prev_offset;
+ if (levels_to_write > 0) {
+ chunks.push_back({prev_offset, prev_value_offset, levels_to_write});
+ prev_offset = offset;
+ prev_value_offset = value_offset;
+ }
+ }
+ if (def_level >= level_info_.repeated_ancestor_def_level) {
+ // we only increment the value offset if we have a leaf value
+ ++value_offset;
+ }
+ }
+ }
+
+ // add the last chunk if we have any levels left
+ if (prev_offset < num_levels) {
+ chunks.push_back({prev_offset, prev_value_offset, num_levels - prev_offset});
+ }
+#ifndef NDEBUG
+ ValidateChunks(chunks, num_levels);
+#endif
+
+ return chunks;
+ }
+
+ template <int kByteWidth>
+ std::vector<Chunk> CalculateFixedWidth(const int16_t* def_levels,
+ const int16_t* rep_levels, int64_t num_levels,
+ const ::arrow::Array& values) {
+ const uint8_t* raw_values =
+ values.data()->GetValues<uint8_t>(/*i=*/1, /*absolute_offset=*/0) +
+ values.offset() * kByteWidth;
+ return Calculate(def_levels, rep_levels, num_levels, [&](int64_t i) {
+ return Roll<kByteWidth>(&raw_values[i * kByteWidth]);
+ });
+ }
+
+ template <typename ArrayType>
+ std::vector<Chunk> CalculateBinaryLike(const int16_t* def_levels,
+ const int16_t* rep_levels, int64_t num_levels,
+ const ::arrow::Array& values) {
+ const auto& array = checked_cast<const ArrayType&>(values);
+ return Calculate(def_levels, rep_levels, num_levels, [&](int64_t i) {
+ typename ArrayType::offset_type length;
+ const uint8_t* value = array.GetValue(i, &length);
+ Roll(value, length);
+ });
+ }
+
+ std::vector<Chunk> GetChunks(const int16_t* def_levels, const int16_t* rep_levels,
+ int64_t num_levels, const ::arrow::Array& values) {
+ auto handle_type = [&](auto&& type) -> std::vector<Chunk> {
+ using ArrowType = std::decay_t<decltype(type)>;
+ if constexpr (ArrowType::type_id == ::arrow::Type::NA) {
+ return Calculate(def_levels, rep_levels, num_levels, [](int64_t) {});
+ } else if constexpr (ArrowType::type_id == ::arrow::Type::BOOL) {
+ const auto& array = static_cast<const ::arrow::BooleanArray&>(values);
+ return Calculate(def_levels, rep_levels, num_levels,
+ [&](int64_t i) { Roll(array.Value(i)); });
+ } else if constexpr (ArrowType::type_id == ::arrow::Type::FIXED_SIZE_BINARY) {
+ const auto& array = static_cast<const ::arrow::FixedSizeBinaryArray&>(values);
+ const auto byte_width = array.byte_width();
+ return Calculate(def_levels, rep_levels, num_levels,
+ [&](int64_t i) { Roll(array.GetValue(i), byte_width); });
+ } else if constexpr (ArrowType::type_id == ::arrow::Type::EXTENSION) {
+ const auto& array = static_cast<const ::arrow::ExtensionArray&>(values);
+ return GetChunks(def_levels, rep_levels, num_levels, *array.storage());
+ } else if constexpr (::arrow::is_primitive(ArrowType::type_id)) {
+ using c_type = typename ArrowType::c_type;
+ return CalculateFixedWidth<sizeof(c_type)>(def_levels, rep_levels, num_levels,
+ values);
+ } else if constexpr (::arrow::is_decimal(ArrowType::type_id)) {
+ return CalculateFixedWidth<ArrowType::kByteWidth>(def_levels, rep_levels,
+ num_levels, values);
+ } else if constexpr (::arrow::is_binary_like(ArrowType::type_id)) {
+ return CalculateBinaryLike<::arrow::BinaryArray>(def_levels, rep_levels,
+ num_levels, values);
+ } else if constexpr (::arrow::is_large_binary_like(ArrowType::type_id)) {
+ return CalculateBinaryLike<::arrow::LargeBinaryArray>(def_levels, rep_levels,
+ num_levels, values);
+ } else if constexpr (::arrow::is_dictionary(ArrowType::type_id)) {
+ return GetChunks(def_levels, rep_levels, num_levels,
+ *static_cast<const ::arrow::DictionaryArray&>(values).indices());
+ } else {
+ throw ParquetException("Unsupported Arrow array type " +
+ values.type()->ToString());
+ }
+ };
+ return ::arrow::VisitType(*values.type(), handle_type);
+ }
+
+ private:
+ // Reference to the column's level information
+ const internal::LevelInfo& level_info_;
+ // Minimum chunk size in bytes, the rolling hash will not be updated until this size is
+ // reached for each chunk. Note that all data sent through the hash function is counted
+ // towards the chunk size, including definition and repetition levels.
+ const int64_t min_chunk_size_;
+ const int64_t max_chunk_size_;
+ // The mask to match the rolling hash against to determine if a new chunk should be
+ // created. The mask is calculated based on min/max chunk size and the normalization
+ // level.
+ const uint64_t rolling_hash_mask_;
+
+ // Whether the rolling hash has matched the mask since the last chunk creation. This
+ // flag is set true by the Roll() function when the mask is matched and reset to false
+ // by NeedNewChunk() method.
+ bool has_matched_ = false;
+ // The current run of the rolling hash, used to normalize the chunk size distribution
+ // by requiring multiple consecutive matches to create a new chunk.
+ int8_t nth_run_ = 0;
+ // Current chunk size in bytes, reset to 0 when a new chunk is created.
+ int64_t chunk_size_ = 0;
+ // Rolling hash state, never reset only initialized once for the entire column.
+ uint64_t rolling_hash_ = 0;
+};
+
+ContentDefinedChunker::ContentDefinedChunker(const LevelInfo& level_info,
+ int64_t min_chunk_size,
+ int64_t max_chunk_size, int norm_level)
+ : impl_(new Impl(level_info, min_chunk_size, max_chunk_size, norm_level)) {}
+
+ContentDefinedChunker::~ContentDefinedChunker() = default;
+
+std::vector<Chunk> ContentDefinedChunker::GetChunks(const int16_t* def_levels,
+ const int16_t* rep_levels,
+ int64_t num_levels,
+ const ::arrow::Array& values) {
+ return impl_->GetChunks(def_levels, rep_levels, num_levels, values);
+}
+
+uint64_t ContentDefinedChunker::GetRollingHashMask() const {
+ return impl_->GetRollingHashMask();
+}
+
+} // namespace parquet::internal
diff --git a/cpp/src/parquet/chunker_internal.h b/cpp/src/parquet/chunker_internal.h
new file mode 100644
--- /dev/null
+++ b/cpp/src/parquet/chunker_internal.h
@@ -0,0 +1,144 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <cstdint>
+#include <vector>
+
+#include "arrow/array.h"
+#include "parquet/level_conversion.h"
+
+namespace parquet::internal {
+
+// Represents a chunk of data with level offsets and value offsets due to the
+// record shredding for nested data.
+struct Chunk {
+ // The start offset of this chunk inside the given levels
+ int64_t level_offset;
+ // The start offset of this chunk inside the given values array
+ int64_t value_offset;
+ // The length of the chunk in levels
+ int64_t levels_to_write;
+};
+
+/// CDC (Content-Defined Chunking) is a technique that divides data into variable-sized
+/// chunks based on the content of the data itself, rather than using fixed-size
+/// boundaries.
+///
+/// For example, given this sequence of values in a column:
+///
+/// File1: [1,2,3, 4,5,6, 7,8,9]
+/// chunk1 chunk2 chunk3
+///
+/// Assume there is an inserted value between 3 and 4:
+///
+/// File2: [1,2,3,0, 4,5,6, 7,8,9]
+/// new-chunk chunk2 chunk3
+///
+/// The chunking process will adjust to maintain stable boundaries across data
+/// modifications. Each chunk defines a new parquet data page which is contiguously
+/// written out to the file. Since each page compressed independently, the files' contents
+/// would look like the following with unique page identifiers:
+///
+/// File1: [Page1][Page2][Page3]...
+/// File2: [Page4][Page2][Page3]...
+///
+/// Then the parquet file is being uploaded to a content addressable storage (CAS) system
+/// which splits the bytes stream into content defined blobs. The CAS system will
+/// calculate a unique identifier for each blob, then store the blob in a key-value store.
+/// If the same blob is encountered again, the system can refer to the hash instead of
+/// physically storing the blob again. In the example above, the CAS system would store
+/// Page1, Page2, Page3, and Page4 only once and the required metadata to reassemble the
+/// files.
+/// While the deduplication is performed by the CAS system, the parquet chunker makes it
+/// possible to efficiently deduplicate the data by consistently dividing the data into
+/// chunks.
+///
+/// Implementation details:
+///
+/// Only the parquet writer must be aware of the content defined chunking, the reader
+/// doesn't need to know about it. Each parquet column writer holds a
+/// ContentDefinedChunker instance depending on the writer's properties. The chunker's
+/// state is maintained across the entire column without being reset between pages and row
+/// groups.
+///
+/// The chunker receives the record shredded column data (def_levels, rep_levels, values)
+/// and goes over the (def_level, rep_level, value) triplets one by one while adjusting
+/// the column-global rolling hash based on the triplet. Whenever the rolling hash matches
+/// a predefined mask, the chunker creates a new chunk. The chunker returns a vector of
+/// Chunk objects that represent the boundaries of the chunks.
+/// Note that the boundaries are deterministically calculated exclusively based on the
+/// data itself, so the same data will always produce the same chunks - given the same
+/// chunker configuration.
+///
+/// References:
+/// - FastCDC: a Fast and Efficient Content-Defined Chunking Approach for Data
+/// Deduplication
+/// https://www.usenix.org/system/files/conference/atc16/atc16-paper-xia.pdf
+/// - Git is for Data (chunk size normalization used here is described in section 6.2.1):
+/// https://www.cidrdb.org/cidr2023/papers/p43-low.pdf
+class PARQUET_EXPORT ContentDefinedChunker {
+ public:
+ /// Create a new ContentDefinedChunker instance
+ ///
+ /// @param level_info Information about definition and repetition levels
+ /// @param min_chunk_size Minimum chunk size in bytes
+ /// The rolling hash will not be updated until this size is reached for each chunk.
+ /// Note that all data sent through the hash function is counted towards the chunk
+ /// size, including definition and repetition levels if present.
+ /// @param max_chunk_size Maximum chunk size in bytes
+ /// The chunker creates a new chunk whenever the chunk size exceeds this value. The
+ /// chunk size distribution approximates a normal distribution between min_chunk_size
+ /// and max_chunk_size. Note that the parquet writer has a related `data_pagesize`
+ // property that controls the maximum size of a parquet data page after encoding.
+ /// While setting `data_pagesize` to a smaller value than `max_chunk_size` doesn't
+ /// affect the chunking effectiveness, it results in more small parquet data pages.
+ /// @param norm_level Normalization level to center the chunk size around the average
+ /// size more aggressively, default 0.
+ /// Increasing the normalization level increases the probability of finding a chunk
+ /// boundary, improving the deduplication ratio, but also increases the number of
+ /// small chunks resulting in many small parquet data pages. The default value
+ /// provides a good balance between deduplication ratio and fragmentation.
+ /// Use norm_level=1 or norm_level=2 to reach a higher deduplication ratio at the
+ /// expense of fragmentation.
+ ContentDefinedChunker(const LevelInfo& level_info, int64_t min_chunk_size,
+ int64_t max_chunk_size, int norm_level = 0);
+ ~ContentDefinedChunker();
+
+ /// Get the chunk boundaries for the given column data
+ ///
+ /// @param def_levels Definition levels
+ /// @param rep_levels Repetition levels
+ /// @param num_levels Number of levels
+ /// @param values Column values as an Arrow array
+ /// @return Vector of Chunk objects representing the chunk boundaries
+ std::vector<Chunk> GetChunks(const int16_t* def_levels, const int16_t* rep_levels,
+ int64_t num_levels, const ::arrow::Array& values);
+
+ private:
+ /// @brief Get the rolling hash mask used to determine chunk boundaries, used for
+ /// testing the mask calculation.
+ uint64_t GetRollingHashMask() const;
+
+ class Impl;
+ std::unique_ptr<Impl> impl_;
+
+ friend class TestCDC;
+};
+
+} // namespace parquet::internal
diff --git a/cpp/src/parquet/chunker_internal_codegen.py b/cpp/src/parquet/chunker_internal_codegen.py
new file mode 100644
--- /dev/null
+++ b/cpp/src/parquet/chunker_internal_codegen.py
@@ -0,0 +1,125 @@
+#!/usr/bin/env python
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""
+Produce the given number gearhash tables for rolling hash calculations.
+
+Each table consists of 256 64-bit integer values and by default 8 tables are
+produced. The tables are written to a header file that can be included in the
+C++ code.
+
+The generated numbers are deterministic "random" numbers created by MD5 hashing
+a fixed seed and the table index. This ensures that the tables are the same
+across different runs and platforms. The function of generating the numbers is
+less important as long as they have sufficiently uniform distribution.
+
+Reference implementations:
+- https://github.com/Borelset/destor/blob/master/src/chunking/fascdc_chunking.c
+- https://github.com/nlfiedler/fastcdc-rs/blob/master/examples/table64.rs
+
+Usage:
+ python chunker_internal_codegen.py [ntables]
+
+ ntables: Number of gearhash tables to generate (default 8), the
+ the C++ implementation expects 8 tables so this should not be
+ changed unless the C++ code is also updated.
+
+ The generated header file is written to ./chunker_internal_generated.h
+"""
+
+import hashlib
+import pathlib
+import sys
+from io import StringIO
+
+
+template = """\
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <cstdint>
+
+namespace parquet::internal {{
+
+constexpr int64_t kNumGearhashTables = {ntables};
+
+constexpr uint64_t kGearhashTable[{ntables}][256] = {{
+{content}}};
+
+}} // namespace parquet::internal
+"""
+
+
+def generate_hash(n: int, seed: int):
+ """Produce predictable hash values for a given seed and n using MD5.
+
+ The value can be arbitrary as long as it is deterministic and has a uniform
+ distribution. The MD5 hash is used to produce a 16 character hexadecimal
+ string which is then converted to a 64-bit integer.
+ """
+ value = bytes([seed] * 64 + [n] * 64)
+ hasher = hashlib.md5(value)
+ return hasher.hexdigest()[:16]
+
+
+def generate_hashtable(seed: int, length=256):
+ """Generate and render a single gearhash table."""
+ table = [generate_hash(n, seed=seed) for n in range(length)]
+
+ out = StringIO()
+ out.write(f" {{// seed = {seed}\n")
+ for i in range(0, length, 4):
+ values = [f"0x{value}" for value in table[i : i + 4]]
+ values = ", ".join(values)
+ out.write(f" {values}")
+ if i < length - 4:
+ out.write(",\n")
+ out.write("}")
+
+ return out.getvalue()
+
+
+def generate_header(ntables=8, relative_path="chunker_internal_generated.h"):
+ """Generate a header file with multiple gearhash tables."""
+ path = pathlib.Path(__file__).parent / relative_path
+ tables = [generate_hashtable(seed) for seed in range(ntables)]
+ content = ",\n".join(tables)
+ text = template.format(ntables=ntables, content=content)
+ path.write_text(text)
+
+
+if __name__ == "__main__":
+ ntables = int(sys.argv[1]) if len(sys.argv) > 1 else 8
+ generate_header(ntables)
diff --git a/cpp/src/parquet/chunker_internal_generated.h b/cpp/src/parquet/chunker_internal_generated.h
new file mode 100644
--- /dev/null
+++ b/cpp/src/parquet/chunker_internal_generated.h
@@ -0,0 +1,548 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <cstdint>
+
+namespace parquet::internal {
+
+constexpr int64_t kNumGearhashTables = 8;
+
+constexpr uint64_t kGearhashTable[8][256] = {
+ {// seed = 0
+ 0xf09f35a563783945, 0x0dcc5b3bc5ae410a, 0x63f1ea8d22554270, 0xfbe5ee7bd05a7b61,
+ 0x3f692ed5e9934aba, 0xaab3755952250eb8, 0xdefb168dc2888fa5, 0x501b36f7c77a7d47,
+ 0xd2fff45d1989642d, 0x80217c1c600e30a6, 0xb9469ee2e43df7ac, 0x3654b76a61999706,
+ 0x6ea73dfe5de0c6b6, 0xdfd662e1937a589d, 0x0dbe0cc74b188a68, 0xde45f4e6d73ffc6f,
+ 0xcdf7a7759e70d87e, 0x5d6a951b8d38c310, 0xdc9423c3813fcf2c, 0x25dc2976e167ffce,
+ 0xc2555baa1d031c84, 0x115bc3f2230a3ab6, 0xd4b10260f350bede, 0xdfd3501ab447d723,
+ 0x022e79217edaf167, 0x1635e2255c5a7526, 0xa0a750350cc77102, 0xc027133e05d39f56,
+ 0xd949459779cf0387, 0xb92f1464f5c688c2, 0xd9ac5f3e8b42f2f3, 0xdf02bb6f5ecaac21,
+ 0x8156f988fac7bfa4, 0xe4580f97bede2ec8, 0x44fe7d17a76fca32, 0x885f59bd54c2014c,
+ 0x435e63ec655ffae9, 0x5ebc51930967b1f1, 0x5428c2084ac29e47, 0x9465938fec30e36b,
+ 0xc7cb3de4977772cd, 0x15692d7c201e8c3a, 0x505ee65cdc4b17f4, 0x7d9839a0a7aead6b,
+ 0xeef5f5b6a0105291, 0x76c2fb232ce7f5bf, 0x5c13893c1c3ff3a9, 0x65b6b547d4442f98,
+ 0xb8ad7487c8c96fce, 0x906bcf51c99974f8, 0x2f56e48bb943a48c, 0xbc9ab109f82d3a44,
+ 0xcd5160cdc8c7e735, 0xbe9acb9df3427732, 0x386b91d477d7fade, 0x36be463621dd5af2,
+ 0xcbe6a2faffd627a8, 0x9c8fd528463a2f5a, 0xb9b88c6bb802b184, 0xb414b4e665c597c7,
+ 0xbedb142568209556, 0x5360d81c25429dce, 0x63a69a960a952f37, 0xc900d63899e1b503,
+ 0x1abc63a8b37c7728, 0xa8b3a8b6409080eb, 0x495e391f662959f6, 0xdf1e136f3e12229b,
+ 0x33d5fc526b0dd38d, 0x321221ae2abfac63, 0x7fde18351fda7395, 0xed79fe5c3a6aa4c3,
+ 0x2dd6965a4867d8d4, 0x54813ca20fe8799b, 0x5d59ea6456465c39, 0x0de0c294d1936b81,
+ 0x4aaf0755002c588c, 0x3530a1857ad04c6d, 0xb8a64f4ce184442b, 0xe0def10bceedfa17,
+ 0x46e38d0a443757ec, 0x9795a1c645ee16d7, 0x7e531def245eac8a, 0x683b25c43a0716cf,
+ 0x884583d372da219d, 0x5b06b62c910416e5, 0x54b6902fbebd3dbe, 0x931198d40a761a75,
+ 0xead7d8e830013590, 0x80b4d5dc99bfaced, 0xf98272c8108a1ad2, 0x1adce054289a0ec6,
+ 0x7d53a1143c56b465, 0x497fbe4f00c92b52, 0x525e4cc2e81ebd69, 0xc94478e0d5508ff6,
+ 0xb8a5da83c196d07c, 0x7667a921b65b0603, 0xf236fabbdefe6cd1, 0x53da978d19a92b98,
+ 0xc604f6e97087124d, 0x2cbd27221924b094, 0x65cd1102c985b1d2, 0x08c0755dc1a97eb4,
+ 0x5e0419e921c0fef1, 0x282d2c1196f84a29, 0xe21117fcfc5793f7, 0xcf4e985dc38e6c2e,
+ 0xd521f4f264d55616, 0xde69b04c485f2a10, 0x59410e245305178a, 0xceab1d477c943601,
+ 0xa9805732d71ee5e9, 0x054cd443896974f6, 0xf2b517717a423a3e, 0x09517937fa9fac95,
+ 0x4938233e9ca871e3, 0x9132cbaf56f83ec0, 0x4703421ed1dd027d, 0xfd9933f4e6f1ec4e,
+ 0xf237c7fded2274a8, 0xdf4616efe68cd7b4, 0x5e46de0f39f0a380, 0x3d41e0c6d8e095b0,
+ 0xc5272f8a5bb2df09, 0x68aa78e8301fb964, 0xbf5b5b52c8e32ae0, 0xbf28ed3df74bdcf7,
+ 0xd6198f64c833815a, 0x8cd99d2974267544, 0xd90560ea4465ff2c, 0x571d65ad7ad59261,
+ 0x309453518baa367a, 0xa60538377bc79fb2, 0xace515da1ab4183c, 0xf56d3c8d891d1c5b,
+ 0x5b0d8370b59def49, 0x775866ce7c83c762, 0x3d76085695c8e18a, 0xba064d1a9af1b114,
+ 0xc84ef7cd7b98b521, 0x90b9231681c2bc37, 0x37e2b13e6f585b6b, 0x1d0a34e55e0f369f,
+ 0x86bb8019cf41447c, 0x4b95c6ef55b3f71f, 0x3b6ed1660732b310, 0x617eee603d137f21,
+ 0xf4f6278b464f3bbc, 0xdfb763b720da205a, 0x353478899b871cb7, 0xe45fbbff574cc41e,
+ 0x1a94b60847907d72, 0xb10eef051eff67a5, 0xf0e012ec6a284d40, 0xcc1cd1a11b926d7c,
+ 0xcf9d9c5453e19cad, 0x270febcc0fc0e86b, 0xd6567568778b781e, 0x7323b98965eeb46b,
+ 0xccecd374567086ff, 0xef7b44bfc497a704, 0xebc479c051a9f0a5, 0xc9b7410e3e00a235,
+ 0x1d084f7ecdf83dab, 0xc8a9a97e33ba8ba3, 0x8c75318f5b2350d6, 0xaa3cd5d0c684bdda,
+ 0xa81125fe0901bedf, 0xf7bcd76020edfc93, 0x834ee4c12e75874f, 0xb2bb8a7beb44fa14,
+ 0x32cd26f50a4f4e4d, 0x0fc5817ca55d959a, 0xd6e4ae2e3ae10718, 0x074abdcceb8d6e38,
+ 0xc0cc5f4f9b3a9c43, 0x1115d364363595b2, 0x69861db2eb19f2e8, 0x59b8d804cf92bc67,
+ 0x9bac9785e5e4b863, 0x7fa0e17a41869561, 0x10d3c9633f0c709c, 0x534a03deee6bc44a,
+ 0x73b1f7201257f581, 0x46fd6a11e2e0706b, 0x494abb554946e67a, 0xb5d6da317864dc8e,
+ 0x402ded9238f39687, 0xd8fa37d2cbd6d290, 0xcc818293fcb06791, 0x6482ab344806cd4d,
+ 0x0956e6ee9d8eb60b, 0x01fee622d8465ac8, 0xae7ece370cbd9c35, 0x7ff09e937a177279,
+ 0xa2c29ee7a33ca5f1, 0x990e8dbee083923b, 0x4a819b72f610863a, 0xddecfad79d3f08be,
+ 0x627372480fac20a7, 0x802154d6eca2db4c, 0x8fcf02e42f805e55, 0x040a911ff8cea977,
+ 0xbb544485bc64d0d4, 0xaddde1aeb406d0fb, 0xf6b35fae23dce66f, 0xc07a9fb3645d2f9b,
+ 0xccd113907e9c0fed, 0xd17af369984fd213, 0x9223823c59a083e7, 0xe19d475606b81013,
+ 0xe181ac116a90e57a, 0x71f7b6258c6def4c, 0x2246f34b45964f7c, 0xd74aedaea2d31751,
+ 0xb1add86e5dd305d1, 0xeb9ba881f16d6471, 0xef7600e036f5c6ff, 0x1d50bc9735b8fb85,
+ 0xe63942bd1f3e2969, 0x9241ba9f8b3f4e72, 0xee8bb2bca07d35b6, 0x55cd55dab522654e,
+ 0x94d0cfa7c1a6845d, 0x02f9845d559884c3, 0x8ce70ea21063b560, 0xd70998028ef08b74,
+ 0xdfdb5bbee310876b, 0x4e21b2e348256d16, 0xde007a981c13debc, 0xe51950cbbddabfdd,
+ 0xd223301dbe9957c1, 0x084b8634cc2cce4b, 0x90e551378aa9d70c, 0x833b533ac633e448,
+ 0x7891e232882da57f, 0xa1bf26f0163ce2b3, 0xf33a0171eb9c68d5, 0x2e7de18ca69b3fa2,
+ 0x666fd6f175619199, 0x1239d37edb5feb9f, 0xfa9fc9382e61ff5c, 0x3ca4ad427e3c126f,
+ 0x37c6dd4c2c31ae6e, 0x1f1bacb619d427b2, 0x7dd09f5d10759afe, 0xc8d941432327d733,
+ 0x2b389ba25e1d43a7, 0xa4e3030c3740ff21, 0xcc56dae13fd37463, 0x2481457c175b560f,
+ 0x9deb35bde77c5c41, 0x847aa6ea5549a0c3, 0xcde01bb48b6e7f02, 0x15a28844e64cb211},
+ {// seed = 1
+ 0xecfcba92fe5691a3, 0x71377799fea34699, 0xb284c9096fa614e5, 0x54534170f40de6c8,
+ 0xbbd804d45884fba3, 0x44929a896388c8a1, 0x79b712508e0fa3b1, 0xeb53ab280af31054,
+ 0x351ea23a6319da7a, 0x2fbe55d9819d85a2, 0x34f4b6568dcd28b1, 0x8c94ea5e5d82967a,
+ 0x09068d333a46d3c5, 0x762ad4f64cb73381, 0xd5c6db5ef0e22640, 0x36d8ab5a36175680,
+ 0xd41fe333cdc3525a, 0xa1f51dbdf20ce781, 0x1410a95e786c8be6, 0x96b7499a670c2b41,
+ 0x3912e1037835d893, 0x272c5bd83e1e9115, 0x2ea7f91cad82a0d6, 0xcd10e85662ce9931,
+ 0xedad49be8d5e8b74, 0x7ccd8fe0f37d12bc, 0xfac0482005eed593, 0x4513991681f6c8b0,
+ 0x2804d612eb0ad37d, 0x7cca9e8412b81d34, 0x85ffd6707192b7b8, 0xea0560aeea954411,
+ 0x0122d28226102bba, 0xf51c47cdbd22fdd1, 0x3707d851183ff17c, 0xaef5a1465f3e902d,
+ 0xbcb38c2d8736a04f, 0x4025317e864bef15, 0x8d3f66d86e1ea58f, 0xc16759a3d97ed79a,
+ 0x1c62abdc0659f2f5, 0x23b3eb4e699bd28f, 0x5083c4fceed3ccaf, 0xa65bf34562cc989c,
+ 0xaa5865932fd79064, 0xf24d08d268c24593, 0x7fbd00a215196999, 0x7812cd366d752964,
+ 0x62e8dcb27ef3d945, 0xf08b7984e1b946dc, 0x547d23ad9a5c1dcf, 0x496b1fb249b27fb7,
+ 0xcd692e1db5f3b3ba, 0x41931e39f1e1bc61, 0x286c6a7d7edae82b, 0x17ef6638b6c4ca6e,
+ 0x609beb5a2576a934, 0xcc5e16fe4a69b83c, 0xbbd14d08b078fc24, 0x2a617680f481cb94,
+ 0x81dbbd5f86e6d039, 0xeb8205e1fc8ecc3c, 0xe5e3bb576faa8042, 0x5d6f1eb9d9df01b5,
+ 0x9a47b8739c10fb44, 0x398a7caad7ea7696, 0x9c0fc1d7c46adde6, 0x67cd6de0a51978a6,
+ 0x68ccc4b77a21cca4, 0x1e067066b82f415c, 0xf7ddade6535e1819, 0xf2185c884291751b,
+ 0xc322b7381fcbe34f, 0x242f593e88290b9b, 0x8e11ccc0ea5e84a3, 0x40e3a2e3346db8a2,
+ 0xf18bfc3ad2931a2c, 0x2468397394b00144, 0xeae199cce14e6817, 0x05b462686c75a1ae,
+ 0xda096cb859c51673, 0xd87aeb967a906bef, 0xaabc74493cb02fe6, 0x74d48fc2e7da143e,
+ 0x6ec1c8fed3f2c1fd, 0xe01e0704b463f18e, 0xc3d88a4d3a8056e4, 0xd01ae0ffab6c8f3f,
+ 0x881ba052620ae7c7, 0xcea033aef0a823a5, 0x8d2cad91d83df1e3, 0x18746d205e66dbe9,
+ 0x3061f8e58d046650, 0xd819c59f0ce2cf8b, 0x144e89e93635e870, 0x3415e88279b21651,
+ 0xd6f7ab944b86c3fa, 0x45f1dd15d0f67bdc, 0xbf0d97c7f4fa24f4, 0x34a7de520a57fcd2,
+ 0x4ba86fda03e9e2bc, 0xa7995265a025b552, 0x698f6819d5f51cf7, 0xd07dbe9d8a156981,
+ 0x2683945373857fc1, 0x116f8a84f96167de, 0x8bc832bd85595ebf, 0xb206519d74fdfafa,
+ 0xde9519b2e9b5cc5f, 0x16fdd6f2da1d8163, 0x7ba32bd48ef56f11, 0x6f4e4d7ee8b29717,
+ 0xd31576dde7468aad, 0x023bb08848676045, 0xf6dcc083178160b7, 0x42035f426250e683,
+ 0x343732993cfed89f, 0x0640a870a22d3d58, 0x65cff80b53b4ae6a, 0x27996fa17ab05215,
+ 0xfd5db01401b21a04, 0x894508784bc1673c, 0x5bfcf43a2380e27d, 0x4cd6dcc2715583b7,
+ 0xa43b3763e7d4c902, 0x6da83e12ef0c1257, 0xfe80a602b0335aff, 0x293a7d8f4ff344de,
+ 0xb4ae7c2b8956bf5a, 0x6b45432d38254b4d, 0xd086acbdf15d9455, 0xa4d19e43f41ea87b,
+ 0xf01f13ba4bb87fbf, 0xca582cf301a299ff, 0x0ddad3d45298fa7d, 0x0646a130459c3999,
+ 0xc08e3af3747e2cee, 0xfc7db8aa9ed67295, 0x783b329e7bd79d5f, 0x732dbc607957af7b,
+ 0x8e446ac19fb26555, 0xff1dfa4d61dc89a5, 0xb6fbc46bd8d011d8, 0x185147ec5779f0d7,
+ 0x6eb2cf6149a5380f, 0xb0e773df803a1eae, 0xc07706c5519bfce5, 0xc35abcf54fa95f14,
+ 0x40a01d99a38608ea, 0x776dcd6f603c277f, 0x6ae12389b1d6d0bb, 0x8bd981448df92bb9,
+ 0x426a6a7ca21a2c16, 0x87efd5b71c1bad26, 0x71fb7fc4cd41de48, 0xdd9033c45619d463,
+ 0x40eaab322654cef7, 0xe077fffed6f3e3a2, 0x375a4dbef9384447, 0x2066b009d2c4a100,
+ 0xeca4a5794a068447, 0x2128f64bddf341a1, 0x738b4bb1be90bd61, 0x433772cf3813d52e,
+ 0x9540c88add8e4474, 0x0b6d5decd21d3519, 0x654ead966745642d, 0xe1bfb03c3b4bdb4c,
+ 0x0b977a9937515b1f, 0x0a4587509ef63870, 0xe89f0de1d9cfd44a, 0x23a91390272e7f68,
+ 0xd92defbc9096b8d8, 0x004db87174612539, 0xc88ecaabdd1a71f1, 0x050de38393073346,
+ 0x8af1426d7964e038, 0xf352c4fef8ad5c87, 0x6f26bc7408e26548, 0x0d41543fd9bf3084,
+ 0xfc4e07553a840fc6, 0x5ef117de86a555a9, 0x1f11c42dffb5ae1b, 0x4147648f07490fa5,
+ 0x09b35fd7671b21aa, 0x1453b14f7ccca481, 0x944f6fcce4c9b2ba, 0x5b08dd2e3583dc06,
+ 0xe0220df78dc9c22d, 0x1c200b9506cbf666, 0x8a0b7465eadb523b, 0xfbcb43a91a1e2d80,
+ 0xe697f44be3c36a58, 0x2f8a8e48fb7e350d, 0x7baba71b8920d55f, 0x10edc0216105bc96,
+ 0x52db07c79d7a7a63, 0x1916e8cef9452ac3, 0x5cbbbf21f867b6cc, 0xadd583365a690a4b,
+ 0x4e4ca2c8bffc2fdb, 0xf5fe3416d2eebcfe, 0x839af8b85e452476, 0x8496c0c54ad44e16,
+ 0x6c46f1ecad4482bf, 0xb794cad76ae18715, 0x67b762eec7c62985, 0x52dc9e68df5b3a53,
+ 0x0cc7e444b422a5f9, 0xadbfe90841c112b0, 0xfe37b136f0ca5c34, 0xcfe9e47948a8d73e,
+ 0xee90572b86a30d91, 0x549e72d8262830aa, 0x3361564b469f32c6, 0x1e6eba9e0d2648e2,
+ 0x5f8e2b2ac5fcb4eb, 0xe4224fa5f71f7cc6, 0x7357a9230c76757b, 0xcad70f74aaf6b702,
+ 0xeef28ced23894cc2, 0x753fdd3352aefd68, 0x1fed6ba90bbeb9d2, 0x05316f4ab4034b4b,
+ 0x3396df022b9f63d6, 0x82d7125a7cfd0935, 0x3519a71caf1f87f0, 0xd1dfb7a5cc3974be,
+ 0xbfae40ecbdbbcc2a, 0x152c11778e08dd54, 0x4a96566a6c848554, 0x3a84d621c340cdd7,
+ 0xfd47aa1887e2fb03, 0xa63cae94b2f1d099, 0xed61783f3e5b75e0, 0xefd44864106019be,
+ 0x145ff78b80b081aa, 0x34670e5fcea9230e, 0x876ef976328db371, 0x4221f3a5269942a6,
+ 0x95315cbd85c648f4, 0x3ca344dc7c3b1600, 0x38421ea39ff28780, 0x31dbeee967c0435c,
+ 0x27437c3e268402e7, 0xdd0cf8343312a654, 0x965ab9dad1d8aa29, 0xf871706dd3e23509,
+ 0xce23d06c7a25e699, 0x1b37d59382b27589, 0x3407f004723d6324, 0x56efb69cdb5deaa1,
+ 0xf46cdd2b9fd604e0, 0xcad3ca79fdac69bd, 0x7252802a574e63cb, 0xc281fb8acc6ec1d3},
+ {// seed = 2
+ 0xdd16cb672ba6979c, 0x3954eaa9ec41ae41, 0x52cb802771d2966d, 0xf57ed8eb0d0294f2,
+ 0x768be23c71da2219, 0x6131e22d95a84ad3, 0xd849e4e49bb15842, 0x18e8e5c4978cf00d,
+ 0x3af5e5867ce1f9bd, 0x06c75a9fffe83d63, 0xe8de75a00b58a065, 0x0a773251bc0d755a,
+ 0x629dc21e54548329, 0x2a168f5e5a883e70, 0x33547375f0996c86, 0xdfcb4c7680451322,
+ 0x55c1ecaaaa57e397, 0x4546c346c24f5a31, 0x6f8f0401dfabc86c, 0x7760d2d36ee340b4,
+ 0xf6448e48bdeb229d, 0xba70e1633b4dba65, 0x069cda561e273054, 0xa010b6a84aebf340,
+ 0x5c23b8229eee34b6, 0xea63c926d90153af, 0x7d7de27b3e43ec1b, 0xea119541eddc3491,
+ 0xf1259daeddfc724c, 0x2873ca9a67730647, 0xa1e7710dade32607, 0x758de030b61d43fd,
+ 0xd2c9bcbfa475edb4, 0x18ade47bb8a0aa29, 0xf7a74af0ff1aea88, 0x6f8873274a987162,
+ 0x6963e8d876f4d282, 0xd435d4fe448c6c5b, 0x93ec80ba404cafff, 0xcf90d24c509e41e7,
+ 0x5f0fc8a62923e36e, 0x9224878fe458f3a4, 0xd9a039edf1945bcd, 0x0877d1892c288441,
+ 0x75205491f4b4740b, 0x30f9d2d523a9085b, 0x4b7f4029fa097c99, 0x170bb013745709d4,
+ 0x7087af537f11ef2e, 0x28c62b88e08fc464, 0x84bbcb3e0bb56271, 0x485a4b099165c681,
+ 0x357c63357caa9292, 0x819eb7d1aee2d27e, 0xdaa759eb9c0f8c9d, 0x42cdc36729cc3db5,
+ 0x9489aa852eddbb06, 0x8161e4f85a84e6d4, 0xa964863fdad3eb29, 0xcc095ddbce1a6702,
+ 0x3ecfadbb8dc2ce58, 0x971316509b95a231, 0xc8f484d1dbc38427, 0xae9c510c463574c0,
+ 0xdf2b31179600c21a, 0x440de87bada4dfa3, 0xbd8d30f3f6fb7522, 0x84e6d7f678a0e2d0,
+ 0x0ec4d74323e15975, 0xf6947610dad6d9ab, 0x73a55a95d73fe3a5, 0x3e5f623024d37eda,
+ 0x8d99a728d95d9344, 0x8b82a7956c4acdc4, 0x7faeaea4385b27f6, 0x540625ff4aa2ff21,
+ 0x4aa43b3ebd92ce2b, 0x899646a6df2da807, 0x49225115780942d7, 0xe16606636af89525,
+ 0xb980bcf893888e33, 0xf9ed57695291b0d8, 0x5c6dd14464619afa, 0x50606d69b733d4f3,
+ 0x7fb1af465b990f97, 0x3fab2634c8bbd936, 0x556da6168838b902, 0x0f15975902a30e1f,
+ 0xb29d782ae9e1991f, 0xae00e26ff8f7e739, 0xd3da86458bb292d5, 0x4528ee0afb27e4ce,
+ 0x49882d5ba49fabad, 0x7e873b6a7cf875ee, 0x777edd535113c912, 0x94ed05e7ff149594,
+ 0x0b8f95fc4211df43, 0x9135c2b42426fef2, 0x411e6c2b47307073, 0x503207d1af0c8cf8,
+ 0xd76f8619059f9a79, 0x64d24617855dee45, 0xf7bc7a877923196a, 0xd6cc42ed6a65be79,
+ 0xe3912ff09d4fc574, 0x4192d03b2bc2460a, 0xa0dcc37dad98af85, 0xfc59049b2a5818a4,
+ 0x2128bae90a5b975f, 0xbe7067ca05ea3294, 0x5bab7e7753064c4f, 0x42cbf0949ef88443,
+ 0x564df4bbd017492c, 0xf2c2eb500cf80564, 0x5b92e67eb00e92af, 0x8c4103eef59c0341,
+ 0x83412122b8284998, 0x888daf2da0636b6d, 0x4d54b10303dd07d6, 0x201190e7c1e7b5ed,
+ 0x3797510bb53a5771, 0x03f7bc598b570b79, 0xdc1e15d67d94f73e, 0x721e8b499ebe02c1,
+ 0x71f954f606d13fa0, 0x0c7a2e408c168bf0, 0x07df2ef14f69c89d, 0xe295096f46b4baaf,
+ 0x7a2037916438737e, 0xd1e861aeaf8676ea, 0xb36ebdce368b8108, 0xb7e53b090ddb5d25,
+ 0x5a606607b390b1aa, 0x475e52994f4a2471, 0xbcc2038ba55b2078, 0x28b8a6b6c80df694,
+ 0xb5f0130ec972c9a2, 0x7a87cd2a93276b54, 0x4d0eec7ecf92d625, 0xac1a8ce16269a42e,
+ 0xa4ca0237ca9637b8, 0xd8dc8ff91202b6ff, 0x75b29846799d7678, 0x761b11a5edd9c757,
+ 0xf2581db294ef3307, 0xe3173c2b6a48e20f, 0xe46fd7d486d65b3c, 0x1352024303580d1f,
+ 0x2d665dae485c1d6d, 0x4e0905c825d74d3b, 0x14ff470c331c229e, 0xbdc656b8613d8805,
+ 0x36de38e396345721, 0xaae682c1aa8ff13b, 0x57eb28d7b85a1052, 0xf3145290231d443a,
+ 0xd0f68095e23cbe39, 0x67f99b3c2570b33d, 0x54575285f3017a83, 0x9b2f7bb03d836a79,
+ 0xa57b209d303367a9, 0x7ccb545dd0939c79, 0x1392b79a37f4716d, 0x6e81bb91a3c79bcd,
+ 0x2c2cd80307dddf81, 0xb949e119e2a16cbb, 0x69625382c4c7596f, 0xf19c6d97204fb95c,
+ 0x1b2ea42a24b6b05e, 0x8976f83cd43d20ac, 0x7149dd3de44c9872, 0xc79f1ae2d2623059,
+ 0xca17a4f143a414e1, 0x66d7a1a21b6f0185, 0xed2c6198fe73f113, 0x16a5f0295cbe06af,
+ 0x5f27162e38d98013, 0xf54d9f295bdc0f76, 0x9ba7d562073ef77b, 0xa4a24daaa2cfc571,
+ 0x49884cf486da43cd, 0x74c641c0e2148a24, 0xbff9dcbff504c482, 0xf8fc2d9403c837ab,
+ 0x6ccc44828af0bb1e, 0xbcf0d69b4c19dfdb, 0x8fe0d962d47abf8f, 0xa65f1d9d5514271d,
+ 0x26ff393e62ef6a03, 0xc7153500f283e8fc, 0xea5ed99cdd9d15cd, 0xfc16ac2ba8b48bb7,
+ 0xf49694b70041c67a, 0xbd35dd30f5d15f72, 0xcf10ad7385f83f98, 0x709e52e27339cdc2,
+ 0xe9505cb3ec893b71, 0x2ffa610e4a229af7, 0x12e1bc774d1f0e52, 0xe301a3bb7eacccc8,
+ 0x1fdd3b6dcd877ebf, 0x56a7e8bda59c05aa, 0x99acd421035d6ab4, 0xfd21e401cecd2808,
+ 0x9a89d23df8b8d46f, 0x4e26b1f1eb297b9c, 0x9df24d973e1eae07, 0xe6cdc74da62a6318,
+ 0xfc360d74df992db0, 0xf4eca0a739514c98, 0x481c515ba9bf5215, 0xce89cce80f5f3022,
+ 0xf487a10fc80e4777, 0x235b379a87e41832, 0x76f72e028371f194, 0xd044d4a201325a7d,
+ 0x47d8e855e0ffbdde, 0x268ae196fe7334b0, 0x123f2b26db46faa8, 0x11741175b86eb083,
+ 0x72ee185a423e6e31, 0x8da113dfe6f6df89, 0x286b72e338bbd548, 0xa922246204973592,
+ 0x7237b4f939a6b629, 0x31babda9bedf039a, 0xb2e8f18c6aeec258, 0x0f5f6ce6dd65a45e,
+ 0x8f9071a0f23e57d3, 0x71307115ba598423, 0xcbe70264c0e1768c, 0x1c23729f955681a8,
+ 0xfbc829099bc2fc24, 0x9619355cbc37d5d6, 0xea694d4e59b59a74, 0xb41cf8d3a7c4f638,
+ 0xae1e792df721cd0b, 0x7cd855d28aac11f6, 0xca11ba0efec11238, 0x7c433e554ce261d8,
+ 0xe3140366f042b6ba, 0x8a59d68642b3b18c, 0x094fcdd5d7bccac2, 0x9517d80356362c37,
+ 0x4a20a9949c6c74e8, 0xc25bcf1699d3b326, 0xa8893f1d1ed2f340, 0x9b58986e0e8a886e,
+ 0x29d78c647587ce41, 0x3b210181df471767, 0xd45e8e807627849d, 0x1ec56bc3f2b653e3,
+ 0x974ff23068558b00, 0xdb72bdac5d34262c, 0x23225143bb206b57, 0xd0a34cfe027cbb7e},
+ {// seed = 3
+ 0x39209fb3eb541043, 0xee0cd3754563088f, 0x36c05fc545bf8abe, 0x842cb6381a9d396b,
+ 0xd5059dcb443ce3bf, 0xe92545a8dfa7097e, 0xb9d47558d8049174, 0xc6389e426f4c2fc0,
+ 0xd8e0a6e4c0b850d3, 0x7730e54360bd0d0d, 0x6ecb4d4c50d050d5, 0x07a16584d4eb229f,
+ 0x13305d05f4a92267, 0xb278ddd75db4baec, 0x32381b774138608f, 0x61fe7a7163948057,
+ 0x460c58a9092efee6, 0x553bf895d9b5ff62, 0x899daf2dabfd0189, 0xf388ab9c1c4b6f70,
+ 0xd600fe47027ea4cd, 0x16d527ec2b5ef355, 0x5ac1f58ff6908c81, 0xa08d79ff8ee9ffe8,
+ 0xc1060a80b7a5e117, 0x14b2c23118c60bda, 0x8cc0defbb890df8f, 0xe29540fd94c6d28b,
+ 0xa604f003f82d5b71, 0xa67583d4eb066d18, 0xd62cbd796322b3fc, 0x070cfe244cdcccf3,
+ 0x73557c30b3af47e5, 0x2e544e31153a2163, 0x996eef7464d5bead, 0xbc71cb5ab0586cdc,
+ 0x0bfcb6c1b517ed69, 0x62b4f1fcc82e8ca0, 0x0edbc68f544965c5, 0x40fa39baa24af412,
+ 0xf39aeb2413dab165, 0x17e6013e7afee738, 0x8109bff1c8d42a9d, 0x3cd99863390989b5,
+ 0x02021a4cc9c336c8, 0xa06060778cb60aa4, 0xd96591db60bc1e06, 0xd2727175183f4022,
+ 0xcdc1f1c5bce3e7ce, 0xb393ccc447872a37, 0xdf6efe63257ead3a, 0x20729d0340dbceb6,
+ 0x9f3d2d26fc0ea0d7, 0xf392e0885189bd79, 0xdf2ee01eb212b8b6, 0x6e103a0c0f97e2c3,
+ 0x96c604a763bd841b, 0x9fc590c43bba0169, 0xf92dcd5ddc248c40, 0x113a8b54446941dc,
+ 0x5943eda146b46bb8, 0xbf657901a36a39a7, 0x5a4e0e7ea6568971, 0xb94c635bae9f9117,
+ 0x2626fb65b3a4ef81, 0xa59bfd5478ce97de, 0x79112ba9cc1a1c63, 0xf41f102f002cf39c,
+ 0x0a589bcbfb7ff1c8, 0xa1478c53540c4fa1, 0x60d55e72c86dfaca, 0x312e7b6840ea7a39,
+ 0x8aae72dcccfe1f75, 0xff2f51f55bf0247a, 0x3c2e4b109edb4a90, 0x5c6d73f6525c7637,
+ 0xe49acb04a199f61c, 0x27860642d966df7f, 0x541ce75fb1e21c30, 0xd9fcd6f90806c7cc,
+ 0xb87c27bc93a7969b, 0x92f77a1179b8f8dc, 0xb1f29379deb89ed4, 0x7e63ead35808efe7,
+ 0x13545183d7fa5420, 0x575f593e34cf029d, 0x27f1199fb07344ae, 0xe67f95f7dc741455,
+ 0x49b478b761ab850b, 0xd7bedf794adfc21e, 0xdc788dcd2dda40ae, 0x14673eb9f4d8ad35,
+ 0x0cced3c71ecf5eb1, 0xe62d4e6c84471180, 0xdfe1b9e2cb4ada7d, 0x70185a8fce980426,
+ 0x0ce2db5e8f9553d6, 0x1fedc57bb37b7264, 0xb9310a2e970b3760, 0x989ff8ab9805e87d,
+ 0x0b912d7eb712d9ee, 0x1fe272830379e67c, 0x16e6a73aff4738fb, 0xeed196d98ba43866,
+ 0x7088ca12d356cbe2, 0x23539aa43a71eee0, 0xed52f0311fa0f7ad, 0xa12b16233f302eea,
+ 0xc477786f0870ecb4, 0xd603674717a93920, 0x4abe0ae17fa62a4c, 0xa18f1ad79e4edc8d,
+ 0xc49fe6db967c6981, 0xcc154d7e3c1271e9, 0xdd075d640013c0c0, 0xc026cd797d10922a,
+ 0xead7339703f95572, 0x4342f6f11739eb4b, 0x9862f4657d15c197, 0x4f3cb1d4d392f9ff,
+ 0xe35bffa018b97d03, 0x600c755031939ad3, 0xb8c6557ffea83abf, 0x14c9e7f2f8a122ea,
+ 0x0a2eb9285ee95a7c, 0x8823fec19840c46f, 0x2c4c445c736ed1d0, 0x83181dff233449f1,
+ 0x15ed3fca3107bef5, 0x305e9adb688a4c71, 0x7dbef196f68a3e2e, 0x93e47ece3e249187,
+ 0x8353c5e890ead93c, 0xea8a7ae66abafdf7, 0xf956dbb6becf7f74, 0x9f37c494fbfdb6e4,
+ 0x11c6cbaa2485dd32, 0x206f336fcca11320, 0x9befe9a59135d8fe, 0x5f3ef8b8db92c7db,
+ 0xbb305e556ce0ce9a, 0xf26bdafb1305887f, 0xcbf28abe23f08c61, 0x0bc64173b914e00b,
+ 0x9168da52e983f54a, 0x6ea41d09c3574a3e, 0x78aa44d4a74459ae, 0x2931422878387bf5,
+ 0x018f64a3a92c2d9c, 0x9be43f6752e66b34, 0xae378890decd1152, 0x07325329a1cb7623,
+ 0x3b96f4ee3dd9c525, 0x2d6ebcdbe77d61a3, 0x10e32b0e975f510c, 0xffc007b9da959bf9,
+ 0x38bf66c6559e5d90, 0xbe22bdf0bf8899fe, 0x87807d7a991632a8, 0x149a0d702816766a,
+ 0x026f723db057e9ab, 0xeeecb83625ec6798, 0xcec2ed5984208148, 0xd985a78e97f03c84,
+ 0xf96c279e7927b116, 0x99d5027b3204f6e2, 0x13a84878c3d34c55, 0x5cf5ec96229e9676,
+ 0x0bc36b07e4f8e289, 0xbed33b80a069914d, 0x2fbfbdd1ff4b9396, 0xab352bb6982da90f,
+ 0x154d219e4fa3f62b, 0x4d087512bb6b9be7, 0xc582e31775ee400e, 0x7dadb002ae8c4a4e,
+ 0xaae2957375c1aee2, 0x5f36ca643356625b, 0xf87cf8eb76e07fb7, 0x46f432a755e02cc3,
+ 0x36087e07aba09642, 0xe5642c1e4ebb9939, 0xb9152d22338eefad, 0xf7ba44278a22cf7f,
+ 0xd3b8013502acd838, 0x7761511da6482659, 0xb0857621638e8e50, 0x552eddb4a8b1d5f5,
+ 0xc43d9861e812c3ea, 0xd765c2aada47910c, 0x21c935b68f552b19, 0x6256d5641a2b47dc,
+ 0xab711d8e6c94bc79, 0xa8d0b91a2a01ab81, 0x5e6d66141e8d632a, 0x7638285124d5d602,
+ 0x794876dbca3e471f, 0x951937d8682670ce, 0x0f99cb1f52ed466a, 0x8c7cd205543b804c,
+ 0x2fd24d74a9c33783, 0xe5dcb7b7762e5af1, 0x45e6749cca4af77c, 0x540ac7ee61f2259f,
+ 0x89c505c72802ce86, 0xeab83b9d2d8000d1, 0x9f01d5e76748d005, 0xc740aaef3035b6d0,
+ 0x49afcd31d582d054, 0xcba5dc4c1efb5ddc, 0xc0a4c07434350ca1, 0xfc8dfaddcc65ee80,
+ 0x157c9780f6e4b2d9, 0x9762a872e1797617, 0xc4afae2cf3c7e1bd, 0x71cde14591b595d4,
+ 0x8843c3e0e641f3b9, 0xd92ecd91dce28750, 0x1474e7a1742cb19f, 0xec198e22764fa06b,
+ 0x39394edb47330c7d, 0x00ba1d925242533d, 0xaed8702536c6fb30, 0x6d3618e531c2967a,
+ 0x77f7cedcd7cc0411, 0xbc1e2ab82be5b752, 0x07b0cf9223676977, 0x596c693b099edd53,
+ 0xbb7f570f5b9b2811, 0x96bfdad3c4a6840c, 0x668015e79b60c534, 0x3ad38d72123f1366,
+ 0x6b994d81d2fcbb09, 0x70885f022c5052d8, 0xc891ee79d9306a7b, 0x2c4df05c0ed02497,
+ 0x19ebc13816898be2, 0xea7c64df11c392a2, 0xb7663e88dd12e1bd, 0x79f768cb8e154c21,
+ 0x1fb21b12e945933b, 0xe6a9045643f6906e, 0x544c47acd7e15371, 0xb7709b14f727e3d1,
+ 0x326ee36a46942971, 0x477f1cf7b0e2d847, 0x88b8f6b82b3b0c24, 0x18bc357b80e3cd5c,
+ 0x3333de70e4d66e0b, 0x4fd4c5e148583cf6, 0xae1b62f3008c0af3, 0xc49f419b6ab29cf5,
+ 0x2c29fa65afc3fa28, 0x4b19d93734d03009, 0x7dd6c09e589276ad, 0x1cece97f30de48ad},
+ {// seed = 4
+ 0x58bdf4338602e4fb, 0x71a5620b02c926d5, 0x3811c960129c2d9f, 0x29c2fb11fccac567,
+ 0x0d6b1ea7780f1352, 0xcc4d3ddfae3f87b3, 0xfdd30257362a586b, 0xabc948fde69f25f1,
+ 0x51b3523469d30f7b, 0xe0f0322724405ace, 0xd3729266d896da1e, 0xb10c37e5147915bf,
+ 0x8b577039f9fa32a3, 0xe677c6a9cbfb44b3, 0x7317a756ebb51a03, 0xf8e988ef37359485,
+ 0x600fc1ef3f469ff3, 0xbf0b8f8520444e01, 0x3711168b08b63d73, 0x34146f2944a6cb36,
+ 0x717feb263862cdde, 0x7185f8347db00412, 0x900798d82127e693, 0x84089e976a473268,
+ 0x10f8308c0d293719, 0xf62a618d4e5719b8, 0x8bdbd257a1a9516f, 0xf49f666fd7a75110,
+ 0xbaf45e2db7864339, 0xe4efa1ea0c627697, 0x3e71d4c82a09fe10, 0x54a2a51cf12127bb,
+ 0xa0592c9f54ba14cd, 0x27dd627a101c7a42, 0x3d2ceb44b3d20d72, 0x7ee1f94a68ca8f5d,
+ 0x7e8cb8651b006c36, 0xbd9fa7ca3a475259, 0x856de173586a7b34, 0xcedb291b594cb1b5,
+ 0xa3d6e462fd21cddc, 0x74561d10af9118e4, 0x13a3d389fc2d4b36, 0xeea8594a4a054856,
+ 0xf56d7474d9ba4b13, 0x25ddce2f6490b2fd, 0x920653ff3a8d830b, 0xcd8c0c9cdac740d1,
+ 0x2c348a738db9c4a0, 0x2967ccbe8ea44c22, 0x47963f69adb049f8, 0xf9d01eb5b4cf7eb6,
+ 0x7a5c26eb63a86bd2, 0x62ad8b7a71fa0566, 0xb373213179f250ae, 0x589d4e9a88245a4d,
+ 0x433dafebe2d558a8, 0x521fbef2c8fe4399, 0x62a31f9ff9ccd46b, 0x51602203eba7c1a6,
+ 0x9afc8c451b06c99f, 0xb529085bdbaffcea, 0xac251825cc75892b, 0x94976a5bce23d58e,
+ 0xdd17925b6c71b515, 0x568fd07a57bce92e, 0xefac31200d8bd340, 0x716c3e466b540ef9,
+ 0x3d2c9e380063c69b, 0x14168f9a3662dd83, 0xd298c7504dbc412f, 0x74490a94f016719f,
+ 0x0e0da431e1ab80c8, 0xe321f63dc6b169ae, 0xf08671544febc95a, 0x39324450cc394b3b,
+ 0xea6e3d35f1aa3a70, 0x8ef8a886508ce486, 0xdc1a631ef0a17f06, 0xfda2b3fbcd79e87b,
+ 0xd75bcae936403b10, 0xf88b5bd9f035f875, 0xc43efec2e3792dd4, 0xe9fac21a9d47cd94,
+ 0xc2876f0c4b7d47c3, 0xaba156cf49f368b4, 0x5ccda2170fa58bf9, 0xadc92c879ed18df7,
+ 0x110c1b227354e6c8, 0x298ee7a603249200, 0xde92142ede0e8ee7, 0x88e4a4610644ba9e,
+ 0xbb62d277e7641d3a, 0xb9be1985b7bf8073, 0x29024e5426cdb0d1, 0xf6aefd01f3092ab8,
+ 0x2a07087b313133aa, 0x6d71f445d6dfc839, 0x1e2412ff12e5526b, 0xed5cdeba6617b9e1,
+ 0x20b1d0d5e5f8760e, 0x12ff15705c368260, 0x7bf4338b7c387203, 0x34ff25f00cd06185,
+ 0x1148c706c518cf28, 0x5c04f0623388f025, 0xcb9d649275d87d79, 0x9b5f0c24fabc42ec,
+ 0x1a7b5e7964e33858, 0x2a81bbd8efdc6793, 0x8d05431ffe42752e, 0x83915cd511002677,
+ 0x580ed4d791837b31, 0x5982e041d19ff306, 0xcad0d08fa5d864ca, 0x867bee6efe1afa63,
+ 0x26467b0320f23009, 0xd842414dfda4ec36, 0x047fcdcbc0a76725, 0xbddb340a3768aeca,
+ 0xef4ce6fa6e99ab45, 0x88c5b66c7762bf9b, 0x5679f1c51ffb225d, 0xdab79048317d77ee,
+ 0xf14e9b8a8ba03803, 0xe77f07f7731184c1, 0x4c2aab9a108c1ef5, 0xa137795718e6ad97,
+ 0x8d6c7cc73350b88b, 0x5c34e2ae74131a49, 0xd4828f579570a056, 0xb7862594da5336fc,
+ 0x6fd590a4a2bed7a5, 0x138d327de35e0ec1, 0xe8290eb33d585b0b, 0xcee01d52cdf88833,
+ 0x165c7c76484f160e, 0x7232653da72fc7f6, 0x66600f13445ca481, 0x6bbdf0a01f7b127d,
+ 0xd7b71d6a1992c73b, 0xcf259d37ae3fda4a, 0xf570c70d05895acf, 0x1e01e6a3e8f60155,
+ 0x2dacbb83c2bd3671, 0x9c291f5a5bca81af, 0xd976826c68b4ee90, 0x95112eec1f6310a2,
+ 0x11ebc7f623bc4c9a, 0x18471781b1122b30, 0x48f7c65414b00187, 0x6834b03efa2f5c30,
+ 0x0875ef5c2c56b164, 0x45248d4f2a60ba71, 0x5a7d466e7f7ba830, 0x2bebe6a5e42c4a1d,
+ 0xd871d8483db51d10, 0x6ee37decd2fd392f, 0x7d724392010cede3, 0x8e96ef11e1c9bcc8,
+ 0x804a61d86b89d178, 0xbb1b83ce956055ec, 0xcb44e107410ff64f, 0xc426bb09ee0ba955,
+ 0x057c08f42c3dd7f1, 0x40ea1ec148602bdf, 0xc24688deeb65d7f1, 0xd8bcc53c768ba4e4,
+ 0x16e0e3af65c1106c, 0xfc12f7e7d647218b, 0x70d6e1d3ee93cef4, 0x01d2a505c4541ef9,
+ 0x1ef79e16e764d5c3, 0x0363d14d13870b98, 0xb56ef64345d06b11, 0xe653d557ebb7c346,
+ 0x8304a8597c2b2706, 0x1536e1322ce7e7bb, 0x525aec08a65af822, 0x91f66d6e98d28e43,
+ 0xe65af12c0b5c0274, 0xdf6ae56b7d5ea4c2, 0x5cef621cedf3c81c, 0x41e8b1ffd4889944,
+ 0xb5c0f452c213c3e5, 0x77af86f3e67e499b, 0xe20e76ea5b010704, 0xbdc205ab0c889ec0,
+ 0xc76d93eb0469cd83, 0x17ac27f65cab0034, 0xd49ec4531fd62133, 0x07a873ea2f1b9984,
+ 0xbff270dfef0032ee, 0x1764dbe91592f255, 0xe40363126f79e859, 0xa06cad3ab46971f6,
+ 0x0be596e90dedd875, 0x3387cce5c1658461, 0x44246acf88a9585e, 0xe0ad82b92d5ecb2c,
+ 0x2177491c9a1600a6, 0x16e7c4aac0f02422, 0x75792eeeec15c4e1, 0x2309cd359d08ee30,
+ 0x7cd9831dd1b83b0a, 0x374914a7c4ee8cf0, 0x0dd17765c9ac2e54, 0xb7847470ba9a7688,
+ 0xfba4f4bbe2991173, 0x422b203fc3de040e, 0x63bfcaf2ecf2ab0e, 0x0c5559f3a192946e,
+ 0xfdf80675c1847695, 0xf5f570accab842c9, 0x65cc5a448767afea, 0x1efeb0a7ee234f2f,
+ 0x9b05f03d81e7b5d2, 0xe7c31317a8626cf4, 0x620f2a53081d0398, 0x1b6de96cdd9943ae,
+ 0x8c226a436777d303, 0xa08fbbd50fafb10d, 0x6a64c5ec20104883, 0x9c9c653502c0f671,
+ 0x678a02b2174f52a0, 0x68e008ba16bbad4b, 0xa317c16d2efb860f, 0xeab2075d17ed714c,
+ 0x565eeeddf0c4ea15, 0x8ec8e94d242a6c19, 0x139e8e27d9000fae, 0xc977a7ff1b33d2f5,
+ 0x1d0accca84420346, 0xc9e82602cd436e03, 0x6a2231da53d2ccd3, 0xb44b12d917826e2a,
+ 0x4f4567c6a74cf0b9, 0xd8e115a42fc6da8f, 0xb6bbe79d95742a74, 0x5686c647f1707dab,
+ 0xa70d58eb6c008fc5, 0xaaedc2dbe4418026, 0x6661e2267bdcfd3d, 0x4882a6eda7706f9e,
+ 0xf6c2d2c912dafdd0, 0x2f2298c142fd61f9, 0x31d75afeb17143a8, 0x1f9b96580a2a982f,
+ 0xa6cd3e5604a8ad49, 0x0dae2a80aad17419, 0xdb9a9d12868124ac, 0x66b6109f80877fac,
+ 0x9a81d9c703a94029, 0xbd3b381b1e03c647, 0xe88bc07b70f31083, 0x4e17878356a55822},
+ {// seed = 5
+ 0xb3c58c2483ad5ead, 0x6570847428cdcf6c, 0x2b38adbf813ac866, 0x8cb9945d37eb9ad3,
+ 0xf5b409ec3d1aed1c, 0xa35f4bffc9bb5a93, 0x5db89cde3c9e9340, 0xff1225231b2afb2b,
+ 0x157b0b212b9cc47d, 0xf03faf97a2b2e04d, 0x86fdab8544a20f87, 0xfcb8732744ae5c1c,
+ 0xd91744c0787986d5, 0x5f8db2a76d65ad05, 0xcff605cbed17a90d, 0xf80284980a3164e7,
+ 0x59cc24e713fccc7d, 0x268982cada117ce4, 0xcd020e63896e730e, 0xe760dc46e9fe9885,
+ 0x6aaece8ab49c6b5d, 0x7451194d597aae3e, 0x35d4385900332457, 0xa40fb563a096583d,
+ 0xa797b612f7f11b76, 0x2fed6eb68e6a2b9b, 0x2f06ee64aeffd943, 0x9dd0e49d9ca45330,
+ 0x97d48f08bd7f1d8f, 0x1cfa7fe3ebe4d8ee, 0x2a2ba076bd397d42, 0x68c4344f7472f333,
+ 0xce21ec31987d74b5, 0xb73dabdc91d84088, 0x801aadee592222fe, 0xaf41345398ebc3f5,
+ 0x8a8f653d7f15ee46, 0xce2d065ff2ba2965, 0x4e05da515da2adb7, 0xa6dbdb8aa25f0fd4,
+ 0xca9f9666bbd2d5a9, 0x6b917ce50bd46408, 0x1550cc564ba6c84d, 0xb3063ae043506504,
+ 0x84e5f96bb796653d, 0xe2364798096cf6e3, 0x3b0dfedf6d3a53d0, 0xb7e4c7c77bde8d93,
+ 0xe99545bac9ab418a, 0xa0e31f96889507bb, 0x883c74f80c346885, 0xf674ae0b039fd341,
+ 0x8bb6ce2d5e8d1c75, 0x0c48737966a7ed7c, 0x04fcdf897b34c61c, 0xe96ac181bacbd4d6,
+ 0x5a9c55a6106a9c01, 0x2520f020de4f45d3, 0x935730955e94d208, 0xce5ad4d7f3f67d3b,
+ 0xa4b6d107fe2d81ca, 0x4f0033f50ae7944e, 0x32c5d28dd8a645a7, 0x57ce018223ef1039,
+ 0x2cbab15a661ab68e, 0x6de08798c0b5bec2, 0xee197fb2c5c007c6, 0x31b630ac63e7bda2,
+ 0xab98785aefe9efe3, 0xa36006158a606bf7, 0x7b20376b9f4af635, 0xa40762fdc3c08680,
+ 0x943b5faffd0ebee2, 0x7f39f41d0b81f06e, 0x7c4b399b116a90f8, 0x24e1662ac92bc9f3,
+ 0xcf586fc4e8e6c7db, 0xe46e0d047eeb12d7, 0xe8021076e4ea9958, 0x11fc13492e3ca22a,
+ 0xd61eae01410397e3, 0x7e8c4a58036a8e9f, 0x068a6de267970745, 0x64faab129bef1a41,
+ 0xb4a6f720943dad01, 0x631491058d73a9d5, 0xdad4fe95eab3ec02, 0x0a8b141c5c3a44f6,
+ 0x9fc69d4c2b335b98, 0x94d5f84a07d6e4cd, 0x1b73965de143c608, 0x443932c2dda54bcc,
+ 0x7397818fb0b04cd2, 0xef4ab03a1202b277, 0xf3d2ee459c0c2b92, 0x182d4daf8b058a87,
+ 0x90e63035d7b51368, 0xba4cd8b9a95d45fd, 0x12a7392c76731090, 0x890d264ec5d082d2,
+ 0xeeaf5c363da4994e, 0xd6aad756902123fb, 0xb531ebebdb28f191, 0xe71ce659fc59babd,
+ 0x37c1b94f63f2dcb5, 0xe4e3abeb311f9b96, 0x4a31b72ccb8695d3, 0x52cae1f0629fdce4,
+ 0xe5b0475e2ed71369, 0x2724e8c3506414fb, 0xbab0367920672deb, 0x0161a781c305449f,
+ 0x37b70f40f5bb60be, 0xddd1094c50251a01, 0x3b28283afd17224e, 0x06dec0cfe889fc6b,
+ 0x47608ea95bb4902d, 0xad883ebc12c00e82, 0x9e8d7ae0f7a8df29, 0xa79443e9f7c013a1,
+ 0xcfa26f68b7c68b71, 0x33ae6cc19bda1f23, 0xd9741e22b407887f, 0xf2bff78066d46b1c,
+ 0x794123191c9d32d4, 0x56cb6b903764ec76, 0x98775d0ef91e1a5a, 0xae7b713bc15c1db9,
+ 0x3b4c1a7870ed7a0d, 0x46666965f305cc34, 0x0ea0c3b2e9c6b3cd, 0x4dc387039a143bff,
+ 0x5f38bb9229ef9477, 0xea5d39ba72af7850, 0x69a5ed0174ce2b6d, 0x06969a36bfe7594d,
+ 0x0adee8e4065ccaa3, 0x908a581d57113718, 0x64822d6c5a8190ed, 0x8c5068b56ace4e4c,
+ 0x88ba3b4fb4e30bef, 0xa6ec0b8bb5896cfe, 0x4e23fcc6b47996fd, 0xe18e75b0dd549c7a,
+ 0xcd90f17e106cf939, 0x1666fdfb2ef7c52f, 0x4fae325f206dd88c, 0xe7bc1160e25b062d,
+ 0x3cc999cb246db950, 0xc5930a7326cd5c37, 0xb008a48a211367bd, 0xc5559da145a88fd4,
+ 0x1e3ad46655fac69c, 0x7834266b4841bfd7, 0xa764450fbffc58cc, 0x54d8cf93a939c667,
+ 0x93c51f11b21b2d9d, 0x0964112082ed65cc, 0x4c2df21213e7fb03, 0xf0405bc877468615,
+ 0x17b4fc835d116ab4, 0xa6b112ae5f3cb4ef, 0x23cfc8a7fd38a46e, 0x8e0a360dc2774808,
+ 0x24ca9c8092105ad5, 0xafd3f75524f2e0d5, 0x4f39ed7dbaddc24c, 0xe5e362c7679a7875,
+ 0x00914a916b07b389, 0xdfe1119b7d5ab5da, 0xabd6ed9940e46161, 0x630ed2044171e22c,
+ 0xdecc244157dd1601, 0x777e6d5b4b4868d5, 0x9b3530bee67017d8, 0xd2faf08b291fdcb9,
+ 0x006e99455d6523de, 0xd559b5817f6955b5, 0xefcc1063b0088c61, 0xed73145ae0f00ae7,
+ 0xab2af402cf5b7421, 0x897767f537644926, 0x26c9c0473ca83695, 0x192e34e1881b2962,
+ 0xf7cf666ec3b3d020, 0x27f9b79c7404afb7, 0xe533e8bed3010767, 0xe5817838e11d05d3,
+ 0x65659c531bd36517, 0xd427c5e0a23836fd, 0xf3eab7ea58fa3528, 0x07683adae1289f35,
+ 0x201d6af7e896dd32, 0xd5da938b9a21ad88, 0x843fb73ad67bc316, 0x1782ec7d5feef21b,
+ 0x943f66f6ec772877, 0x7e9112e7b26da097, 0xeac8161f8663c2c7, 0xe8600db480a9ebf4,
+ 0x07807fc90f6eaf5f, 0xe0e4c9deb41abf83, 0xbdf533db271f9c15, 0xb398411b0497afe2,
+ 0xdebb45ef25448940, 0xe7a5decefcd376c4, 0xaf1ef3c728c83735, 0xb8b83a99355cb15a,
+ 0x6444a0344f1611e4, 0xe8bb7f5cf3c60179, 0x77ab5c5177e75ff7, 0xc38fd6fa849d585d,
+ 0x390d57d53029060a, 0xa66327eb7b8b593c, 0x6350a14f6fcd5ac9, 0x2c08125bcd7008b4,
+ 0x2d00c299a6a6bf8e, 0x6b0039c1f68d1445, 0x0035150c5d06f143, 0xa34d01628cc927e1,
+ 0xdf5b3164d7b2ede1, 0x8167db1d0583d72e, 0x4e13b341cd2ae8bc, 0xa693d9b1f416e306,
+ 0xc15ed7ca0bc67609, 0xdc344313c1c4f0af, 0x88b6887ccf772bb4, 0x6326d8f93ca0b20e,
+ 0x6964fad667dc2f11, 0xe9783dd38fc6d515, 0x359ed258fa022718, 0x27ac934d1f7fd60a,
+ 0xd68130437294dbcc, 0xaf5f869921f8f416, 0x2b8f149b4ab4bf9f, 0xc41caca607e421cb,
+ 0x7746976904238ef9, 0x604cb5529b1532f0, 0x1c94cd17c4c4e4ab, 0xe833274b734d6bbe,
+ 0xe9f1d3ef674539ce, 0x64f56ed68d193c6a, 0xe34192343d8ecfc1, 0xcb162f6c3aa71fe8,
+ 0x99eaf25f4c0f8fa4, 0x92f11e7361cb8d02, 0xb89170cddff37197, 0x4f86e68a51e071e3,
+ 0x31abf6afd911a75b, 0x6d20cf259c269333, 0x4150b9f88fcb6513, 0x705063989ebf7451,
+ 0x559231d927c84410, 0x1ca8ec4b098bc687, 0xebed22405c9180e0, 0xaa815b37d052af59},
+ {// seed = 6
+ 0x946ac62246e04460, 0x9cebee264fcbc1ae, 0x8af54943a415652b, 0x2b327ed3b17b8682,
+ 0x983fde47b3c3847e, 0x10a3013f99a2ad33, 0x6e230bb92d2721ef, 0x1cf8b8369e5c5c50,
+ 0x7f64017f2b7b3738, 0xd393248a62417fa1, 0x9ff01c0b20a372c5, 0xb0e44abce7e7c220,
+ 0xcebb9f88d48a815f, 0xdb7df6bd09033886, 0x7844fc82b6fa9091, 0x72d095449863b8ec,
+ 0xc13e678c89da2c7e, 0x6caf4d5ad231d12f, 0x2e0ab7b5fcf35c49, 0xf410720cb932a70f,
+ 0xd66ea581f16fce06, 0x175c9f002f57dc98, 0xccbcfd0d32988775, 0xfde4c407d3b0a232,
+ 0x5db2931ae7e97223, 0x6e07e2173085809f, 0x6e1d1ec0f9cad73c, 0xb2fc251a7f802619,
+ 0xbc1fc17f04f342de, 0x8de8f21ec658e078, 0x72c0f40cbee53fd6, 0x0678244411fc17a1,
+ 0x1d5837ca166b9bbd, 0xc8cada003c554345, 0x6a2fe2bfb2e58652, 0xfca9d797a6f7988b,
+ 0x6699e24ac737948b, 0x69623ffcb05789ba, 0x946429c529d95b75, 0x0d14df0b2a13970f,
+ 0x593d8592c440dfec, 0x2ee176f3d7e74b94, 0xae003f1da3be9e26, 0x0c7b02c4c0f6764a,
+ 0x3117e2fa1f632462, 0xf0f23265b6f1eaeb, 0x3111255d9b10c137, 0xc82745e509a00397,
+ 0xbd1d04037005fea7, 0xe104ab0dd22a9036, 0x51b27ce50851ac7a, 0xb2cb9fb21b471b15,
+ 0x29d298074c5a3e26, 0x6ebdf2058b737418, 0xc4a974041431b96f, 0x1ec5a30ccb6bdaac,
+ 0xe818beede9bf4425, 0x4b69b1bce67a5555, 0xf5c35f1eb0d62698, 0xf4509bbd8e99867c,
+ 0xb17206debd52e1bc, 0x35785668c770b3be, 0xe9343987ff5863bc, 0x2ee768499ac73114,
+ 0x5132bb3426eeaaf4, 0x471bce2c6833c5ff, 0xbb9a2d5428e6f6f9, 0xd5678943c595792d,
+ 0xab2a65e7f81e479c, 0xa82407bb23990b31, 0xdae321383984923c, 0x01823bb22648e6f1,
+ 0xda6e8df4214a8b04, 0x0e172bb88e03d94f, 0x552da6c22e362777, 0x7ce67329fb0e90cb,
+ 0x7b2d7f287ede7ebf, 0xd44f8222500651bd, 0x4acca1ef58fbb8ab, 0x428ecf058df9656b,
+ 0xd7e1ec6a8987c185, 0x365be6a54b253246, 0x168849be1e271ee8, 0x6a00f3c4151a8db2,
+ 0x37602727ca94b33d, 0xf6b50f18504fa9ce, 0x1c10817f6bc872de, 0x4bfe1fe42b0f3638,
+ 0x135fad4b8ef6143b, 0x1b25ad2bafc25f58, 0x41e37f85cf321f92, 0xfc73f75d9d5b9bea,
+ 0x9eb3694d1e9cb7e1, 0x601d51f08fa83b90, 0x234a2a9b88366f41, 0x63fe903e16f2c3bf,
+ 0x1cdbd34fa751c0b0, 0x0ce4fc6747c0558c, 0x51ed72afb8bb49aa, 0x20313ba13ca12c96,
+ 0x271fa38f9ebd54c1, 0x3696a5ac03a8edde, 0x05602be7df625702, 0x11f1ac73790f7a9f,
+ 0xa2836c099f0810bd, 0xe5ac2e47caa532fa, 0xd9c000a66d39f681, 0xd93d900e6f3d9d5f,
+ 0x792c81c65b7900f2, 0x5c5dce790ee20da1, 0x74ff1950edec1aee, 0x71fc85fa1e277d8f,
+ 0x0e77df17d6546cbc, 0x07debad44816c3b4, 0xbafa721581e92a70, 0x8ab6fbe2ed27bba8,
+ 0xe83243a20dea304a, 0xaa85a63a84c00a07, 0xde0e79917fc4153a, 0x21bb445e83537896,
+ 0xeedcac49fc0b433a, 0xffb2926a810ae57a, 0xf724be1f41d28702, 0x79cb95746039bb3b,
+ 0x5a54fe3742a00900, 0xda4768d64922c04f, 0x420396a84a339dae, 0xa171e26ee5e8724e,
+ 0x4c8da7c5d289c20a, 0x9ebd79a1a8e94742, 0x39235232b97e9782, 0xb75df0be9bba7d80,
+ 0x0c1d204dd87d48fc, 0x8f81f3e7177266e8, 0xe4a460b39e78d72b, 0x50b98fa151e65351,
+ 0xb7cb585c3ee1eddc, 0x11cdad9a76ee1dc4, 0xa38054a78595dc1c, 0x92f09e2ec4978edc,
+ 0xa8f0061b5efdabaa, 0x04bcc4abc224d230, 0xc58606738e692d46, 0xdd2b27b565952433,
+ 0x19e6ed1b740beec0, 0xceadd49b2ef9891f, 0x328178c28fe95cad, 0xe5ad4c43afe02848,
+ 0x03c0cb538cd967c0, 0xec4352526d19a630, 0x4c7e99389d39b031, 0xf65dd05362c2deb6,
+ 0xd1e70daf6879d28d, 0xbe9f57db6309b265, 0xa4b66f370b872bb7, 0xe26896fbc6ee1fd5,
+ 0xac705e661bfcf7c5, 0xab4d0d07d7f09940, 0x976417c06aeb6267, 0x8161c684a6bd468c,
+ 0xf77b6b9976dc4601, 0xc6489b779a39c12c, 0xb2aa58d5681cea1a, 0x043b1b40f8c3e04c,
+ 0x681fcbfadc845430, 0xab8896c921ba8def, 0x57aaf172606f37b2, 0xc3735048cd5eb8d7,
+ 0xa7078b96955631bd, 0xdd6b3543aa187f33, 0xc7103ea4a2a697fd, 0x8d7b95f6ff1f7407,
+ 0xe44f419e84709530, 0xf340caa9132cbb0a, 0x2ba407283143c66c, 0xe1be240ca636c844,
+ 0x90d32f2877ac08bc, 0x5d26e6294b2c8673, 0x4a6b2f5b27c87a44, 0x961fb9043f76d34f,
+ 0x0afee02d8d3c55d2, 0x6228e3f48c42e5dc, 0xc338e69ee6593675, 0x853f74b16efb7bdd,
+ 0xd062f40bdd22e687, 0x647164b9ab4c4190, 0xf94689f67d598369, 0x8e4b29d87a5012d7,
+ 0xaf02b8b925656fbd, 0x7a722a767179a630, 0xb5c8afe937a75ace, 0xfdb8e8d02d279372,
+ 0x887ef700cb25fae1, 0xcfe9bd912f72cabe, 0xb1d4dedc24f978de, 0x517522d38319cc2a,
+ 0x7dd87b2b36aab798, 0x579c4ff3046b5a04, 0xf5c5975c5028b7a7, 0x7094579d1000ec84,
+ 0xbc8d5b1ea70a5291, 0x161b2d783be8855c, 0xd26d0b0d6d18279f, 0x0be1945f02a78bd5,
+ 0xb822a5a9e045415b, 0x2fe9d68b1ccc3562, 0xb2e375960033d14f, 0x26aca04e49b4ff22,
+ 0x732a81c862112aea, 0x8bd901ed6e4260b8, 0xe839532c561ad5b0, 0x8fb6e4d517a79b12,
+ 0x0dd37f8c0be9b429, 0xc8ad87ad12f1b1b0, 0xc51f3aa62b90318b, 0x031a7e8b86c1cefc,
+ 0xa95547af2b70fc76, 0x9cb3615c5a98801e, 0xa387e3c3341d7032, 0xa087ea52a1debaef,
+ 0x16325ec9a2e6e835, 0x587944a484c585eb, 0xc8879033bde22ecc, 0xa39dbfce709c464a,
+ 0x7acc010f99208774, 0x98dd2973a096c5ad, 0x26458b51139f198c, 0x2f5d19575e8c4f02,
+ 0x726643f0d38af352, 0x44d879b6d73e6e94, 0xa68a03885c980abe, 0x06048acd161c40c0,
+ 0xa4dab8f89d405d28, 0x7120c880cb04be18, 0xa062ace22a1cf0cf, 0x3901a9daf29704f4,
+ 0xff08f3ed989db30a, 0x6d22b13e874c67e9, 0x80c6f35518d73f4d, 0xc23c2a521aac6f29,
+ 0x2e708fd83aaa42e0, 0x7fc3780f55f1b0fd, 0xabb3075c98cf87f2, 0xb4df3f40f7c61143,
+ 0x2a04418098a76d75, 0x0d9eeee9509b2d37, 0x6be8ae51f4b59cdc, 0xe746cc7c00e4a2ab,
+ 0x785bc6df9cac597c, 0x33cb6620ce8adc48, 0xc1ba30739bffcef7, 0x6d95771f18e503f7,
+ 0xf7be3ae2e62652ff, 0xc8d82ffd2a73c62b, 0x8725a3ba5b110973, 0x67ed6b9c724757ec},
+ {// seed = 7
+ 0xc0272d42c19ff3ae, 0x4694228b43ea043b, 0x5709a6ef8a462841, 0xc9210a1e538805c9,
+ 0x279b171196113ec2, 0x859b769fc2d9e815, 0x0d5d3125a2bf14d3, 0x22bca1cfefa878ba,
+ 0x481b6bf58037bd83, 0x4933ba8647728d22, 0xf08c7b6b56f6e1b6, 0x374e8af5a15407c7,
+ 0xa95c4dc3d2487a5c, 0x9b832808ff11e751, 0xf2048507e9da01d5, 0xa9c576189f544a4a,
+ 0xf6c2a45b2e9d2b41, 0x9b9874c9f10ecc2f, 0x37d9b5f51f8c149e, 0x93aead54c9de9467,
+ 0x59cf0b4af262da23, 0xe7e9929af18194b2, 0x9df2644e33eb0178, 0xde4122d6f0671938,
+ 0xf005786c07f4800b, 0xb1fc9d254b5d1039, 0x0bf1088631f6dd7b, 0x665623f0a4b8f0c7,
+ 0x60f0113a9187db7c, 0xfd7cceda4f0d23a6, 0x26c01e9d89955940, 0x33afa1dfc0f5a6a0,
+ 0xeb77daf215e9283c, 0xc7575214bf85edb4, 0xeb0d804bf297e616, 0x84bff4ffd564f747,
+ 0xc4ac33189246f620, 0x43ef61213ecc1005, 0xcbbb0dea6cd96acd, 0x8ed27abfa8cfcb05,
+ 0x543b61529cb996b6, 0xa5f987ca41ea5e59, 0x3c50e0ac5254cb7a, 0x4192b0446c06d1e6,
+ 0x3e86592e21b45388, 0xdb766f06fcc6e51e, 0x0448ee36efe632db, 0x663c9db689253e35,
+ 0x72e0bd4985331dd4, 0xff501b5bf7d94e74, 0xe911ce758e2113a8, 0xec3a8d03a75a6ba4,
+ 0xaf6b4b72f56edc83, 0xf284857936c0a391, 0x5ba6feff407d46f4, 0x9d689c26de9d6702,
+ 0x28c04a9083726b5d, 0x2ccf4a627a029730, 0x7b4719500d4f0c71, 0x76470a9a7da250a8,
+ 0xcc48409404a1c890, 0xccefbdc7ec9a8055, 0xe0db91bff3cc42d3, 0x0532436426141254,
+ 0xf2ee9325e6f0ff0b, 0x149c20a5fbb28d9d, 0xe71624cd8d2d14d4, 0x8f01d4dc8cc2dd77,
+ 0x29cf409b333015b7, 0xba8bebd211884dd1, 0xc3396635e8c8db1d, 0x8ed0f6208d0528b8,
+ 0x0d90b43fdd0ee334, 0xd73c9a3333a044c7, 0xa2595cd208dbdc38, 0xae93cb264f940c09,
+ 0x8e0538d8afb07a97, 0x19115ec881385ba2, 0xa886f9e6a8039c6a, 0xcd5d62147ce3ecac,
+ 0xaecdf9e0bb4969f7, 0x2ddd631c53dcad10, 0x73ad1c97b3412054, 0xb08915fa2722efc6,
+ 0x97966047e5067eb0, 0x337f1675ed91445c, 0xb3a833d150b96a0d, 0x5940a98fe35e5e2e,
+ 0xfd03cc354ed0d8ff, 0x4e65b98291a8644a, 0x14a259f2852a60b2, 0x7648e3478c1e8e5f,
+ 0xbc0fbef6d9a919b4, 0xbec4302081346cf1, 0x57d2ce7aa1c7c511, 0x234c209d8f4e1ac3,
+ 0x87cf80cc933ce443, 0x7c262c616931e94e, 0xc5e33b049cf9eddf, 0x1a80790ed03ae51b,
+ 0xf2e8b9494f7220cf, 0x124cb59c14fff3ff, 0xa8a06cbfdb86ce18, 0x9068ef1f80b37653,
+ 0x0c55417b8d90338f, 0xcd579a523f6bcd30, 0xa31bfe2476a8d2a9, 0x1f8d142208094223,
+ 0x332dc40a5203cfad, 0xf8792fe5b2d33b4c, 0x443bd9668bf9461e, 0xc9019db0ace1409e,
+ 0x781bea919a113e8b, 0xb0f11d866abfbeec, 0xcfe139a60db0c26a, 0x869ab8721e6aa39e,
+ 0xdb48a4977717837a, 0x588a5ff151065b18, 0xe4a251ea0028864d, 0x7f0e43ba408a77c3,
+ 0x65f66dd50a536135, 0x6f49e934d9331c3e, 0xb8d742e0f0fa6b09, 0xe4e9b272deca2348,
+ 0xaee132ff902f773c, 0x43f658f7c2a0c90a, 0x28cb4dbc76cc53ea, 0x7d92253aa99ac39b,
+ 0x4fea3d832370baab, 0xb29e36936e51d78e, 0xea10778712321064, 0xff4f21f8ef274be2,
+ 0x84eff18ddfa0933f, 0xd0ec6a9f86c758a0, 0xaf82e5973c431ae0, 0x352023c00c045425,
+ 0xad34d7bc4a2f8961, 0xbdb4a02a24d4dee0, 0x354a4846d97447cf, 0x331a8b944d5bc19f,
+ 0x5ce04f8e17909035, 0x6497581bad8f4aab, 0x07c503bba647111e, 0x85f412ba78e1f7ff,
+ 0x7f3b920fd20f4cff, 0x424e1a9a4ce34e2f, 0x3035e2d62e1b9f0a, 0xef63114bff7b729a,
+ 0xe86a05889ab6bb60, 0xee0830cf095585a1, 0x4a54f7fa47d9c94b, 0x17daeece9fcb556a,
+ 0xc506d3f391834c6f, 0xb3f24be362e1af64, 0xc435e4e23608efdd, 0xeeba9caaa4cc1768,
+ 0x5a71f306daddc22d, 0x18e5205f41eba1a0, 0x7b29b4d1f6610925, 0x065cb65a0258d9a9,
+ 0x3e5ac8faa9fd1f95, 0x3b362362c1ea0470, 0xce0e4f6434db7a2e, 0xf327341098de52f2,
+ 0xcfca3b9e2a1992c3, 0x7483bf9401233e41, 0xbafbac531c6f9281, 0x4b52dd71b2c106f8,
+ 0xdf73b66e50b5a1f7, 0x237aec0202a20283, 0x23dd5be23dffdf2b, 0xea9730731ee122ef,
+ 0x5cb3f846014fbcd3, 0xc3b21c8ffdce9201, 0x06a99a02f91a8760, 0x721a81fa8fd7b7a3,
+ 0x6aafcdddc53cbcd8, 0xd03b464005a93bcc, 0x8212edc1b1669dcb, 0x71f4c31364c31bc7,
+ 0xfeeec0eba8772307, 0x1948d00a13d88cf1, 0x19064fd6d943ada8, 0x4ec8d31722697bfd,
+ 0x596d9a953a516609, 0xc4cb4bff53507da2, 0x1d59f3c5be36e4ca, 0xe5b4fc5bf6044c9b,
+ 0x1bb74e052232f735, 0x04e8a0db611ddd5d, 0x8d04eaa009b421bf, 0xa7878ae0ac0e6d58,
+ 0x28c1030217cab2b3, 0x827943767e56a883, 0x28fce5fa02d22809, 0xb30c322fffc8c58e,
+ 0x1ca5a6a9f8066c5b, 0xb24db5f1462b2513, 0x02f653b89b7e5f6c, 0xe31f8fb5d5f78eee,
+ 0x266acc514ed93501, 0x936879d1c6fddcc4, 0xcd51be3636af1952, 0x3fdbb6fc332c78c8,
+ 0x9eb656379fa73094, 0x056146cc92fa0f96, 0xed6c4f1836c027c3, 0x021e0bb5d2113f2a,
+ 0x8983e42ec1c626b3, 0x73ea9bc6513ad9c9, 0x0c904903b24f4247, 0xacbac1e6243e2525,
+ 0x0b1069a0c230fb06, 0x77d709fca3fc1ce5, 0x87ad0f65020947e6, 0x555302641c53f4e6,
+ 0x65ea87871fa9aaee, 0x58aaf4ecc1067bb4, 0x1a66c48cc4c65b3f, 0xca96aca48b2ea969,
+ 0xa68eb70bad14de2b, 0x5ccdb3d7e00a6f6e, 0xe178fbfec73fe72f, 0x2b63d6a16b83e890,
+ 0x32fdb7a5330fbae0, 0x2ab5803c8d1bf32c, 0xda838388c1527c94, 0x16a50bdc4de24acb,
+ 0xe561301f134c074a, 0xd7ae63d2816b4db1, 0x036aabd4df0dd741, 0xc5e0db8783435b9d,
+ 0x9c4386cf0a07f3b2, 0x6a72ac1aa56a13a1, 0x299bbdb04bb20a23, 0x138c1018fda16b81,
+ 0x0e354f0b3bda49df, 0x9f4c295b23127437, 0xd133ceb2bd561341, 0xd8b4bfd5a526ac29,
+ 0xcdd0a70ddc1c7bbd, 0x81dce595bf572225, 0x1c6f925c05f6efd7, 0x8ae5097553856ea0,
+ 0x3aabeaeef248f60d, 0xd9005809d19a69e2, 0x2a3a1a314311cc27, 0x89bb2dc76b2b624a,
+ 0x50a2a95d0412e289, 0x9def8df564e68581, 0xf49010a9b2e2ea5c, 0x8602ae175d9ff3f0,
+ 0xbf037e245369a618, 0x8038164365f6e2b5, 0xe2e1f6163b4e8d08, 0x8df9314914f0857e}};
+
+} // namespace parquet::internal
diff --git a/cpp/src/parquet/column_writer.cc b/cpp/src/parquet/column_writer.cc
--- a/cpp/src/parquet/column_writer.cc
+++ b/cpp/src/parquet/column_writer.cc
@@ -45,6 +45,7 @@
#include "arrow/util/rle_encoding_internal.h"
#include "arrow/util/type_traits.h"
#include "arrow/visit_array_inline.h"
+#include "parquet/chunker_internal.h"
#include "parquet/column_page.h"
#include "parquet/encoding.h"
#include "parquet/encryption/encryption_internal.h"
@@ -764,6 +765,12 @@ class ColumnWriterImpl {
compressor_temp_buffer_ =
std::static_pointer_cast<ResizableBuffer>(AllocateBuffer(allocator_, 0));
}
+ if (properties_->content_defined_chunking_enabled()) {
+ auto cdc_options = properties_->content_defined_chunking_options();
+ content_defined_chunker_.emplace(level_info_, cdc_options.min_chunk_size,
+ cdc_options.max_chunk_size,
+ cdc_options.norm_level);
+ }
}
virtual ~ColumnWriterImpl() = default;
@@ -895,6 +902,8 @@ class ColumnWriterImpl {
std::vector<std::unique_ptr<DataPage>> data_pages_;
+ std::optional<internal::ContentDefinedChunker> content_defined_chunker_;
+
private:
void InitSinks() {
definition_levels_sink_.Rewind(0);
@@ -1269,6 +1278,16 @@ class TypedColumnWriterImpl : public ColumnWriterImpl,
int64_t WriteBatch(int64_t num_values, const int16_t* def_levels,
const int16_t* rep_levels, const T* values) override {
+ if (ARROW_PREDICT_FALSE(properties_->content_defined_chunking_enabled())) {
+ throw ParquetException(
+ "Content-defined chunking is not supported in WriteBatch() or "
+ "WriteBatchSpaced(), use WriteArrow() instead.");
+ }
+ return WriteBatchInternal(num_values, def_levels, rep_levels, values);
+ }
+
+ int64_t WriteBatchInternal(int64_t num_values, const int16_t* def_levels,
+ const int16_t* rep_levels, const T* values) {
// We check for DataPage limits only after we have inserted the values. If a user
// writes a large number of values, the DataPage size can be much above the limit.
// The purpose of this chunking is to bound this. Even if a user writes large number
@@ -1301,6 +1320,18 @@ class TypedColumnWriterImpl : public ColumnWriterImpl,
void WriteBatchSpaced(int64_t num_values, const int16_t* def_levels,
const int16_t* rep_levels, const uint8_t* valid_bits,
int64_t valid_bits_offset, const T* values) override {
+ if (ARROW_PREDICT_FALSE(properties_->content_defined_chunking_enabled())) {
+ throw ParquetException(
+ "Content-defined chunking is not supported in WriteBatch() or "
+ "WriteBatchSpaced(), use WriteArrow() instead.");
+ }
+ return WriteBatchSpacedInternal(num_values, def_levels, rep_levels, valid_bits,
+ valid_bits_offset, values);
+ }
+
+ void WriteBatchSpacedInternal(int64_t num_values, const int16_t* def_levels,
+ const int16_t* rep_levels, const uint8_t* valid_bits,
+ int64_t valid_bits_offset, const T* values) {
// Like WriteBatch, but for spaced values
int64_t value_offset = 0;
auto WriteChunk = [&](int64_t offset, int64_t batch_size, bool check_page) {
@@ -1357,13 +1388,47 @@ class TypedColumnWriterImpl : public ColumnWriterImpl,
bits_buffer_->ZeroPadding();
}
- if (leaf_array.type()->id() == ::arrow::Type::DICTIONARY) {
- return WriteArrowDictionary(def_levels, rep_levels, num_levels, leaf_array, ctx,
- maybe_parent_nulls);
+ if (ARROW_PREDICT_FALSE(properties_->content_defined_chunking_enabled())) {
+ DCHECK(content_defined_chunker_.has_value());
+ auto chunks = content_defined_chunker_->GetChunks(def_levels, rep_levels,
+ num_levels, leaf_array);
+ for (size_t i = 0; i < chunks.size(); i++) {
+ auto chunk = chunks[i];
+ auto chunk_array = leaf_array.Slice(chunk.value_offset);
+ auto chunk_def_levels = AddIfNotNull(def_levels, chunk.level_offset);
+ auto chunk_rep_levels = AddIfNotNull(rep_levels, chunk.level_offset);
+ if (leaf_array.type()->id() == ::arrow::Type::DICTIONARY) {
+ ARROW_CHECK_OK(WriteArrowDictionary(chunk_def_levels, chunk_rep_levels,
+ chunk.levels_to_write, *chunk_array, ctx,
+ maybe_parent_nulls));
+ } else {
+ ARROW_CHECK_OK(WriteArrowDense(chunk_def_levels, chunk_rep_levels,
+ chunk.levels_to_write, *chunk_array, ctx,
+ maybe_parent_nulls));
+ }
+ bool is_last_chunk = i == (chunks.size() - 1);
+ if (num_buffered_values_ > 0 && !is_last_chunk) {
+ // Explicitly add a new data page according to the content-defined chunk
+ // boundaries. This way the same chunks will have the same byte-sequence
+ // in the resulting file, which can be identified by content addressible
+ // storage.
+ // Note that the last chunk doesn't trigger a new data page in order to
+ // allow subsequent WriteArrow() calls to continue writing to the same
+ // data page, the chunker's state is not being reset after the last chunk.
+ AddDataPage();
+ }
+ }
+ return Status::OK();
} else {
- return WriteArrowDense(def_levels, rep_levels, num_levels, leaf_array, ctx,
- maybe_parent_nulls);
+ if (leaf_array.type()->id() == ::arrow::Type::DICTIONARY) {
+ return WriteArrowDictionary(def_levels, rep_levels, num_levels, leaf_array, ctx,
+ maybe_parent_nulls);
+ } else {
+ return WriteArrowDense(def_levels, rep_levels, num_levels, leaf_array, ctx,
+ maybe_parent_nulls);
+ }
}
+
END_PARQUET_CATCH_EXCEPTIONS
}
@@ -1401,11 +1466,12 @@ class TypedColumnWriterImpl : public ColumnWriterImpl,
this->descr()->schema_node()->is_required() || (array.null_count() == 0);
if (!maybe_parent_nulls && no_nulls) {
- PARQUET_CATCH_NOT_OK(WriteBatch(num_levels, def_levels, rep_levels, values));
+ PARQUET_CATCH_NOT_OK(
+ WriteBatchInternal(num_levels, def_levels, rep_levels, values));
} else {
- PARQUET_CATCH_NOT_OK(WriteBatchSpaced(num_levels, def_levels, rep_levels,
- data.null_bitmap_data(), data.offset(),
- values));
+ PARQUET_CATCH_NOT_OK(WriteBatchSpacedInternal(num_levels, def_levels, rep_levels,
+ data.null_bitmap_data(),
+ data.offset(), values));
}
return Status::OK();
}
@@ -1968,11 +2034,11 @@ Status TypedColumnWriterImpl<ParquetType>::WriteArrowSerialize(
bool no_nulls =
this->descr()->schema_node()->is_required() || (array.null_count() == 0);
if (!maybe_parent_nulls && no_nulls) {
- PARQUET_CATCH_NOT_OK(WriteBatch(num_levels, def_levels, rep_levels, buffer));
+ PARQUET_CATCH_NOT_OK(WriteBatchInternal(num_levels, def_levels, rep_levels, buffer));
} else {
- PARQUET_CATCH_NOT_OK(WriteBatchSpaced(num_levels, def_levels, rep_levels,
- array.null_bitmap_data(), array.offset(),
- buffer));
+ PARQUET_CATCH_NOT_OK(WriteBatchSpacedInternal(num_levels, def_levels, rep_levels,
+ array.null_bitmap_data(),
+ array.offset(), buffer));
}
return Status::OK();
}
@@ -2096,7 +2162,8 @@ Status TypedColumnWriterImpl<Int32Type>::WriteArrowDense(
const ::arrow::Array& array, ArrowWriteContext* ctx, bool maybe_parent_nulls) {
switch (array.type()->id()) {
case ::arrow::Type::NA: {
- PARQUET_CATCH_NOT_OK(WriteBatch(num_levels, def_levels, rep_levels, nullptr));
+ PARQUET_CATCH_NOT_OK(
+ WriteBatchInternal(num_levels, def_levels, rep_levels, nullptr));
} break;
WRITE_SERIALIZE_CASE(INT8)
WRITE_SERIALIZE_CASE(UINT8)
diff --git a/cpp/src/parquet/properties.h b/cpp/src/parquet/properties.h
--- a/cpp/src/parquet/properties.h
+++ b/cpp/src/parquet/properties.h
@@ -245,6 +245,44 @@ class PARQUET_EXPORT ColumnProperties {
bool page_index_enabled_;
};
+// EXPERIMENTAL: Options for content-defined chunking.
+///
+/// Content-defined chunking is an experimental feature that optimizes parquet
+/// files for content addressable storage (CAS) systems by writing data pages
+/// according to content-defined chunk boundaries. This allows for more
+/// efficient deduplication of data across files, hence more efficient network
+/// transfers and storage.
+/// Each content-defined chunk is written as a separate parquet data page. The
+/// following options control the chunks' size and the chunking process. Note
+/// that the chunk size is calculated based on the logical value of the data,
+/// before any encoding or compression is applied.
+struct PARQUET_EXPORT CdcOptions {
+ /// Minimum chunk size in bytes, default is 256 KiB
+ /// The rolling hash will not be updated until this size is reached for each chunk.
+ /// Note that all data sent through the hash function is counted towards the chunk
+ /// size, including definition and repetition levels if present.
+ int64_t min_chunk_size = 256 * 1024;
+ /// Maximum chunk size in bytes, default is 1024 KiB
+ /// The chunker will create a new chunk whenever the chunk size exceeds this value.
+ /// Note that the parquet writer has a related `pagesize` property that controls
+ /// the maximum size of a parquet data page after encoding. While setting
+ /// `pagesize` to a smaller value than `max_chunk_size` doesn't affect the
+ /// chunking effectiveness, it results in more small parquet data pages.
+ int64_t max_chunk_size = 1024 * 1024;
+ /// Number of bit adjustment to the gearhash mask in order to center the chunk size
+ /// around the average size more aggressively, default is 0
+ /// Increasing the normalization level increases the probability of finding a chunk,
+ /// improving the deduplication ratio, but also increasing the number of small chunks
+ /// resulting in many small parquet data pages. The default value provides a good
+ /// balance between deduplication ratio and fragmentation.
+ /// Use norm_level=1 or norm_level=2 to reach a higher deduplication ratio at the
+ /// expense of fragmentation. Negative values can also be used to reduce the
+ /// probability of finding a chunk, resulting in larger chunks and fewer data pages.
+ /// Note that values outside [-3, 3] are not recommended, prefer using the default
+ /// value of 0 for most use cases.
+ int norm_level = 0;
+};
+
class PARQUET_EXPORT WriterProperties {
public:
class Builder {
@@ -260,7 +298,9 @@ class PARQUET_EXPORT WriterProperties {
created_by_(DEFAULT_CREATED_BY),
store_decimal_as_integer_(false),
page_checksum_enabled_(false),
- size_statistics_level_(DEFAULT_SIZE_STATISTICS_LEVEL) {}
+ size_statistics_level_(DEFAULT_SIZE_STATISTICS_LEVEL),
+ content_defined_chunking_enabled_(false),
+ content_defined_chunking_options_({}) {}
explicit Builder(const WriterProperties& properties)
: pool_(properties.memory_pool()),
@@ -275,10 +315,40 @@ class PARQUET_EXPORT WriterProperties {
page_checksum_enabled_(properties.page_checksum_enabled()),
size_statistics_level_(properties.size_statistics_level()),
sorting_columns_(properties.sorting_columns()),
- default_column_properties_(properties.default_column_properties()) {}
+ default_column_properties_(properties.default_column_properties()),
+ content_defined_chunking_enabled_(
+ properties.content_defined_chunking_enabled()),
+ content_defined_chunking_options_(
+ properties.content_defined_chunking_options()) {}
virtual ~Builder() {}
+ /// \brief EXPERIMENTAL: Use content-defined page chunking for all columns.
+ ///
+ /// Optimize parquet files for content addressable storage (CAS) systems by writing
+ /// data pages according to content-defined chunk boundaries. This allows for more
+ /// efficient deduplication of data across files, hence more efficient network
+ /// transfers and storage. The chunking is based on a rolling hash algorithm that
+ /// identifies chunk boundaries based on the actual content of the data.
+ ///
+ /// Note that only the WriteArrow() interface is supported at the moment.
+ Builder* enable_content_defined_chunking() {
+ content_defined_chunking_enabled_ = true;
+ return this;
+ }
+
+ /// \brief EXPERIMENTAL: Disable content-defined page chunking for all columns.
+ Builder* disable_content_defined_chunking() {
+ content_defined_chunking_enabled_ = false;
+ return this;
+ }
+
+ /// \brief EXPERIMENTAL: Specify content-defined chunking options, see CdcOptions.
+ Builder* content_defined_chunking_options(const CdcOptions& options) {
+ content_defined_chunking_options_ = options;
+ return this;
+ }
+
/// Specify the memory pool for the writer. Default default_memory_pool.
Builder* memory_pool(MemoryPool* pool) {
pool_ = pool;
@@ -701,7 +771,8 @@ class PARQUET_EXPORT WriterProperties {
pagesize_, version_, created_by_, page_checksum_enabled_,
size_statistics_level_, std::move(file_encryption_properties_),
default_column_properties_, column_properties, data_page_version_,
- store_decimal_as_integer_, std::move(sorting_columns_)));
+ store_decimal_as_integer_, std::move(sorting_columns_),
+ content_defined_chunking_enabled_, content_defined_chunking_options_));
}
private:
@@ -730,6 +801,9 @@ class PARQUET_EXPORT WriterProperties {
std::unordered_map<std::string, bool> dictionary_enabled_;
std::unordered_map<std::string, bool> statistics_enabled_;
std::unordered_map<std::string, bool> page_index_enabled_;
+
+ bool content_defined_chunking_enabled_;
+ CdcOptions content_defined_chunking_options_;
};
inline MemoryPool* memory_pool() const { return pool_; }
@@ -754,6 +828,13 @@ class PARQUET_EXPORT WriterProperties {
inline bool page_checksum_enabled() const { return page_checksum_enabled_; }
+ inline bool content_defined_chunking_enabled() const {
+ return content_defined_chunking_enabled_;
+ }
+ inline CdcOptions content_defined_chunking_options() const {
+ return content_defined_chunking_options_;
+ }
+
inline SizeStatisticsLevel size_statistics_level() const {
return size_statistics_level_;
}
@@ -856,7 +937,8 @@ class PARQUET_EXPORT WriterProperties {
const ColumnProperties& default_column_properties,
const std::unordered_map<std::string, ColumnProperties>& column_properties,
ParquetDataPageVersion data_page_version, bool store_short_decimal_as_integer,
- std::vector<SortingColumn> sorting_columns)
+ std::vector<SortingColumn> sorting_columns, bool content_defined_chunking_enabled,
+ CdcOptions content_defined_chunking_options)
: pool_(pool),
dictionary_pagesize_limit_(dictionary_pagesize_limit),
write_batch_size_(write_batch_size),
@@ -871,7 +953,9 @@ class PARQUET_EXPORT WriterProperties {
file_encryption_properties_(file_encryption_properties),
sorting_columns_(std::move(sorting_columns)),
default_column_properties_(default_column_properties),
- column_properties_(column_properties) {}
+ column_properties_(column_properties),
+ content_defined_chunking_enabled_(content_defined_chunking_enabled),
+ content_defined_chunking_options_(content_defined_chunking_options) {}
MemoryPool* pool_;
int64_t dictionary_pagesize_limit_;
@@ -891,6 +975,9 @@ class PARQUET_EXPORT WriterProperties {
ColumnProperties default_column_properties_;
std::unordered_map<std::string, ColumnProperties> column_properties_;
+
+ bool content_defined_chunking_enabled_;
+ CdcOptions content_defined_chunking_options_;
};
PARQUET_EXPORT const std::shared_ptr<WriterProperties>& default_writer_properties();
diff --git a/cpp/src/parquet/schema.cc b/cpp/src/parquet/schema.cc
--- a/cpp/src/parquet/schema.cc
+++ b/cpp/src/parquet/schema.cc
@@ -28,7 +28,7 @@
#include "parquet/exception.h"
#include "parquet/schema_internal.h"
#include "parquet/thrift_internal.h"
-#include "parquet/windows_fixup.h"
+#include "parquet/windows_fixup.h" // for OPTIONAL
using parquet::format::SchemaElement;
diff --git a/python/pyarrow/_parquet.pxd b/python/pyarrow/_parquet.pxd
--- a/python/pyarrow/_parquet.pxd
+++ b/python/pyarrow/_parquet.pxd
@@ -462,6 +462,11 @@ cdef extern from "parquet/api/reader.h" namespace "parquet" nogil:
cdef extern from "parquet/api/writer.h" namespace "parquet" nogil:
+ cdef cppclass CdcOptions:
+ int64_t min_chunk_size
+ int64_t max_chunk_size
+ int norm_level
+
cdef cppclass WriterProperties:
cppclass Builder:
Builder* data_page_version(ParquetDataPageVersion version)
@@ -495,6 +500,9 @@ cdef extern from "parquet/api/writer.h" namespace "parquet" nogil:
Builder* disable_write_page_index()
Builder* enable_page_checksum()
Builder* disable_page_checksum()
+ Builder* enable_content_defined_chunking()
+ Builder* disable_content_defined_chunking()
+ Builder* content_defined_chunking_options(CdcOptions options)
shared_ptr[WriterProperties] build()
cdef cppclass ArrowWriterProperties:
@@ -512,7 +520,6 @@ cdef extern from "parquet/api/writer.h" namespace "parquet" nogil:
shared_ptr[ArrowWriterProperties] build()
c_bool support_deprecated_int96_timestamps()
-
cdef extern from "parquet/arrow/reader.h" namespace "parquet::arrow" nogil:
cdef cppclass FileReader:
FileReader(CMemoryPool* pool, unique_ptr[ParquetFileReader] reader)
@@ -646,6 +653,7 @@ cdef shared_ptr[WriterProperties] _create_writer_properties(
write_page_checksum=*,
sorting_columns=*,
store_decimal_as_integer=*,
+ use_content_defined_chunking=*
) except *
diff --git a/python/pyarrow/_parquet.pyx b/python/pyarrow/_parquet.pyx
--- a/python/pyarrow/_parquet.pyx
+++ b/python/pyarrow/_parquet.pyx
@@ -1972,12 +1972,14 @@ cdef shared_ptr[WriterProperties] _create_writer_properties(
write_page_index=False,
write_page_checksum=False,
sorting_columns=None,
- store_decimal_as_integer=False) except *:
+ store_decimal_as_integer=False,
+ use_content_defined_chunking=False) except *:
"""General writer properties"""
cdef:
shared_ptr[WriterProperties] properties
WriterProperties.Builder props
+ CdcOptions cdc_options
# data_page_version
@@ -2101,6 +2103,7 @@ cdef shared_ptr[WriterProperties] _create_writer_properties(
raise TypeError(
"'column_encoding' should be a dictionary or a string")
+ # size limits
if data_page_size is not None:
props.data_pagesize(data_page_size)
@@ -2110,6 +2113,33 @@ cdef shared_ptr[WriterProperties] _create_writer_properties(
if dictionary_pagesize_limit is not None:
props.dictionary_pagesize_limit(dictionary_pagesize_limit)
+ # content defined chunking
+
+ if use_content_defined_chunking is True:
+ props.enable_content_defined_chunking()
+ elif use_content_defined_chunking is False:
+ props.disable_content_defined_chunking()
+ elif isinstance(use_content_defined_chunking, dict):
+ defined_keys = use_content_defined_chunking.keys()
+ mandatory_keys = {"min_chunk_size", "max_chunk_size"}
+ allowed_keys = {"min_chunk_size", "max_chunk_size", "norm_level"}
+ unknown_keys = defined_keys - allowed_keys
+ missing_keys = mandatory_keys - defined_keys
+ if unknown_keys:
+ raise ValueError(
+ f"Unknown options in 'use_content_defined_chunking': {unknown_keys}")
+ if missing_keys:
+ raise ValueError(
+ f"Missing options in 'use_content_defined_chunking': {missing_keys}")
+ cdc_options.min_chunk_size = use_content_defined_chunking["min_chunk_size"]
+ cdc_options.max_chunk_size = use_content_defined_chunking["max_chunk_size"]
+ cdc_options.norm_level = use_content_defined_chunking.get("norm_level", 0)
+ props.enable_content_defined_chunking()
+ props.content_defined_chunking_options(cdc_options)
+ else:
+ raise TypeError(
+ "'use_content_defined_chunking' should be either boolean or a dictionary")
+
# encryption
if encryption_properties is not None:
@@ -2259,7 +2289,8 @@ cdef class ParquetWriter(_Weakrefable):
write_page_index=False,
write_page_checksum=False,
sorting_columns=None,
- store_decimal_as_integer=False):
+ store_decimal_as_integer=False,
+ use_content_defined_chunking=False):
cdef:
shared_ptr[WriterProperties] properties
shared_ptr[ArrowWriterProperties] arrow_properties
@@ -2294,6 +2325,7 @@ cdef class ParquetWriter(_Weakrefable):
write_page_checksum=write_page_checksum,
sorting_columns=sorting_columns,
store_decimal_as_integer=store_decimal_as_integer,
+ use_content_defined_chunking=use_content_defined_chunking
)
arrow_properties = _create_arrow_writer_properties(
use_deprecated_int96_timestamps=use_deprecated_int96_timestamps,
diff --git a/python/pyarrow/parquet/core.py b/python/pyarrow/parquet/core.py
--- a/python/pyarrow/parquet/core.py
+++ b/python/pyarrow/parquet/core.py
@@ -892,6 +892,39 @@ def _sanitize_table(table, new_schema, flavor):
- fixed_len_byte_array: for precision > 18.
As a consequence, decimal columns stored in integer types are more compact.
+use_content_defined_chunking : bool or dict, default False
+ Optimize parquet files for content addressable storage (CAS) systems by writing
+ data pages according to content-defined chunk boundaries. This allows for more
+ efficient deduplication of data across files, hence more efficient network
+ transfers and storage. The chunking is based on a rolling hash algorithm that
+ identifies chunk boundaries based on the actual content of the data.
+
+ Note that it is an experimental feature and the API may change in the future.
+
+ If set to ``True``, a default configuration is used with `min_chunk_size=256 KiB`
+ and `max_chunk_size=1024 KiB`. The chunk size distribution approximates a normal
+ distribution between `min_chunk_size` and `max_chunk_size` (sizes are accounted
+ before any Parquet encodings).
+
+ A `dict` can be passed to adjust the chunker parameters with the following keys:
+ - `min_chunk_size`: minimum chunk size in bytes, default 256 KiB
+ The rolling hash will not be updated until this size is reached for each chunk.
+ Note that all data sent through the hash function is counted towards the chunk
+ size, including definition and repetition levels if present.
+ - `max_chunk_size`: maximum chunk size in bytes, default is 1024 KiB
+ The chunker will create a new chunk whenever the chunk size exceeds this value.
+ Note that the parquet writer has a related `data_pagesize` property that controls
+ the maximum size of a parquet data page after encoding. While setting
+ `data_page_size` to a smaller value than `max_chunk_size` doesn't affect the
+ chunking effectiveness, it results in more small parquet data pages.
+ - `norm_level`: normalization level to center the chunk size around the average
+ size more aggressively, default 0
+ Increasing the normalization level increases the probability of finding a chunk,
+ improving the deduplication ratio, but also increasing the number of small chunks
+ resulting in many small parquet data pages. The default value provides a good
+ balance between deduplication ratio and fragmentation. Use norm_level=1 or
+ norm_level=2 to reach a higher deduplication ratio at the expense of
+ fragmentation.
"""
_parquet_writer_example_doc = """\