-
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 JSON reader and writer api #14313
Merged
Merged
Changes from 5 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
13e5be3
Added streams to JSON reader and writer api; added tests
shrshi c324948
code linting fix for CMakeLists
shrshi e33752e
Merge streams-io with branch-23.12
shrshi 68f80a2
Merge branch 'branch-23.12' into streams-io
shrshi 3b8e982
docstring fix; default stream update in tests
shrshi d3344c5
added copy constructor to column_to_strings_fn struct
shrshi 3b8b031
removed unused default stream headers from JSON code
shrshi 80c5a66
define/delete constructors in column_to_strings_fn struct
shrshi 1147d6b
Merge branch 'branch-23.12' into streams-io
shrshi 1d87bfc
removed unused default stream header
shrshi 12b3180
Merge branch 'streams-io' of github.com:shrshi/cudf into streams-io
shrshi bcc226c
cleanup of rmm default argument
shrshi f89d83b
Merge branch 'branch-23.12' into streams-io
shrshi b219b13
applying patch https://github.com/rapidsai/cudf/pull/14313/files#r137…
shrshi 13022da
json test cleanup; separating tests
shrshi d145e97
Merge branch 'streams-io' of github.com:shrshi/cudf into streams-io
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* 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/detail/json.hpp> | ||
#include <cudf/io/json.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> | ||
|
||
class FunctionsTest : public cudf::test::BaseFixture {}; | ||
|
||
//.dtypes(std::vector<cudf::data_type>{dtype<int32_t>(), dtype<double>()}) | ||
TEST_F(FunctionsTest, JSONreader) | ||
{ | ||
std::string data = "[1, 1.1]\n[2, 2.2]\n[3, 3.3]\n"; | ||
cudf::io::json_reader_options in_options = | ||
cudf::io::json_reader_options::builder(cudf::io::source_info{data.data(), data.size()}) | ||
.dtypes(std::vector<cudf::data_type>{cudf::data_type{cudf::type_id::INT32}, | ||
cudf::data_type{cudf::type_id::FLOAT64}}) | ||
.lines(true) | ||
.legacy(true); | ||
cudf::io::table_with_metadata result = cudf::io::read_json( | ||
in_options, cudf::test::get_default_stream(), rmm::mr::get_current_device_resource()); | ||
} | ||
|
||
TEST_F(FunctionsTest, JSONwriter) | ||
{ | ||
cudf::test::strings_column_wrapper col1{"a", "b", "c"}; | ||
cudf::test::strings_column_wrapper col2{"d", "e", "f"}; | ||
cudf::test::fixed_width_column_wrapper<int> col3{1, 2, 3}; | ||
cudf::test::fixed_width_column_wrapper<float> col4{1.5, 2.5, 3.5}; | ||
cudf::test::fixed_width_column_wrapper<int16_t> col5{{1, 2, 3}, | ||
cudf::test::iterators::nulls_at({0, 2})}; | ||
cudf::table_view tbl_view{{col1, col2, col3, col4, col5}}; | ||
cudf::io::table_metadata mt{{{"col1"}, {"col2"}, {"int"}, {"float"}, {"int16"}}}; | ||
|
||
std::vector<char> out_buffer; | ||
auto destination = cudf::io::sink_info(&out_buffer); | ||
auto options_builder = cudf::io::json_writer_options_builder(destination, tbl_view) | ||
.include_nulls(true) | ||
.metadata(mt) | ||
.lines(false) | ||
.na_rep("null"); | ||
|
||
cudf::io::write_json(options_builder.build(), | ||
cudf::test::get_default_stream(), | ||
rmm::mr::get_current_device_resource()); | ||
} |
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.
can these just be
We have the same values for the defaults. Not sure why
mr
was specified in the first place.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.
now I see the difference, cudf::get_default_stream vs cudf::test::get_default_stream
does this matter for these tests? I don't see other PRs adding the stream parameter to all tests
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.
Yes, the stream parameter can be left as is for now. For the moment,
cudf::test::get_default_stream
is only necessary for the stream tests. That may change in the future, but probably isn't worth planning for right now.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.
Thanks for the feedback! I've cleaned up the
rmm::mr
default parameter in both the calls.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.
Not sure I understand what "as is" is in @vyasr 's comment, but it looks like we might be adding the stream parameter to all API calls in the future so we might as do it now.
FWIW, the
mr
parameter can be removed fromwrite_json
calls in this file as well. I'm not blocking the PR on that, though.