Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cpp/src/arrow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,8 @@ if(ARROW_JSON)
json/object_parser.cc
json/object_writer.cc
json/parser.cc
json/reader.cc)
json/reader.cc
json/writer.cc)
foreach(ARROW_JSON_TARGET ${ARROW_JSON_TARGETS})
target_link_libraries(${ARROW_JSON_TARGET} PRIVATE RapidJSON)
endforeach()
Expand Down
7 changes: 7 additions & 0 deletions cpp/src/arrow/json/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ add_arrow_test(test
from_string_test.cc
parser_test.cc
reader_test.cc
writer_test.cc
PREFIX
"arrow-json"
EXTRA_LINK_LIBS
Expand All @@ -33,6 +34,12 @@ add_arrow_benchmark(parser_benchmark
"arrow-json"
EXTRA_LINK_LIBS
RapidJSON)

add_arrow_benchmark(writer_benchmark
PREFIX
"arrow-json"
EXTRA_LINK_LIBS
RapidJSON)
arrow_install_all_headers("arrow/json")

# pkg-config support
Expand Down
9 changes: 9 additions & 0 deletions cpp/src/arrow/json/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ exc = executable(
'from_string_test.cc',
'parser_test.cc',
'reader_test.cc',
'writer_test.cc',
],
dependencies: [arrow_test_dep, rapidjson_dep],
)
Expand All @@ -36,6 +37,13 @@ exc = executable(
)
benchmark('arrow-json-parser-benchmark', exc)

exc = executable(
'arrow-json-writer-benchmark',
sources: ['writer_benchmark.cc'],
dependencies: [arrow_benchmark_dep, rapidjson_dep],
)
benchmark('arrow-json-writer-benchmark', exc)

install_headers(
[
'api.h',
Expand All @@ -51,6 +59,7 @@ install_headers(
'reader.h',
'test_common.h',
'type_fwd.h',
'writer.h',
],
subdir: 'arrow/json',
)
Expand Down
9 changes: 9 additions & 0 deletions cpp/src/arrow/json/options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,14 @@ ParseOptions ParseOptions::Defaults() { return ParseOptions(); }

ReadOptions ReadOptions::Defaults() { return ReadOptions(); }

WriteOptions WriteOptions::Defaults() { return WriteOptions(); }

Status WriteOptions::Validate() const {
if (ARROW_PREDICT_FALSE(batch_size < 1)) {
return Status::Invalid("WriteOptions: batch_size must be at least 1: ", batch_size);
}
return Status::OK();
}

} // namespace json
} // namespace arrow
22 changes: 22 additions & 0 deletions cpp/src/arrow/json/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@

#include <cstdint>
#include <memory>
#include <string>

#include "arrow/json/type_fwd.h"
#include "arrow/status.h"
#include "arrow/util/visibility.h"

namespace arrow {
Expand Down Expand Up @@ -70,5 +72,25 @@ struct ARROW_EXPORT ReadOptions {
static ReadOptions Defaults();
};

struct ARROW_EXPORT WriteOptions {
/// \brief Maximum number of rows processed at a time
///
/// The JSON writer converts and writes data in batches of N rows.
/// This number can impact performance.
int32_t batch_size = 1024;

/// \brief Whether to emit null values in the JSON output
///
/// If true, null values are included as JSON null.
/// If false, null values are omitted from the output entirely.
bool emit_null = false;

/// Create write options with default values
static WriteOptions Defaults();

/// \brief Test that all set options are valid
Status Validate() const;
};

} // namespace json
} // namespace arrow
Loading
Loading