Skip to content

Commit

Permalink
Remove host_parse_nested_json. (#15674)
Browse files Browse the repository at this point in the history
This PR addresses a task from #15537 to remove the `host_parse_nested_json` code path and corresponding tests. See discussion in #15568 (comment).

Authors:
  - Bradley Dice (https://github.com/bdice)

Approvers:
  - David Wendt (https://github.com/davidwendt)
  - Mark Harris (https://github.com/harrism)

URL: #15674
  • Loading branch information
bdice authored May 6, 2024
1 parent bc3071e commit dcd0d6b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 40 deletions.
23 changes: 8 additions & 15 deletions cpp/src/io/json/nested_json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,16 @@ reduce_to_column_tree(tree_meta_t& tree,
cudf::io::parse_options parsing_options(cudf::io::json_reader_options const& options,
rmm::cuda_stream_view stream);

/** @copydoc host_parse_nested_json
/**
* @brief Parses the given JSON string and generates table from the given input.
*
* All processing is done in device memory.
*
* @param input The JSON input
* @param options Parsing options specifying the parsing behaviour
* @param stream The CUDA stream to which kernels are dispatched
* @param mr Optional, resource with which to allocate
* @return The data parsed from the given JSON input
*/
table_with_metadata device_parse_nested_json(device_span<SymbolT const> input,
cudf::io::json_reader_options const& options,
Expand Down Expand Up @@ -337,20 +344,6 @@ struct path_from_tree {
std::vector<path_rep> get_path(NodeIndexT this_col_id);
};

/**
* @brief Parses the given JSON string and generates table from the given input.
*
* @param input The JSON input
* @param options Parsing options specifying the parsing behaviour
* @param stream The CUDA stream to which kernels are dispatched
* @param mr Optional, resource with which to allocate
* @return The data parsed from the given JSON input
*/
table_with_metadata host_parse_nested_json(device_span<SymbolT const> input,
cudf::io::json_reader_options const& options,
rmm::cuda_stream_view stream,
rmm::device_async_resource_ref mr);

} // namespace detail

} // namespace cudf::io::json
1 change: 0 additions & 1 deletion cpp/src/io/json/read_json.cu
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ table_with_metadata read_json(host_span<std::unique_ptr<datasource>> sources,
cudf::device_span<char const>(reinterpret_cast<char const*>(bufview.data()), bufview.size());
stream.synchronize();
return device_parse_nested_json(buffer, reader_opts, stream, mr);
// For debug purposes, use host_parse_nested_json()
}

} // namespace cudf::io::json::detail
37 changes: 13 additions & 24 deletions cpp/tests/io/nested_json_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,15 +620,12 @@ TEST_F(JsonTest, TokenStream2)
}
}

struct JsonParserTest : public cudf::test::BaseFixture, public testing::WithParamInterface<bool> {};
INSTANTIATE_TEST_SUITE_P(IsFullGPU, JsonParserTest, testing::Bool());
struct JsonParserTest : public cudf::test::BaseFixture {};

TEST_P(JsonParserTest, ExtractColumn)
TEST_F(JsonParserTest, ExtractColumn)
{
using cuio_json::SymbolT;
bool const is_full_gpu = GetParam();
auto json_parser = is_full_gpu ? cuio_json::detail::device_parse_nested_json
: cuio_json::detail::host_parse_nested_json;
auto json_parser = cuio_json::detail::device_parse_nested_json;

// Prepare cuda stream for data transfers & kernels
auto const stream = cudf::get_default_stream();
Expand Down Expand Up @@ -867,14 +864,12 @@ TEST_F(JsonTest, PostProcessTokenStream)
}
}

TEST_P(JsonParserTest, UTF_JSON)
TEST_F(JsonParserTest, UTF_JSON)
{
// Prepare cuda stream for data transfers & kernels
auto const stream = cudf::get_default_stream();
auto mr = rmm::mr::get_current_device_resource();
bool const is_full_gpu = GetParam();
auto json_parser = is_full_gpu ? cuio_json::detail::device_parse_nested_json
: cuio_json::detail::host_parse_nested_json;
auto const stream = cudf::get_default_stream();
auto mr = rmm::mr::get_current_device_resource();
auto json_parser = cuio_json::detail::device_parse_nested_json;

// Default parsing options
cudf::io::json_reader_options default_options{};
Expand Down Expand Up @@ -924,12 +919,10 @@ TEST_P(JsonParserTest, UTF_JSON)
CUDF_EXPECT_NO_THROW(json_parser(d_utf_pass, default_options, stream, mr));
}

TEST_P(JsonParserTest, ExtractColumnWithQuotes)
TEST_F(JsonParserTest, ExtractColumnWithQuotes)
{
using cuio_json::SymbolT;
bool const is_full_gpu = GetParam();
auto json_parser = is_full_gpu ? cuio_json::detail::device_parse_nested_json
: cuio_json::detail::host_parse_nested_json;
auto json_parser = cuio_json::detail::device_parse_nested_json;

// Prepare cuda stream for data transfers & kernels
auto const stream = cudf::get_default_stream();
Expand Down Expand Up @@ -959,12 +952,10 @@ TEST_P(JsonParserTest, ExtractColumnWithQuotes)
CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_col2, parsed_col2);
}

TEST_P(JsonParserTest, ExpectFailMixStructAndList)
TEST_F(JsonParserTest, ExpectFailMixStructAndList)
{
using cuio_json::SymbolT;
bool const is_full_gpu = GetParam();
auto json_parser = is_full_gpu ? cuio_json::detail::device_parse_nested_json
: cuio_json::detail::host_parse_nested_json;
auto json_parser = cuio_json::detail::device_parse_nested_json;

// Prepare cuda stream for data transfers & kernels
auto const stream = cudf::get_default_stream();
Expand Down Expand Up @@ -1002,12 +993,10 @@ TEST_P(JsonParserTest, ExpectFailMixStructAndList)
}
}

TEST_P(JsonParserTest, EmptyString)
TEST_F(JsonParserTest, EmptyString)
{
using cuio_json::SymbolT;
bool const is_full_gpu = GetParam();
auto json_parser = is_full_gpu ? cuio_json::detail::device_parse_nested_json
: cuio_json::detail::host_parse_nested_json;
auto json_parser = cuio_json::detail::device_parse_nested_json;

// Prepare cuda stream for data transfers & kernels
auto const stream = cudf::get_default_stream();
Expand Down

0 comments on commit dcd0d6b

Please sign in to comment.