-
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
Added streams to CSV reader and writer api #14340
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
aa28cd8
Added streams to CSV reader and writer api
shrshi 147c4dc
Merge branch 'branch-23.12' into streams-io-csv
karthikeyann 15a8fb4
Merge branch 'branch-23.12' into streams-io-csv
shrshi 5b39b59
Merge branch 'streams-io-csv' of github.com:shrshi/cudf into streams-…
shrshi 102ee92
Merge branch 'branch-23.12' into streams-io-csv
shrshi 75076fd
simplified tests
shrshi c09d78f
Merge branch 'streams-io-csv' of github.com:shrshi/cudf into streams-…
shrshi 656a5b6
code comment cleanup; initialization style
shrshi c5011c0
Merge branch 'branch-23.12' into streams-io-csv
shrshi 08ac4a2
default mr usage; test header cleanup
shrshi 751936d
Merge branch 'streams-io-csv' of github.com:shrshi/cudf into streams-…
shrshi 413bfb6
Merge branch 'branch-23.12' into streams-io-csv
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
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,102 @@ | ||
/* | ||
* Copyright (c) 2023, 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/csv.hpp> | ||
#include <cudf/io/detail/csv.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> | ||
|
||
auto const temp_env = static_cast<cudf::test::TempDirTestEnvironment*>( | ||
::testing::AddGlobalTestEnvironment(new cudf::test::TempDirTestEnvironment)); | ||
|
||
class CSVTest : public cudf::test::BaseFixture {}; | ||
|
||
TEST_F(CSVTest, CSVWriter) | ||
{ | ||
constexpr auto num_rows = 10; | ||
|
||
std::vector<size_t> zeros(num_rows, 0); | ||
std::vector<size_t> ones(num_rows, 1); | ||
auto col6_data = cudf::detail::make_counting_transform_iterator(0, [&](auto i) { | ||
return numeric::decimal128{ones[i], numeric::scale_type{12}}; | ||
}); | ||
auto col7_data = cudf::detail::make_counting_transform_iterator(0, [&](auto i) { | ||
return numeric::decimal128{ones[i], numeric::scale_type{-12}}; | ||
}); | ||
|
||
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(col6_data, col6_data + num_rows); | ||
cudf::test::fixed_width_column_wrapper<numeric::decimal128> col7(col7_data, col7_data + num_rows); | ||
|
||
std::vector<std::string> col8_data(num_rows, "rapids"); | ||
cudf::test::strings_column_wrapper col8(col8_data.begin(), col8_data.end()); | ||
|
||
cudf::table_view tab({col0, col1, col2, col3, col4, col5, col6, col7, col8}); | ||
|
||
auto const filepath = temp_env->get_temp_dir() + "multicolumn.csv"; | ||
auto w_options = cudf::io::csv_writer_options::builder(cudf::io::sink_info{filepath}, tab) | ||
.include_header(false) | ||
.inter_column_delimiter(','); | ||
cudf::io::write_csv(w_options.build(), cudf::test::get_default_stream()); | ||
} | ||
|
||
TEST_F(CSVTest, CSVReader) | ||
{ | ||
constexpr auto num_rows = 10; | ||
|
||
std::vector<size_t> zeros(num_rows, 0); | ||
std::vector<size_t> ones(num_rows, 1); | ||
auto col6_data = cudf::detail::make_counting_transform_iterator(0, [&](auto i) { | ||
return numeric::decimal128{ones[i], numeric::scale_type{12}}; | ||
}); | ||
auto col7_data = cudf::detail::make_counting_transform_iterator(0, [&](auto i) { | ||
return numeric::decimal128{ones[i], numeric::scale_type{-12}}; | ||
}); | ||
|
||
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(col6_data, col6_data + num_rows); | ||
cudf::test::fixed_width_column_wrapper<numeric::decimal128> col7(col7_data, col7_data + num_rows); | ||
|
||
std::vector<std::string> col8_data(num_rows, "rapids"); | ||
cudf::test::strings_column_wrapper col8(col8_data.begin(), col8_data.end()); | ||
|
||
cudf::table_view tab({col0, col1, col2, col3, col4, col5, col6, col7, col8}); | ||
|
||
auto const filepath = temp_env->get_temp_dir() + "multicolumn.csv"; | ||
auto w_options = cudf::io::csv_writer_options::builder(cudf::io::sink_info{filepath}, tab) | ||
.include_header(false) | ||
.inter_column_delimiter(','); | ||
cudf::io::write_csv(w_options.build(), cudf::test::get_default_stream()); | ||
} |
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.
Does this include changes from other PR? The additional stream parameter here and below seems unrelated to this PR.
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.
My guess is that CSV stream test is exercising this code path while no prior stream test was, so before this PR we didn't observe that there was a missing stream argument here.
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.
Yep, this change is needed for the string column in the tests -
make_strings_column
is called with the default stream otherwise.