-
Notifications
You must be signed in to change notification settings - Fork 4k
GH-33115: [C++] Parquet Implement crc in reading and writing Page for DATA_PAGE (v1) #14351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
570355d
Implement crc in reading and writing crc
mapleFU 7888183
adding config for crc, which default are all false
mapleFU 464b8b1
Trying to fixing compile: add `use_page_checksum_verification` in Pag…
mapleFU 6ff0aaa
Merge branch 'master' into crc32-for-data-page
mapleFU 4b2734a
[Update] vendor crc32 implements from
mapleFU 07bcec0
[Update] crc32: remove HAVE_DECLARE_OPTIMIZE macro
mapleFU 93a616a
Merge branch 'master' into crc32-for-data-page
mapleFU 02d37ad
[Update] Change crc32.h visibility
mapleFU fea3733
[Update] fmt: using clang-format to format the library
mapleFU dfe16c6
[update] fmt the whole updates
mapleFU 619debc
[Update] change swap to arrow::bit_util::ByteSwap
mapleFU c14610e
[fmt] fmt file_writer
mapleFU 3a47a74
[add] add arrow license for crc32.cc
mapleFU a20241a
Merge branch 'master' into crc32-for-data-page
mapleFU e3415a3
[Update] Update page test
mapleFU b72509e
[Update] Finish page-level testing
mapleFU 891ce6e
[Update] add test in properties
mapleFU 523799f
[ADD] add checksum failed cases
mapleFU 6024d36
[ADD] Add SerializedPageWriter test
mapleFU 01c04da
[Fix] using actual_size instead of buffer.size()
mapleFU 6d83725
[FIX] fix some previous argument passing problem
mapleFU 8165730
[ADD] adding testing for checking crc
mapleFU 6900946
remove iostream for debug, and clang-format the code
mapleFU c6cac1d
Merge branch 'master' into crc32-for-data-page
mapleFU 809ae81
[Update] update submodule to latest
mapleFU b5ef742
Merge branch 'master' into crc32-for-data-page
mapleFU 4c609cd
[Update] Resolve comment for code
mapleFU ae692fe
[Update] crc verification: check exception message
mapleFU a3da96e
[FIX] Fix compile caused by api change
mapleFU be32e3a
[Update] Update ColumnWriterTest for checksum
mapleFU 7952923
Merge branch 'master' into crc32-for-data-page
mapleFU b26c86a
Merge branch 'master' into crc32-for-data-page
mapleFU eddf8ef
[Update] Trying to eliminate duplicate code in testing
mapleFU dd71ec6
Mention checksums in supported features
pitrou b8fecfc
Move test around, check exception message
pitrou 9e3703e
Improve file reader tests
pitrou f14ad46
Merge branch 'master' into crc32-for-data-page
mapleFU e786f8b
Merge branch 'master' into crc32-for-data-page
mapleFU 951df14
rename variable: change data_page on checksum to page
mapleFU f3da672
Merge branch 'master' into crc32-for-data-page
mapleFU 9fd4ce0
Merge branch 'master' into crc32-for-data-page
mapleFU 6d3b686
Merge branch 'master' into crc32-for-data-page
mapleFU 8f57334
address comment
mapleFU 72a0108
Merge branch 'master' into crc32-for-data-page
mapleFU 300b680
add crc test
mapleFU ac9413a
add boost crc32 testing
mapleFU 17e13bd
change to use random u32
mapleFU 0fd3cdd
using vector to avoid stack overflow
mapleFU b014cb1
Merge branch 'master' into crc32-for-data-page
mapleFU File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| // 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 <cstddef> | ||
| #include <cstdint> | ||
|
|
||
| #include "arrow/util/visibility.h" | ||
|
|
||
| namespace arrow { | ||
| namespace internal { | ||
|
|
||
| /// \brief Compute the CRC32 checksum of the given data | ||
| /// | ||
| /// This function computes CRC32 with the polynomial 0x04C11DB7, | ||
| /// as used in zlib and others (note this is different from CRC32C). | ||
| /// To compute a running CRC32, pass the previous value in `prev`, | ||
| /// otherwise `prev` should be 0. | ||
| ARROW_EXPORT | ||
| uint32_t crc32(uint32_t prev, const void* data, size_t length); | ||
|
|
||
| } // namespace internal | ||
| } // namespace arrow | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| // 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 <array> | ||
| #include <cstdint> | ||
| #include <limits> | ||
| #include <memory> | ||
| #include <random> | ||
|
|
||
| #include <gtest/gtest.h> | ||
| #include <boost/crc.hpp> | ||
|
|
||
| #include "arrow/util/crc32.h" | ||
|
|
||
| namespace arrow { | ||
|
|
||
| TEST(Crc32Test, Basic) { | ||
| // use the string "123456789" in ASCII as test data. | ||
| constexpr uint32_t TEST_CRC32_RESULT = 0xCBF43926; | ||
| constexpr size_t TEST_CRC32_LENGTH = 9; | ||
| std::array<unsigned char, TEST_CRC32_LENGTH> std_data = {0x31, 0x32, 0x33, 0x34, 0x35, | ||
| 0x36, 0x37, 0x38, 0x39}; | ||
| size_t const std_data_len = sizeof(std_data) / sizeof(std_data[0]); | ||
| EXPECT_EQ(TEST_CRC32_RESULT, internal::crc32(0, &std_data[0], std_data_len)); | ||
|
|
||
| for (size_t i = 1; i < std_data_len - 1; ++i) { | ||
| uint32_t crc1 = internal::crc32(0, &std_data[0], i); | ||
| EXPECT_EQ(TEST_CRC32_RESULT, internal::crc32(crc1, &std_data[i], std_data_len - i)); | ||
| } | ||
| } | ||
|
|
||
| TEST(Crc32Test, matchesBoost32Type) { | ||
| const size_t BUFFER_SIZE = 512 * 1024 * sizeof(uint64_t); | ||
| std::vector<uint8_t> buffer; | ||
| buffer.resize(BUFFER_SIZE, 0); | ||
|
|
||
| // Populate a buffer with a deterministic pattern | ||
| // on which to compute checksums | ||
| std::random_device r; | ||
| std::seed_seq seed{r(), r(), r(), r(), r(), r(), r(), r()}; | ||
| std::mt19937 gen(seed); | ||
| // N4659 29.6.1.1 [rand.req.genl]/1e requires one of short, int, long, long long, | ||
| // unsigned short, unsigned int, unsigned long, or unsigned long long | ||
| std::uniform_int_distribution<uint32_t> dist; | ||
|
|
||
| for (size_t i = 0; i < BUFFER_SIZE; ++i) { | ||
| buffer[i] = static_cast<uint8_t>(dist(gen)); | ||
| } | ||
|
|
||
| struct TestCrcGroup { | ||
| size_t offset; | ||
| size_t length; | ||
| }; | ||
|
|
||
| // NOLINTNEXTLINE | ||
| TestCrcGroup testCrcGroups[] = { | ||
| // Zero-byte input | ||
| {0, 0}, | ||
| {8, 1}, | ||
| {8, 2}, | ||
| {8, 3}, | ||
| {8, 4}, | ||
| {8, 5}, | ||
| {8, 6}, | ||
| {8, 7}, | ||
| {9, 1}, | ||
| {10, 2}, | ||
| {11, 3}, | ||
| {12, 4}, | ||
| {13, 5}, | ||
| {14, 6}, | ||
| {15, 7}, | ||
| {8, 8}, | ||
| {8, 9}, | ||
| {8, 10}, | ||
| {8, 11}, | ||
| {8, 12}, | ||
| {8, 13}, | ||
| {8, 14}, | ||
| {8, 15}, | ||
| {8, 16}, | ||
| {8, 17}, | ||
| // Much larger inputs | ||
| {0, BUFFER_SIZE}, | ||
| {1, BUFFER_SIZE / 2}, | ||
| }; | ||
|
|
||
| for (TestCrcGroup group : testCrcGroups) { | ||
| uint32_t crc = internal::crc32(0, &buffer[group.offset], group.length); | ||
| boost::crc_32_type boost_crc; | ||
| boost_crc.process_bytes(&buffer[group.offset], group.length); | ||
| EXPECT_EQ(boost_crc.checksum(), crc); | ||
| } | ||
| } | ||
|
|
||
| } // namespace arrow |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.