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: 1 addition & 2 deletions cpp/cmake_modules/DefineOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -599,8 +599,7 @@ takes precedence over ccache if a storage backend is configured" ON)
"Build support for encryption. Fail if OpenSSL is not found"
OFF
DEPENDS
ARROW_FILESYSTEM
ARROW_JSON)
ARROW_FILESYSTEM)

#----------------------------------------------------------------------
set_option_category("Gandiva")
Expand Down
5 changes: 2 additions & 3 deletions cpp/cmake_modules/ThirdpartyToolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@ if(ARROW_WITH_OPENTELEMETRY)
endif()

if(ARROW_PARQUET)
set(ARROW_WITH_RAPIDJSON ON)
set(ARROW_WITH_SIMDJSON ON)
set(ARROW_WITH_THRIFT ON)
endif()
Expand Down Expand Up @@ -411,11 +410,11 @@ if(ARROW_AZURE)
set(ARROW_WITH_AZURE_SDK ON)
endif()

if(ARROW_JSON OR ARROW_FLIGHT_SQL_ODBC)
if(ARROW_JSON)
set(ARROW_WITH_RAPIDJSON ON)
endif()

if(ARROW_JSON)
if(ARROW_JSON OR ARROW_FLIGHT_SQL_ODBC)
set(ARROW_WITH_SIMDJSON ON)
endif()

Expand Down
1 change: 1 addition & 0 deletions cpp/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ needs_testing = (get_option('testing').enabled()
or needs_integration
)
needs_json = get_option('json').enabled() or needs_testing
needs_simdjson = needs_json or needs_parquet
needs_brotli = get_option('brotli').enabled() or needs_fuzzing
needs_bz2 = get_option('bz2').enabled()
needs_lz4 = get_option('lz4').enabled()
Expand Down
15 changes: 13 additions & 2 deletions cpp/src/arrow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,13 @@ endif()
if(ARROW_WITH_OPENTELEMETRY)
list(APPEND ARROW_UTIL_SRCS util/tracing_internal.cc)
endif()
if(ARROW_WITH_SIMDJSON)
list(APPEND
ARROW_UTIL_SRCS
json/object_parser.cc
util/json_writer_internal.cc
util/simdjson_internal.cc)
endif()
if(ARROW_WITH_SNAPPY)
list(APPEND ARROW_UTIL_SRCS util/compression_snappy.cc)
endif()
Expand All @@ -664,6 +671,12 @@ foreach(ARROW_UTIL_TARGET ${ARROW_UTIL_TARGETS})
target_link_libraries(${ARROW_UTIL_TARGET} PRIVATE ${ARROW_XSIMD})
endforeach()

if(ARROW_WITH_SIMDJSON)
foreach(ARROW_UTIL_TARGET ${ARROW_UTIL_TARGETS})
target_link_libraries(${ARROW_UTIL_TARGET} PRIVATE arrow::simdjson)
endforeach()
endif()

if(ARROW_USE_BOOST)
foreach(ARROW_UTIL_TARGET ${ARROW_UTIL_TARGETS})
target_link_libraries(${ARROW_UTIL_TARGET} PRIVATE Boost::headers)
Expand Down Expand Up @@ -1088,8 +1101,6 @@ if(ARROW_JSON)
json/chunker.cc
json/converter.cc
json/from_string.cc
json/json_writer_internal.cc
json/object_parser.cc
json/parser.cc
json/reader.cc)
foreach(ARROW_JSON_TARGET ${ARROW_JSON_TARGETS})
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/dataset/file_json_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
#include "arrow/dataset/plan.h"
#include "arrow/dataset/test_util_internal.h"
#include "arrow/filesystem/mockfs.h"
#include "arrow/json/json_writer_internal.h"
#include "arrow/json/parser.h"
#include "arrow/testing/gtest_util.h"
#include "arrow/testing/util.h"
#include "arrow/util/json_writer_internal.h"
#include "arrow/util/logging_internal.h"

