-
Notifications
You must be signed in to change notification settings - Fork 891
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
Expose streams in Parquet reader and writer APIs #14359
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
2a93126
added streams to parquet api
shrshi 1316b4b
streams for chunked operations
shrshi 7cf7cd8
Merge branch 'branch-23.12' into streams-io-parquet
shrshi e31ce02
Updated cudf default stream lookup
shrshi 75b1a74
Merge branch 'streams-io-parquet' of github.com:shrshi/cudf into stre…
shrshi 09ebf8e
compare with rmm stream directly
shrshi de09ba1
Merge branch 'branch-24.02' into streams-io-parquet
shrshi 23427a1
removed relaxation to test stream relaxation; test cleanup
shrshi f26fc66
Merge branch 'branch-24.02' into streams-io-parquet
shrshi c9fe587
oops, pre-commit check
shrshi 00fad05
Merge branch 'streams-io-parquet' of github.com:shrshi/cudf into stre…
shrshi 6d89a40
more formatting fixes
shrshi 47ed293
Merge branch 'branch-24.02' into streams-io-parquet
shrshi 79ca7b4
minor fixes
shrshi 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
/* | ||
* Copyright (c) 2023-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 <cudf/io/detail/parquet.hpp> | ||
#include <cudf/io/parquet.hpp> | ||
#include <cudf/table/table.hpp> | ||
#include <cudf/table/table_view.hpp> | ||
#include <cudf/types.hpp> | ||
|
||
#include <cudf_test/base_fixture.hpp> | ||
#include <cudf_test/column_wrapper.hpp> | ||
#include <cudf_test/default_stream.hpp> | ||
#include <cudf_test/iterator_utilities.hpp> | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
// Global environment for temporary files | ||
auto const temp_env = static_cast<cudf::test::TempDirTestEnvironment*>( | ||
::testing::AddGlobalTestEnvironment(new cudf::test::TempDirTestEnvironment)); | ||
|
||
class ParquetTest : public cudf::test::BaseFixture {}; | ||
|
||
template <typename... UniqPtrs> | ||
std::vector<std::unique_ptr<cudf::column>> make_uniqueptrs_vector(UniqPtrs&&... uniqptrs) | ||
{ | ||
std::vector<std::unique_ptr<cudf::column>> ptrsvec; | ||
(ptrsvec.push_back(std::forward<UniqPtrs>(uniqptrs)), ...); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. omg, a fold expression |
||
return ptrsvec; | ||
} | ||
|
||
cudf::table construct_table() | ||
{ | ||
constexpr auto num_rows = 10; | ||
|
||
std::vector<size_t> zeros(num_rows, 0); | ||
std::vector<size_t> ones(num_rows, 1); | ||
|
||
cudf::test::fixed_width_column_wrapper<bool> col0(zeros.begin(), zeros.end()); | ||
cudf::test::fixed_width_column_wrapper<int8_t> col1(zeros.begin(), zeros.end()); | ||
cudf::test::fixed_width_column_wrapper<int16_t> col2(zeros.begin(), zeros.end()); | ||
cudf::test::fixed_width_column_wrapper<int32_t> col3(zeros.begin(), zeros.end()); | ||
cudf::test::fixed_width_column_wrapper<float> col4(zeros.begin(), zeros.end()); | ||
cudf::test::fixed_width_column_wrapper<double> col5(zeros.begin(), zeros.end()); | ||
cudf::test::fixed_width_column_wrapper<numeric::decimal128> col6 = [&ones, num_rows] { | ||
auto col6_data = cudf::detail::make_counting_transform_iterator(0, [&](auto i) { | ||
return numeric::decimal128{ones[i], numeric::scale_type{12}}; | ||
}); | ||
return cudf::test::fixed_width_column_wrapper<numeric::decimal128>(col6_data, | ||
col6_data + num_rows); | ||
}(); | ||
cudf::test::fixed_width_column_wrapper<numeric::decimal128> col7 = [&ones, num_rows] { | ||
auto col7_data = cudf::detail::make_counting_transform_iterator(0, [&](auto i) { | ||
return numeric::decimal128{ones[i], numeric::scale_type{-12}}; | ||
}); | ||
return cudf::test::fixed_width_column_wrapper<numeric::decimal128>(col7_data, | ||
col7_data + num_rows); | ||
}(); | ||
|
||
cudf::test::lists_column_wrapper<int64_t> col8{ | ||
{1, 1}, {1, 1, 1}, {}, {1}, {1, 1, 1, 1}, {1, 1, 1, 1, 1}, {}, {1, -1}, {}, {-1, -1}}; | ||
|
||
cudf::test::structs_column_wrapper col9 = [&ones] { | ||
cudf::test::fixed_width_column_wrapper<int32_t> child_col(ones.begin(), ones.end()); | ||
return cudf::test::structs_column_wrapper{child_col}; | ||
}(); | ||
|
||
cudf::test::strings_column_wrapper col10 = [] { | ||
std::vector<std::string> col10_data(num_rows, "rapids"); | ||
return cudf::test::strings_column_wrapper(col10_data.begin(), col10_data.end()); | ||
}(); | ||
|
||
auto colsptr = make_uniqueptrs_vector(col0.release(), | ||
col1.release(), | ||
col2.release(), | ||
col3.release(), | ||
col4.release(), | ||
col5.release(), | ||
col6.release(), | ||
col7.release(), | ||
col8.release(), | ||
col9.release(), | ||
col10.release()); | ||
return cudf::table(std::move(colsptr)); | ||
} | ||
|
||
TEST_F(ParquetTest, ParquetWriter) | ||
{ | ||
auto tab = construct_table(); | ||
auto filepath = temp_env->get_temp_filepath("MultiColumn.parquet"); | ||
cudf::io::parquet_writer_options out_opts = | ||
cudf::io::parquet_writer_options::builder(cudf::io::sink_info{filepath}, tab); | ||
cudf::io::write_parquet(out_opts, cudf::test::get_default_stream()); | ||
} | ||
|
||
TEST_F(ParquetTest, ParquetReader) | ||
{ | ||
auto tab = construct_table(); | ||
auto filepath = temp_env->get_temp_filepath("MultiColumn.parquet"); | ||
cudf::io::parquet_writer_options out_opts = | ||
cudf::io::parquet_writer_options::builder(cudf::io::sink_info{filepath}, tab); | ||
cudf::io::write_parquet(out_opts, cudf::test::get_default_stream()); | ||
|
||
cudf::io::parquet_reader_options in_opts = | ||
cudf::io::parquet_reader_options::builder(cudf::io::source_info{filepath}); | ||
auto result = cudf::io::read_parquet(in_opts, cudf::test::get_default_stream()); | ||
auto meta = cudf::io::read_parquet_metadata(cudf::io::source_info{filepath}); | ||
} | ||
|
||
TEST_F(ParquetTest, ChunkedOperations) | ||
{ | ||
auto tab = construct_table(); | ||
auto filepath = temp_env->get_temp_filepath("MultiColumn.parquet"); | ||
cudf::io::chunked_parquet_writer_options out_opts = | ||
cudf::io::chunked_parquet_writer_options::builder(cudf::io::sink_info{filepath}); | ||
cudf::io::parquet_chunked_writer(out_opts, cudf::test::get_default_stream()).write(tab); | ||
|
||
auto reader = cudf::io::chunked_parquet_reader( | ||
1L << 31, | ||
cudf::io::parquet_reader_options::builder(cudf::io::source_info{filepath}), | ||
cudf::test::get_default_stream()); | ||
while (reader.has_next()) { | ||
auto chunk = reader.read_chunk(); | ||
} | ||
} |
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.
The PQ reader launches a separate kernel for many different encoding types; in theory we need to cover all those kernels. But, I think we can ignore this for now, since it requires carefully crafting tests that lead to specific encodings.
CC @nvdbaranec @etseidl for viz (short for wizardry)