Skip to content
Draft
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
1 change: 1 addition & 0 deletions ci/conda_env_cpp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pkg-config
python
rapidjson
re2
simdjson
snappy
thrift-cpp>=0.11.0
xsimd>=14.2
Expand Down
1 change: 1 addition & 0 deletions ci/docker/alpine-linux-3.22-cpp.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ RUN apk add \
re2-dev \
rsync \
samurai \
simdjson-dev \
snappy-dev \
sqlite-dev \
thrift-dev \
Expand Down
1 change: 1 addition & 0 deletions ci/docker/debian-13-cpp.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ RUN apt-get update -y -q && \
libprotobuf-dev \
libprotoc-dev \
libre2-dev \
libsimdjson-dev \
libsnappy-dev \
libsqlite3-dev \
libssl-dev \
Expand Down
1 change: 1 addition & 0 deletions ci/docker/debian-experimental-cpp.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ RUN if [ -n "${gcc}" ]; then \
libpsl-dev \
libre2-dev \
librtmp-dev \
libsimdjson-dev \
libsnappy-dev \
libsqlite3-dev \
libssh-dev \
Expand Down
1 change: 1 addition & 0 deletions ci/docker/fedora-42-cpp.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ RUN dnf update -y && \
python-pip \
rapidjson-devel \
re2-devel \
simdjson-devel \
snappy-devel \
thrift-devel \
utf8proc-devel \
Expand Down
1 change: 1 addition & 0 deletions ci/docker/ubuntu-22.04-cpp.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ RUN apt-get update -y -q && \
libradospp-dev \
libre2-dev \
librtmp-dev \
libsimdjson-dev \
libsnappy-dev \
libsqlite3-dev \
libssh-dev \
Expand Down
1 change: 1 addition & 0 deletions ci/docker/ubuntu-24.04-cpp.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ RUN apt-get update -y -q && \
libradospp-dev \
libre2-dev \
librtmp-dev \
libsimdjson-dev \
libsnappy-dev \
libsqlite3-dev \
libssh-dev \
Expand Down
1 change: 1 addition & 0 deletions ci/scripts/cpp_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ else
-DProtobuf_SOURCE=${Protobuf_SOURCE:-} \
-DRapidJSON_SOURCE=${RapidJSON_SOURCE:-} \
-Dre2_SOURCE=${re2_SOURCE:-} \
-Dsimdjson_SOURCE=${simdjson_SOURCE:-} \
-DSnappy_SOURCE=${Snappy_SOURCE:-} \
-DThrift_SOURCE=${Thrift_SOURCE:-} \
-Dutf8proc_SOURCE=${utf8proc_SOURCE:-} \
Expand Down
1 change: 1 addition & 0 deletions ci/scripts/msys2_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ case "${target}" in
packages+=("${MINGW_PACKAGE_PREFIX}-protobuf")
packages+=("${MINGW_PACKAGE_PREFIX}-rapidjson")
packages+=("${MINGW_PACKAGE_PREFIX}-re2")
packages+=("${MINGW_PACKAGE_PREFIX}-simdjson")
packages+=("${MINGW_PACKAGE_PREFIX}-snappy")
packages+=("${MINGW_PACKAGE_PREFIX}-sqlite3")
packages+=("${MINGW_PACKAGE_PREFIX}-thrift")
Expand Down
1 change: 1 addition & 0 deletions ci/scripts/r_revdepcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ apt install -y \
libprotoc-dev \
libradospp-dev \
libre2-dev \
libsimdjson-dev \
libsnappy-dev \
libssl-dev \
libthrift-dev \
Expand Down
3 changes: 2 additions & 1 deletion ci/vcpkg/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
"json": {
"description": "JSON support",
"dependencies": [
"rapidjson"
"rapidjson",
"simdjson"
]
},
"gandiva": {
Expand Down
99 changes: 99 additions & 0 deletions cpp/cmake_modules/FindsimdjsonAlt.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.

if(SimdjsonAlt_FOUND)
return()
endif()

# Try to find simdjson manually first, as some system packages have broken
# CMake configs that reference non-existent library files (e.g., Alpine Linux)
if(simdjson_ROOT)
find_path(SIMDJSON_INCLUDE_DIR
NAMES simdjson.h
PATHS ${simdjson_ROOT}
NO_DEFAULT_PATH
PATH_SUFFIXES "include")
find_library(SIMDJSON_LIBRARY
NAMES simdjson
PATHS ${simdjson_ROOT}
NO_DEFAULT_PATH
PATH_SUFFIXES "lib" "lib64")
else()
find_path(SIMDJSON_INCLUDE_DIR
NAMES simdjson.h
PATH_SUFFIXES "include")
find_library(SIMDJSON_LIBRARY
NAMES simdjson
PATH_SUFFIXES "lib" "lib64")
endif()

if(SIMDJSON_INCLUDE_DIR AND SIMDJSON_LIBRARY)
# Found via manual search
file(READ "${SIMDJSON_INCLUDE_DIR}/simdjson.h" SIMDJSON_H_CONTENT)
string(REGEX MATCH "#define SIMDJSON_VERSION \"([0-9]+\\.[0-9]+\\.[0-9]+)\""
SIMDJSON_VERSION_DEFINITION "${SIMDJSON_H_CONTENT}")
string(REGEX REPLACE "^.+ \"([0-9]+\\.[0-9]+\\.[0-9]+)\"$" "\\1" SIMDJSON_VERSION
"${SIMDJSON_VERSION_DEFINITION}")
if("${SIMDJSON_VERSION}" STREQUAL "")
set(SIMDJSON_VERSION "0.0.0")
endif()

find_package_handle_standard_args(
SimdjsonAlt
REQUIRED_VARS SIMDJSON_INCLUDE_DIR SIMDJSON_LIBRARY
VERSION_VAR SIMDJSON_VERSION)

if(SimdjsonAlt_FOUND)
if(WIN32 AND "${SIMDJSON_INCLUDE_DIR}" MATCHES "^/")
# MSYS2
execute_process(COMMAND "cygpath" "--windows" "${SIMDJSON_INCLUDE_DIR}"
OUTPUT_VARIABLE SIMDJSON_INCLUDE_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
# Detect library type based on file extension
if("${SIMDJSON_LIBRARY}" MATCHES "\\.(so|dylib)(\\.[0-9]+)*$" OR "${SIMDJSON_LIBRARY}"
MATCHES "\\.dll$")
add_library(simdjson::simdjson SHARED IMPORTED)
else()
add_library(simdjson::simdjson STATIC IMPORTED)
endif()
set_target_properties(simdjson::simdjson
PROPERTIES IMPORTED_LOCATION "${SIMDJSON_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES
"${SIMDJSON_INCLUDE_DIR}")
endif()
return()
endif()

# Manual search failed, try CMake config mode
set(find_package_args)
if(SimdjsonAlt_FIND_VERSION)
list(APPEND find_package_args ${SimdjsonAlt_FIND_VERSION})
endif()
if(SimdjsonAlt_FIND_QUIETLY)
list(APPEND find_package_args QUIET)
endif()
find_package(simdjson ${find_package_args} CONFIG)
if(simdjson_FOUND)
set(SimdjsonAlt_FOUND TRUE)
if(NOT TARGET simdjson::simdjson)
# simdjson's CMake config should create this target, but create it if missing
if(TARGET simdjson)
add_library(simdjson::simdjson ALIAS simdjson)
endif()
endif()
endif()
74 changes: 74 additions & 0 deletions cpp/cmake_modules/ThirdpartyToolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ set(ARROW_THIRDPARTY_DEPENDENCIES
re2
Protobuf
RapidJSON
simdjson
Snappy
Substrait
Thrift
Expand Down Expand Up @@ -137,6 +138,10 @@ if(ARROW_DEPENDENCY_SOURCE STREQUAL "CONDA")
if("${GTest_SOURCE}" STREQUAL "")
set(GTest_SOURCE "AUTO")
endif()
# simdjson is not commonly available in conda, so we allow auto fallback.
if("${simdjson_SOURCE}" STREQUAL "")
set(simdjson_SOURCE "AUTO")
endif()
message(STATUS "Using CONDA_PREFIX for ARROW_PACKAGE_PREFIX: ${ARROW_PACKAGE_PREFIX}")
else()
set(ARROW_ACTUAL_DEPENDENCY_SOURCE "${ARROW_DEPENDENCY_SOURCE}")
Expand Down Expand Up @@ -209,6 +214,8 @@ macro(build_dependency DEPENDENCY_NAME)
build_protobuf()
elseif("${DEPENDENCY_NAME}" STREQUAL "RapidJSON")
build_rapidjson()
elseif("${DEPENDENCY_NAME}" STREQUAL "simdjson")
build_simdjson()
elseif("${DEPENDENCY_NAME}" STREQUAL "re2")
build_re2()
elseif("${DEPENDENCY_NAME}" STREQUAL "Snappy")
Expand Down Expand Up @@ -411,6 +418,10 @@ if(ARROW_JSON OR ARROW_FLIGHT_SQL_ODBC)
set(ARROW_WITH_RAPIDJSON ON)
endif()

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

if(ARROW_ORC OR ARROW_FLIGHT)
set(ARROW_WITH_PROTOBUF ON)
endif()
Expand Down Expand Up @@ -763,6 +774,14 @@ else()
"${THIRDPARTY_MIRROR_URL}/rapidjson-${ARROW_RAPIDJSON_BUILD_VERSION}.tar.gz")
endif()

if(DEFINED ENV{ARROW_SIMDJSON_URL})
set(SIMDJSON_SOURCE_URL "$ENV{ARROW_SIMDJSON_URL}")
else()
set_urls(SIMDJSON_SOURCE_URL
"https://github.com/simdjson/simdjson/archive/refs/tags/${ARROW_SIMDJSON_BUILD_VERSION}.tar.gz"
"${THIRDPARTY_MIRROR_URL}/simdjson-${ARROW_SIMDJSON_BUILD_VERSION}.tar.gz")
endif()

if(DEFINED ENV{ARROW_S2N_TLS_URL})
set(S2N_TLS_SOURCE_URL "$ENV{ARROW_S2N_TLS_URL}")
else()
Expand Down Expand Up @@ -2782,6 +2801,61 @@ if(ARROW_BUILD_BENCHMARKS)
FALSE)
endif()

macro(build_simdjson)
message(STATUS "Building simdjson from source")
set(SIMDJSON_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/simdjson_ep/src/simdjson_ep-install")
set(SIMDJSON_INCLUDE_DIR "${SIMDJSON_PREFIX}/include")
set(SIMDJSON_LIB_DIR "${SIMDJSON_PREFIX}/lib")

set(SIMDJSON_CMAKE_ARGS
${EP_COMMON_CMAKE_ARGS}
-DSIMDJSON_BUILD_STATIC_LIB=ON
-DSIMDJSON_DEVELOPER_MODE=OFF
-DSIMDJSON_ENABLE_THREADS=ON
-DBUILD_SHARED_LIBS=OFF
"-DCMAKE_INSTALL_PREFIX=${SIMDJSON_PREFIX}")

set(SIMDJSON_STATIC_LIB
"${SIMDJSON_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}simdjson${CMAKE_STATIC_LIBRARY_SUFFIX}"
)

externalproject_add(simdjson_ep
${EP_COMMON_OPTIONS}
PREFIX "${CMAKE_BINARY_DIR}"
URL ${SIMDJSON_SOURCE_URL}
URL_HASH "SHA256=${ARROW_SIMDJSON_BUILD_SHA256_CHECKSUM}"
CMAKE_ARGS ${SIMDJSON_CMAKE_ARGS}
BUILD_BYPRODUCTS "${SIMDJSON_STATIC_LIB}")

# The include directory must exist before it is referenced by a target.
file(MAKE_DIRECTORY "${SIMDJSON_INCLUDE_DIR}")

# Check if target already exists (may have been created by find_package with incompatible version)
if(NOT TARGET simdjson::simdjson)
add_library(simdjson::simdjson STATIC IMPORTED)
endif()
set_target_properties(simdjson::simdjson
PROPERTIES IMPORTED_LOCATION "${SIMDJSON_STATIC_LIB}"
INTERFACE_INCLUDE_DIRECTORIES
"${SIMDJSON_INCLUDE_DIR}")
add_dependencies(simdjson::simdjson simdjson_ep)

set(SIMDJSON_VENDORED TRUE)

list(APPEND ARROW_BUNDLED_STATIC_LIBS simdjson::simdjson)
endmacro()

if(ARROW_WITH_SIMDJSON)
set(ARROW_SIMDJSON_REQUIRED_VERSION "3.0.0")
resolve_dependency(simdjson
HAVE_ALT
TRUE
REQUIRED_VERSION
${ARROW_SIMDJSON_REQUIRED_VERSION}
IS_RUNTIME_DEPENDENCY
FALSE)
endif()

function(build_rapidjson)
list(APPEND CMAKE_MESSAGE_INDENT "RapidJSON: ")
message(STATUS "Building from source")
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ if(ARROW_JSON)
json/parser.cc
json/reader.cc)
foreach(ARROW_JSON_TARGET ${ARROW_JSON_TARGETS})
target_link_libraries(${ARROW_JSON_TARGET} PRIVATE RapidJSON)
target_link_libraries(${ARROW_JSON_TARGET} PRIVATE RapidJSON simdjson::simdjson)
endforeach()
else()
set(ARROW_JSON_TARGET_SHARED)
Expand Down
1 change: 1 addition & 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
object_parser_test.cc
PREFIX
"arrow-json"
EXTRA_LINK_LIBS
Expand Down
Loading
Loading