namespace arrow {
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/extension/fixed_shape_tensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

#include "arrow/array/array_nested.h"
#include "arrow/array/array_primitive.h"
#include "arrow/json/json_writer_internal.h"
#include "arrow/tensor.h"
#include "arrow/util/json_writer_internal.h"
#include "arrow/util/logging_internal.h"
#include "arrow/util/print_internal.h"
#include "arrow/util/simdjson_internal.h"
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/extension/opaque.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include <sstream>

#include "arrow/json/json_writer_internal.h"
#include "arrow/util/json_writer_internal.h"
#include "arrow/util/logging_internal.h"
#include "arrow/util/simdjson_internal.h"

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/extension/variable_shape_tensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
#include "arrow/extension/variable_shape_tensor.h"

#include "arrow/array/array_primitive.h"
#include "arrow/json/json_writer_internal.h"
#include "arrow/scalar.h"
#include "arrow/tensor.h"
#include "arrow/util/json_writer_internal.h"
#include "arrow/util/logging_internal.h"
#include "arrow/util/print_internal.h"
#include "arrow/util/simdjson_internal.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include <boost/beast/core/detail/base64.hpp>
#include "arrow/builder.h"
#include "arrow/flight/sql/odbc/odbc_impl/util.h"
#include "arrow/json/json_writer_internal.h"
#include "arrow/scalar.h"
#include "arrow/util/json_writer_internal.h"
#include "arrow/visitor.h"

using boost::beast::detail::base64::encode;
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/integration/json_integration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
#include "arrow/integration/json_internal.h"
#include "arrow/io/file.h"
#include "arrow/ipc/dictionary.h"
#include "arrow/json/json_writer_internal.h"
#include "arrow/record_batch.h"
#include "arrow/result.h"
#include "arrow/status.h"
#include "arrow/type.h"
#include "arrow/util/json_writer_internal.h"
#include "arrow/util/logging_internal.h"
#include "arrow/util/simdjson_internal.h"

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/integration/json_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include "arrow/ipc/reader.h"
#include "arrow/ipc/test_common.h"
#include "arrow/ipc/writer.h"
#include "arrow/json/json_writer_internal.h"
#include "arrow/pretty_print.h"
#include "arrow/status.h"
#include "arrow/testing/builder.h"
Expand All @@ -49,6 +48,7 @@
#include "arrow/type.h"
#include "arrow/type_fwd.h"
#include "arrow/util/io_util.h"
#include "arrow/util/json_writer_internal.h"
#include "arrow/util/simdjson_internal.h"

DEFINE_string(arrow, "", "Arrow file name");
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/integration/json_internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include "arrow/array/builder_time.h"
#include "arrow/extension_type.h"
#include "arrow/ipc/dictionary.h"
#include "arrow/json/json_writer_internal.h"
#include "arrow/record_batch.h"
#include "arrow/result.h"
#include "arrow/scalar.h"
Expand All @@ -48,6 +47,7 @@
#include "arrow/util/checked_cast.h"
#include "arrow/util/decimal.h"
#include "arrow/util/formatting.h"
#include "arrow/util/json_writer_internal.h"
#include "arrow/util/key_value_metadata.h"
#include "arrow/util/logging_internal.h"
#include "arrow/util/range.h"
Expand Down
1 change: 0 additions & 1 deletion cpp/src/arrow/json/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ add_arrow_test(test
chunker_test.cc
converter_test.cc
from_string_test.cc
json_writer_internal_test.cc
object_parser_test.cc
parser_test.cc
reader_test.cc
Expand Down
1 change: 0 additions & 1 deletion cpp/src/arrow/json/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ exc = executable(
'chunker_test.cc',
'converter_test.cc',
'from_string_test.cc',
'json_writer_internal_test.cc',
'parser_test.cc',
'reader_test.cc',
],
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/json/object_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace json {
namespace internal {

/// This class is a helper to parse a json object from a string.
/// It uses rapidjson::Document in implementation.
/// It uses simdjson in the implementation.
class ARROW_EXPORT ObjectParser {
public:
ObjectParser();
Expand Down
43 changes: 25 additions & 18 deletions cpp/src/arrow/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@
dl_dep = dependency('dl')
threads_dep = dependency('threads')

if needs_simdjson
simdjson_dep = dependency('simdjson', allow_fallback: false, required: false)

if not simdjson_dep.found()
cmake = import('cmake')
simdjson_opts = cmake.subproject_options()

simdjson_opts.add_cmake_defines({'SIMDJSON_EXCEPTIONS': 'OFF'})

simdjson_proj = cmake.subproject('simdjson', options: simdjson_opts)
simdjson_dep = simdjson_proj.dependency('simdjson')
endif
else
simdjson_dep = disabler()
endif

arrow_components = {
'arrow_array': {
'sources': [
Expand Down Expand Up @@ -224,6 +240,15 @@ arrow_util_srcs = [

arrow_util_deps = [threads_dep]

if needs_simdjson
arrow_util_srcs += [
'json/object_parser.cc',
'util/json_writer_internal.cc',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meson can still compile Parquet encryption with JSON disabled, but json/object_parser.cc remains excluded because needs_json is false. Please build ObjectParser under the same simdjson gate, otherwise this configuration still fails to link.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

'util/simdjson_internal.cc',
]
arrow_util_deps += [simdjson_dep]
endif

if needs_brotli
arrow_util_srcs += ['util/compression_brotli.cc']
arrow_util_deps += [dependency('libbrotlidec'), dependency('libbrotlienc')]
Expand Down Expand Up @@ -318,22 +343,6 @@ else
rapidjson_dep = disabler()
endif

if needs_json or needs_integration
simdjson_dep = dependency('simdjson', allow_fallback: false, required: false)

if not simdjson_dep.found()
cmake = import('cmake')
simdjson_opts = cmake.subproject_options()

simdjson_opts.add_cmake_defines({'SIMDJSON_EXCEPTIONS': 'OFF'})

simdjson_proj = cmake.subproject('simdjson', options: simdjson_opts)
simdjson_dep = simdjson_proj.dependency('simdjson')
endif
else
simdjson_dep = disabler()
endif

azure_dep = disabler()
gcs_dep = disabler()
s3_dep = disabler()
Expand Down Expand Up @@ -530,8 +539,6 @@ if needs_json
'json/chunker.cc',
'json/converter.cc',
'json/from_string.cc',
'json/json_writer_internal.cc',
'json/object_parser.cc',
'json/options.cc',
'json/parser.cc',
'json/reader.cc',
Expand Down
8 changes: 8 additions & 0 deletions cpp/src/arrow/util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ add_arrow_test(utility-test
EXTRA_LINK_LIBS
${ARROW_UTILITY_TEST_LINK_LIBS})

if(ARROW_WITH_SIMDJSON)
add_arrow_test(json-writer-internal-test
SOURCES
json_writer_internal_test.cc
EXTRA_LINK_LIBS
arrow::simdjson)
endif()

add_arrow_test(async-utility-test
SOURCES
async_generator_test.cc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.

#include "arrow/json/json_writer_internal.h"
#include "arrow/util/json_writer_internal.h"
#include "arrow/util/simdjson_internal.h"

namespace arrow::json {
Expand Down Expand Up @@ -100,21 +100,21 @@ void JsonWriter::Double(double value) {
}

Status JsonWriter::WriteValue(sj::value value) {
return internal::VisitJsonValue(
return ::arrow::internal::VisitJsonValue(
value,

[&](sj::object object) -> Status {
StartObject();

for (auto field : object) {
ARROW_ASSIGN_OR_RAISE(
auto key, internal::ResolveSimdjsonResult(field.unescaped_key(),
"Failed to get object key"));
ARROW_ASSIGN_OR_RAISE(auto key,
::arrow::internal::ResolveSimdjsonResult(
field.unescaped_key(), "Failed to get object key"));

Key(key);

ARROW_ASSIGN_OR_RAISE(auto field_value,
internal::ResolveSimdjsonResult(
::arrow::internal::ResolveSimdjsonResult(
field.value(), "Failed to get object value"));

RETURN_NOT_OK(WriteValue(field_value));
Expand All @@ -128,9 +128,9 @@ Status JsonWriter::WriteValue(sj::value value) {
StartArray();

for (auto element : array) {
ARROW_ASSIGN_OR_RAISE(
auto element_value,
internal::ResolveSimdjsonResult(element, "Failed to iterate JSON array"));
ARROW_ASSIGN_OR_RAISE(auto element_value,
::arrow::internal::ResolveSimdjsonResult(
element, "Failed to iterate JSON array"));

RETURN_NOT_OK(WriteValue(element_value));
}
Expand Down Expand Up @@ -170,7 +170,7 @@ Status JsonWriter::WriteValue(sj::value value) {
},

[&](sj::value value) -> Status {
ARROW_ASSIGN_OR_RAISE(auto raw_json, internal::ResolveSimdjsonResult(
ARROW_ASSIGN_OR_RAISE(auto raw_json, ::arrow::internal::ResolveSimdjsonResult(
simdjson::to_json_string(value),
"Failed to get raw JSON"));
RawValue(raw_json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

#include <gtest/gtest.h>

#include "arrow/json/json_writer_internal.h"
#include "arrow/testing/gtest_util.h"
#include "arrow/util/json_writer_internal.h"

namespace sj = simdjson::ondemand;

Expand Down
8 changes: 7 additions & 1 deletion cpp/src/arrow/util/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,12 @@ utility_test_srcs = [
'value_parsing_test.cc',
]

utility_test_deps = [arrow_test_dep_no_main]
if needs_simdjson
utility_test_srcs += ['json_writer_internal_test.cc']
utility_test_deps += [simdjson_dep]
endif

if host_machine.system() == 'windows'
# This manifest enables long file paths on Windows 10+
# See https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#enable-long-paths-in-windows-10-version-1607-and-later
Expand All @@ -235,7 +241,7 @@ endif
exc = executable(
'arrow-utility-test',
sources: utility_test_srcs,
dependencies: arrow_test_dep_no_main,
dependencies: utility_test_deps,
implicit_include_directories: false,
)
test('arrow-utility-test', exc)
Expand Down
Loading
Loading