-
Notifications
You must be signed in to change notification settings - Fork 915
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
Add support for large string columns to Parquet reader and writer #15632
Merged
Merged
Changes from 19 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
072f7a7
first cut at reading large string columns
etseidl 1e44820
small fix for writer
etseidl 6c6c6fd
call sizes_to_offsets directly
etseidl de26d50
Merge branch 'branch-24.06' into large_strings
etseidl b67d9d3
fix delta decoders as well
etseidl 70ee8c4
add test
etseidl 2c45fdf
Merge branch 'branch-24.06' into large_strings
etseidl 7035112
fix comment
etseidl aea2691
move test to large_strings
etseidl 3b77620
get rid of leftover include
etseidl 32452d4
remove outdated comment
etseidl 8748094
Apply suggestions from code review
etseidl 5b0156d
a few tweaks
etseidl 5587bff
fix sliced offset calc as suggested
etseidl a9a2230
Merge branch 'branch-24.06' into large_strings
etseidl d465fab
formatting
etseidl 3a2e64e
reword per review suggestion
etseidl 16b94b8
fix alignment
etseidl 92c062c
make clearer how offsets are computed in the large strings case
etseidl 8f8e3ae
remove unneeded alignment specifiers
etseidl 182ce50
Merge branch 'branch-24.06' into large_strings
etseidl 9d4dcbe
Merge branch 'branch-24.06' into large_strings
vuule 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 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 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 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 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 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 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 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 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 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,53 @@ | ||
/* | ||
* Copyright (c) 2024, NVIDIA CORPORATION. | ||
* | ||
* Licensed 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 "column_buffer.hpp" | ||
|
||
#include <cudf/strings/detail/strings_children.cuh> | ||
#include <cudf/strings/detail/utilities.hpp> | ||
#include <cudf/utilities/error.hpp> | ||
|
||
namespace cudf::io::detail { | ||
|
||
std::unique_ptr<column> cudf::io::detail::inline_column_buffer::make_string_column_impl( | ||
rmm::cuda_stream_view stream) | ||
{ | ||
// if the size of _string_data is over the threshold for 64bit size_type, _data will contain | ||
// sizes rather than offsets. need special handling for that case. | ||
auto const threshold = static_cast<size_t>(strings::detail::get_offset64_threshold()); | ||
if (_string_data.size() > threshold) { | ||
if (not strings::detail::is_large_strings_enabled()) { | ||
CUDF_FAIL("String column exceeds the column size limit", std::overflow_error); | ||
} | ||
// create new offsets | ||
auto const offsets_ptr = static_cast<size_type*>(_data.data()); | ||
auto offsets_col = make_numeric_column( | ||
data_type{type_id::INT64}, size + 1, mask_state::UNALLOCATED, stream, _mr); | ||
auto d_offsets64 = offsets_col->mutable_view().template data<int64_t>(); | ||
// it's safe to call with size + 1 because _data is also sized that large | ||
cudf::detail::sizes_to_offsets(offsets_ptr, offsets_ptr + size + 1, d_offsets64, stream); | ||
return make_strings_column( | ||
size, std::move(offsets_col), std::move(_string_data), null_count(), std::move(_null_mask)); | ||
} else { | ||
// no need for copies, just transfer ownership of the data_buffers to the columns | ||
auto offsets_col = std::make_unique<column>( | ||
data_type{type_to_id<size_type>()}, size + 1, std::move(_data), rmm::device_buffer{}, 0); | ||
return make_strings_column( | ||
size, std::move(offsets_col), std::move(_string_data), null_count(), std::move(_null_mask)); | ||
} | ||
} | ||
|
||
} // namespace cudf::io::detail |
This file contains 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 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,73 @@ | ||
/* | ||
* Copyright (c) 2024, NVIDIA CORPORATION. | ||
* | ||
* Licensed 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 "large_strings_fixture.hpp" | ||
|
||
#include <cudf_test/column_utilities.hpp> | ||
#include <cudf_test/column_wrapper.hpp> | ||
#include <cudf_test/table_utilities.hpp> | ||
|
||
#include <cudf/io/parquet.hpp> | ||
#include <cudf/io/types.hpp> | ||
#include <cudf/table/table_view.hpp> | ||
|
||
namespace { | ||
|
||
cudf::test::TempDirTestEnvironment* const g_temp_env = | ||
static_cast<cudf::test::TempDirTestEnvironment*>( | ||
::testing::AddGlobalTestEnvironment(new cudf::test::TempDirTestEnvironment)); | ||
|
||
} // namespace | ||
|
||
struct ParquetStringsTest : public cudf::test::StringsLargeTest {}; | ||
|
||
TEST_F(ParquetStringsTest, ReadLargeStrings) | ||
{ | ||
// need to create a string column larger than `threshold` | ||
auto const col0 = this->long_column(); | ||
auto const column_size = cudf::strings_column_view(col0).chars_size(cudf::get_default_stream()); | ||
auto const threshold = column_size - 1; | ||
auto const expected = cudf::table_view{{col0, col0, col0}}; | ||
|
||
auto expected_metadata = cudf::io::table_input_metadata{expected}; | ||
expected_metadata.column_metadata[1].set_encoding( | ||
cudf::io::column_encoding::DELTA_LENGTH_BYTE_ARRAY); | ||
expected_metadata.column_metadata[2].set_encoding(cudf::io::column_encoding::DELTA_BYTE_ARRAY); | ||
|
||
// set smaller threshold to reduce file size and execution time | ||
setenv("LIBCUDF_LARGE_STRINGS_THRESHOLD", std::to_string(threshold).c_str(), 1); | ||
|
||
auto const filepath = g_temp_env->get_temp_filepath("ReadLargeStrings.parquet"); | ||
cudf::io::parquet_writer_options out_opts = | ||
cudf::io::parquet_writer_options::builder(cudf::io::sink_info{filepath}, expected) | ||
.compression(cudf::io::compression_type::ZSTD) | ||
.stats_level(cudf::io::STATISTICS_NONE) | ||
.metadata(expected_metadata); | ||
cudf::io::write_parquet(out_opts); | ||
|
||
cudf::io::parquet_reader_options default_in_opts = | ||
cudf::io::parquet_reader_options::builder(cudf::io::source_info{filepath}); | ||
auto const result = cudf::io::read_parquet(default_in_opts); | ||
auto const result_view = result.tbl->view(); | ||
for (auto cv : result_view) { | ||
auto const offsets = cudf::strings_column_view(cv).offsets(); | ||
EXPECT_EQ(offsets.type(), cudf::data_type{cudf::type_id::INT64}); | ||
} | ||
CUDF_TEST_EXPECT_TABLES_EQUAL(result_view, expected); | ||
|
||
// go back to normal threshold | ||
unsetenv("LIBCUDF_LARGE_STRINGS_THRESHOLD"); | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
candidate for inclusion in
StringsLargeTest
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a good idea.
I think I'd want it behave like the
CUDF_TEST_ENABLE_LARGE_STRINGS()
macro where it automatically unsets the environment variable at the end of the scope. I can do this in a follow on PR so to keep this one more focused.