39 class json_reader_options_builder;
92 std::variant<std::vector<data_type>,
93 std::map<std::string, data_type>,
94 std::map<std::string, schema_element>>
102 bool _mixed_types_as_string =
false;
105 size_t _byte_range_offset = 0;
107 size_t _byte_range_size = 0;
110 bool _dayfirst =
false;
113 bool _legacy =
false;
116 bool _keep_quotes =
false;
119 bool _normalize_single_quotes =
false;
161 std::variant<std::vector<data_type>,
162 std::map<std::string, data_type>,
163 std::map<std::string, schema_element>>
const&
197 if (_byte_range_size == 0) {
211 auto const num_columns = std::visit([](
auto const& dtypes) {
return dtypes.size(); }, _dtypes);
213 auto const max_row_bytes = 16 * 1024;
214 auto const column_bytes = 64;
215 auto const base_padding = 1024;
217 if (num_columns == 0) {
219 return max_row_bytes;
223 return base_padding + num_columns * column_bytes;
280 void set_dtypes(std::vector<data_type> types) { _dtypes = std::move(types); }
287 void set_dtypes(std::map<std::string, data_type> types) { _dtypes = std::move(types); }
294 void set_dtypes(std::map<std::string, schema_element> types) { _dtypes = std::move(types); }
398 options._dtypes = std::move(types);
410 options._dtypes = std::move(types);
422 options._dtypes = std::move(types);
434 options._compression = comp_type;
446 options._byte_range_offset = offset;
458 options._byte_range_size = size;
470 options._lines = val;
482 options._mixed_types_as_string = val;
494 options._dayfirst = val;
506 options._legacy = val;
519 options._keep_quotes = val;
532 options._normalize_single_quotes = val;
544 options._recovery_mode = val;
607 std::string _na_rep =
"";
609 bool _include_nulls =
false;
613 size_type _rows_per_chunk = std::numeric_limits<size_type>::max();
615 std::string _true_value = std::string{
"true"};
617 std::string _false_value = std::string{
"false"};
619 std::optional<table_metadata> _metadata;
671 [[nodiscard]] std::optional<table_metadata>
const&
get_metadata()
const {
return _metadata; }
678 [[nodiscard]] std::string
const&
get_na_rep()
const {
return _na_rep; }
736 void set_na_rep(std::string val) { _na_rep = std::move(val); }
795 : options{sink,
table}
807 options._table = tbl;
819 options._metadata = std::move(
metadata);
831 options._na_rep = std::move(val);
843 options._include_nulls = val;
855 options._lines = val;
867 options._rows_per_chunk = val;
879 options._true_value = std::move(val);
891 options._false_value = std::move(val);
Indicator for the logical data type of an element in a column.
Builds settings to use for read_json().
json_reader_options_builder & normalize_single_quotes(bool val)
Set whether the reader should normalize single quotes around strings.
json_reader_options_builder & keep_quotes(bool val)
Set whether the reader should keep quotes of string values.
json_reader_options_builder & dayfirst(bool val)
Set whether to parse dates as DD/MM versus MM/DD.
json_reader_options_builder & recovery_mode(json_recovery_mode_t val)
Specifies the JSON reader's behavior on invalid JSON lines.
json_reader_options_builder & lines(bool val)
Set whether to read the file as a json object per line.
json_reader_options_builder & dtypes(std::vector< data_type > types)
Set data types for columns to be read.
json_reader_options && build()
move json_reader_options member once it's built.
json_reader_options_builder & mixed_types_as_string(bool val)
Set whether to parse mixed types as a string column.
json_reader_options_builder & compression(compression_type comp_type)
Set the compression type.
json_reader_options_builder(source_info src)
Constructor from source info.
json_reader_options_builder & byte_range_size(size_type size)
Set number of bytes to read.
json_reader_options_builder & dtypes(std::map< std::string, schema_element > types)
Set data types for columns to be read.
json_reader_options_builder & legacy(bool val)
Set whether to use the legacy reader.
json_reader_options_builder & byte_range_offset(size_type offset)
Set number of bytes to skip from source start.
json_reader_options_builder()=default
Default constructor.
json_reader_options_builder & dtypes(std::map< std::string, data_type > types)
Set data types for columns to be read.
Input arguments to the read_json interface.
void enable_mixed_types_as_string(bool val)
Set whether to parse mixed types as a string column.
void set_compression(compression_type comp_type)
Set the compression type.
void set_dtypes(std::vector< data_type > types)
Set data types for columns to be read.
void enable_normalize_single_quotes(bool val)
Set whether the reader should enable normalization of single quotes around strings.
bool is_enabled_keep_quotes() const
Whether the reader should keep quotes of string values.
size_t get_byte_range_offset() const
Returns number of bytes to skip from source start.
source_info const & get_source() const
Returns source info.
void enable_legacy(bool val)
Set whether to use the legacy reader.
void set_dtypes(std::map< std::string, data_type > types)
Set data types for columns to be read.
bool is_enabled_lines() const
Whether to read the file as a json object per line.
void set_byte_range_size(size_type size)
Set number of bytes to read.
bool is_enabled_mixed_types_as_string() const
Whether to parse mixed types as a string column.
json_reader_options()=default
Default constructor.
void enable_dayfirst(bool val)
Set whether to parse dates as DD/MM versus MM/DD.
std::variant< std::vector< data_type >, std::map< std::string, data_type >, std::map< std::string, schema_element > > const & get_dtypes() const
Returns data types of the columns.
size_t get_byte_range_size_with_padding() const
Returns number of bytes to read with padding.
void set_recovery_mode(json_recovery_mode_t val)
Specifies the JSON reader's behavior on invalid JSON lines.
void enable_lines(bool val)
Set whether to read the file as a json object per line.
void enable_keep_quotes(bool val)
Set whether the reader should keep quotes of string values.
bool is_enabled_normalize_single_quotes() const
Whether the reader should normalize single quotes around strings.
compression_type get_compression() const
Returns compression format of the source.
void set_dtypes(std::map< std::string, schema_element > types)
Set data types for a potentially nested column hierarchy.
size_t get_byte_range_size() const
Returns number of bytes to read.
json_recovery_mode_t recovery_mode() const
Queries the JSON reader's behavior on invalid JSON lines.
static json_reader_options_builder builder(source_info src)
create json_reader_options_builder which will build json_reader_options.
void set_byte_range_offset(size_type offset)
Set number of bytes to skip from source start.
bool is_enabled_legacy() const
Whether the legacy reader should be used.
bool is_enabled_dayfirst() const
Whether to parse dates as DD/MM versus MM/DD.
size_t get_byte_range_padding() const
Returns number of bytes to pad when reading.
Builder to build options for writer_json()
json_writer_options_builder & include_nulls(bool val)
Enables/Disables output of nulls as 'null'.
json_writer_options_builder & table(table_view tbl)
Sets table to be written to output.
json_writer_options_builder()=default
Default constructor.
json_writer_options_builder & rows_per_chunk(int val)
Sets maximum number of rows to process for each file write.
json_writer_options_builder & true_value(std::string val)
Sets string used for values != 0 in INT8 types.
json_writer_options_builder & false_value(std::string val)
Sets string used for values == 0 in INT8 types.
json_writer_options_builder(sink_info const &sink, table_view const &table)
Constructor from sink and table.
json_writer_options_builder & na_rep(std::string val)
Sets string to used for null entries.
json_writer_options_builder & metadata(table_metadata metadata)
Sets optional metadata (with column names).
json_writer_options && build()
move json_writer_options member once it's built.
json_writer_options_builder & lines(bool val)
Enables/Disables JSON lines for records format.
Settings to use for write_json().
table_view const & get_table() const
Returns table that would be written to output.
void set_false_value(std::string val)
Sets string used for values == 0 in INT8 types.
void enable_include_nulls(bool val)
Enables/Disables output of nulls as 'null'.
bool is_enabled_include_nulls() const
Whether to output nulls as 'null'.
void enable_lines(bool val)
Enables/Disables JSON lines for records format.
void set_na_rep(std::string val)
Sets string to used for null entries.
static json_writer_options_builder builder(sink_info const &sink, table_view const &table)
Create builder to create json_writer_options.
json_writer_options()=default
Default constructor.
void set_true_value(std::string val)
Sets string used for values != 0 in INT8 types.
sink_info const & get_sink() const
Returns sink used for writer output.
void set_rows_per_chunk(size_type val)
Sets maximum number of rows to process for each file write.
std::string const & get_true_value() const
Returns string used for values != 0 in INT8 types.
void set_table(table_view tbl)
Sets table to be written to output.
std::string const & get_false_value() const
Returns string used for values == 0 in INT8 types.
bool is_enabled_lines() const
Whether to use JSON lines for records format.
size_type get_rows_per_chunk() const
Returns maximum number of rows to process for each file write.
std::optional< table_metadata > const & get_metadata() const
Returns metadata information.
std::string const & get_na_rep() const
Returns string to used for null entries.
void set_metadata(table_metadata metadata)
Sets metadata.
A set of cudf::column_view's of the same size.
A set of cudf::column's of the same size.
size_type num_rows() const noexcept
Returns the number of rows.
rmm::cuda_stream_view const get_default_stream()
Get the current default stream.
table_with_metadata read_json(json_reader_options options, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Reads a JSON dataset into a set of columns.
json_recovery_mode_t
Control the error recovery behavior of the json parser.
@ RECOVER_WITH_NULL
Recovers from an error, replacing invalid records with null.
@ FAIL
Does not recover from an error when encountering an invalid format.
compression_type
Compression algorithms.
@ AUTO
Automatically detect or select compression format.
void write_json(json_writer_options const &options, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Writes a set of columns to JSON format.
device_memory_resource * get_current_device_resource()
int32_t size_type
Row index type for columns and tables.
Allows specifying the target types for nested JSON data via json_reader_options' set_dtypes method.
data_type type
The type that this column should be converted to.
std::map< std::string, schema_element > child_types
Allows specifying this column's child columns target type.
Destination information for write interfaces.
Source information for read interfaces.
Class definitions for (mutable)_table_view
Type declarations for libcudf.