diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index e2806cdfbd23..8e5e2a536922 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -323,6 +323,7 @@ add_library( src/io/functions.cpp src/io/json/json_gpu.cu src/io/json/reader_impl.cu + src/io/json/experimental/read_json.cpp src/io/orc/aggregate_orc_metadata.cpp src/io/orc/dict_enc.cu src/io/orc/orc.cpp diff --git a/cpp/include/cudf/io/json.hpp b/cpp/include/cudf/io/json.hpp index 9ccb5ec4d588..73724b995895 100644 --- a/cpp/include/cudf/io/json.hpp +++ b/cpp/include/cudf/io/json.hpp @@ -80,6 +80,9 @@ class json_reader_options { // Whether to parse dates as DD/MM versus MM/DD bool _dayfirst = false; + // Whether to use the experimental reader + bool _experimental = false; + /** * @brief Constructor from source info. * @@ -193,6 +196,13 @@ class json_reader_options { */ bool is_enabled_dayfirst() const { return _dayfirst; } + /** + * @brief Whether the experimental reader should be used. + * + * @returns true if the experimental reader will be used, false otherwise + */ + bool is_enabled_experimental() const { return _experimental; } + /** * @brief Set data types for columns to be read. * @@ -241,6 +251,13 @@ class json_reader_options { * @param val Boolean value to enable/disable day first parsing format */ void enable_dayfirst(bool val) { _dayfirst = val; } + + /** + * @brief Set whether to use the experimental reader. + * + * @param val Boolean value to enable/disable the experimental reader + */ + void enable_experimental(bool val) { _experimental = val; } }; /** @@ -348,6 +365,18 @@ class json_reader_options_builder { return *this; } + /** + * @brief Set whether to use the experimental reader. + * + * @param val Boolean value to enable/disable experimental parsing + * @return this for chaining + */ + json_reader_options_builder& experimental(bool val) + { + options._experimental = val; + return *this; + } + /** * @brief move json_reader_options member once it's built. */ diff --git a/cpp/src/io/json/experimental/read_json.cpp b/cpp/src/io/json/experimental/read_json.cpp new file mode 100644 index 000000000000..146eaf203e4e --- /dev/null +++ b/cpp/src/io/json/experimental/read_json.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2022, 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 "read_json.hpp" + +#include + +namespace cudf::io::detail::json::experimental { + +table_with_metadata read_json(host_span> sources, + json_reader_options const& reader_opts, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr) +{ + CUDF_FAIL("Not implemented"); +} + +} // namespace cudf::io::detail::json::experimental diff --git a/cpp/src/io/json/experimental/read_json.hpp b/cpp/src/io/json/experimental/read_json.hpp new file mode 100644 index 000000000000..c9f74b2cc41e --- /dev/null +++ b/cpp/src/io/json/experimental/read_json.hpp @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2022, 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. + */ + +#pragma once + +#include +#include +#include +#include + +#include +#include + +#include + +namespace cudf::io::detail::json::experimental { + +table_with_metadata read_json(host_span> sources, + json_reader_options const& reader_opts, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr); + +} diff --git a/cpp/src/io/json/reader_impl.cu b/cpp/src/io/json/reader_impl.cu index 052c51351a1b..7e6be190acb8 100644 --- a/cpp/src/io/json/reader_impl.cu +++ b/cpp/src/io/json/reader_impl.cu @@ -16,6 +16,8 @@ #include "json_gpu.hpp" +#include "experimental/read_json.hpp" + #include #include @@ -571,6 +573,10 @@ table_with_metadata read_json(std::vector>& sources, rmm::cuda_stream_view stream, rmm::mr::device_memory_resource* mr) { + if (reader_opts.is_enabled_experimental()) { + return experimental::read_json(sources, reader_opts, stream, mr); + } + CUDF_EXPECTS(not sources.empty(), "No sources were defined"); CUDF_EXPECTS(reader_opts.is_enabled_lines(), "Only JSON Lines format is currently supported.\n");