-
Notifications
You must be signed in to change notification settings - Fork 4.3k
GH-50859: [C++][Parquet] Move JsonWriter to simdjson utilities #50990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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': [ | ||
|
|
@@ -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', | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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')] | ||
|
|
@@ -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() | ||
|
|
@@ -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', | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 { | ||
|
|
@@ -100,21 +100,21 @@ void JsonWriter::Double(double value) { | |
| } | ||
|
|
||
| Status JsonWriter::WriteValue(sj::value value) { | ||
| return internal::VisitJsonValue( | ||
| return ::arrow::internal::VisitJsonValue( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we don't need to add this prefix. |
||
| 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)); | ||
|
|
@@ -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)); | ||
| } | ||
|
|
@@ -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); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
object_parser.ccis necessary even withARROW_JSONdisabled, perhaps it should be moved outside of thejsondirectory? It seems it's Parquet-only by the way.