diff --git a/.mapping.json b/.mapping.json
index e6eb2d43d225..5ae0cf01f806 100644
--- a/.mapping.json
+++ b/.mapping.json
@@ -744,6 +744,7 @@
"contrib/libs/re2/CMakeLists.darwin-x86_64.txt":"",
"contrib/libs/re2/CMakeLists.linux-x86_64.txt":"",
"contrib/libs/re2/CMakeLists.txt":"",
+ "contrib/libs/simdjson/CMakeLists.txt":"",
"contrib/libs/snappy/CMakeLists.darwin-arm64.txt":"",
"contrib/libs/snappy/CMakeLists.darwin-x86_64.txt":"",
"contrib/libs/snappy/CMakeLists.linux-x86_64.txt":"",
diff --git a/contrib/clickhouse/includes/configs/clickhouse_config.h b/contrib/clickhouse/includes/configs/clickhouse_config.h
index 1967e8ce7d59..ee2681fed3b8 100644
--- a/contrib/clickhouse/includes/configs/clickhouse_config.h
+++ b/contrib/clickhouse/includes/configs/clickhouse_config.h
@@ -12,7 +12,7 @@
#define USE_CASSANDRA 0
#define USE_SENTRY 0
#define USE_GRPC 0
-#define USE_SIMDJSON 0
+#define USE_SIMDJSON 1
#define USE_RAPIDJSON 1
#define USE_DATASKETCHES 0
#define USE_YAML_CPP 0
diff --git a/contrib/clickhouse/src/CMakeLists.txt b/contrib/clickhouse/src/CMakeLists.txt
index b7484cd30fd7..3ab1c9d2764b 100644
--- a/contrib/clickhouse/src/CMakeLists.txt
+++ b/contrib/clickhouse/src/CMakeLists.txt
@@ -76,6 +76,7 @@ target_include_directories(contrib-clickhouse-src PRIVATE
${PROJECT_SOURCE_DIR}/contrib/libs/msgpack/include
${PROJECT_SOURCE_DIR}/contrib/libs/pdqsort
${PROJECT_SOURCE_DIR}/contrib/libs/rapidjson/include
+ ${PROJECT_SOURCE_DIR}/contrib/libs/simdjson/include
${PROJECT_SOURCE_DIR}/contrib/libs/sparsehash/src
${PROJECT_SOURCE_DIR}/contrib/libs/zstd/include
${PROJECT_SOURCE_DIR}/contrib/restricted/cityhash-1.0.2
@@ -121,6 +122,7 @@ target_link_libraries(contrib-clickhouse-src PUBLIC
libs-poco-XML
contrib-libs-rapidjson
contrib-libs-re2
+ contrib-libs-simdjson
contrib-libs-sparsehash
contrib-libs-wyhash
contrib-libs-xxhash
@@ -1784,6 +1786,7 @@ target_include_directories(contrib-clickhouse-src.global PRIVATE
${PROJECT_SOURCE_DIR}/contrib/libs/msgpack/include
${PROJECT_SOURCE_DIR}/contrib/libs/pdqsort
${PROJECT_SOURCE_DIR}/contrib/libs/rapidjson/include
+ ${PROJECT_SOURCE_DIR}/contrib/libs/simdjson/include
${PROJECT_SOURCE_DIR}/contrib/libs/sparsehash/src
${PROJECT_SOURCE_DIR}/contrib/libs/zstd/include
${PROJECT_SOURCE_DIR}/contrib/restricted/cityhash-1.0.2
@@ -1829,6 +1832,7 @@ target_link_libraries(contrib-clickhouse-src.global PUBLIC
libs-poco-XML
contrib-libs-rapidjson
contrib-libs-re2
+ contrib-libs-simdjson
contrib-libs-sparsehash
contrib-libs-wyhash
contrib-libs-xxhash
diff --git a/contrib/clickhouse/src/Common/JSONParsers/SimdJSONParser.h b/contrib/clickhouse/src/Common/JSONParsers/SimdJSONParser.h
index d582ae0de891..6aadc17315e8 100644
--- a/contrib/clickhouse/src/Common/JSONParsers/SimdJSONParser.h
+++ b/contrib/clickhouse/src/Common/JSONParsers/SimdJSONParser.h
@@ -6,7 +6,7 @@
# include
# include
# include
-# error #include
+# include
# include "ElementTypes.h"
namespace DB
diff --git a/contrib/clickhouse/src/Storages/System/StorageSystemBuildOptions.generated.cpp b/contrib/clickhouse/src/Storages/System/StorageSystemBuildOptions.generated.cpp
index b069810a13df..d2fead7c7051 100644
--- a/contrib/clickhouse/src/Storages/System/StorageSystemBuildOptions.generated.cpp
+++ b/contrib/clickhouse/src/Storages/System/StorageSystemBuildOptions.generated.cpp
@@ -37,7 +37,7 @@ const char * auto_config_build[]
"OPENSSL_VERSION", "1.1.1g",
"OPENSSL_IS_BORING_SSL", "1",
"USE_VECTORSCAN", "",
- "USE_SIMDJSON", "OFF",
+ "USE_SIMDJSON", "1",
"USE_ODBC", "",
"USE_GRPC", "",
"USE_LDAP", "",
diff --git a/contrib/clickhouse/src/ya.make b/contrib/clickhouse/src/ya.make
index 6046b525e50e..bf494b02c70f 100644
--- a/contrib/clickhouse/src/ya.make
+++ b/contrib/clickhouse/src/ya.make
@@ -45,6 +45,7 @@ PEERDIR(
contrib/libs/poco/XML
contrib/libs/rapidjson
contrib/libs/re2
+ contrib/libs/simdjson
contrib/libs/sparsehash
contrib/libs/wyhash
contrib/libs/xxhash
@@ -106,6 +107,7 @@ ADDINCL(
contrib/libs/msgpack/include
contrib/libs/pdqsort
contrib/libs/rapidjson/include
+ contrib/libs/simdjson/include
contrib/libs/sparsehash/src
contrib/libs/zstd/include
contrib/restricted/cityhash-1.0.2
diff --git a/contrib/libs/CMakeLists.linux-x86_64.txt b/contrib/libs/CMakeLists.linux-x86_64.txt
index 15863f8586a6..093d668830f9 100644
--- a/contrib/libs/CMakeLists.linux-x86_64.txt
+++ b/contrib/libs/CMakeLists.linux-x86_64.txt
@@ -66,6 +66,7 @@ add_subdirectory(fmath)
add_subdirectory(libdivide)
add_subdirectory(metrohash)
add_subdirectory(msgpack)
+add_subdirectory(simdjson)
add_subdirectory(wyhash)
add_subdirectory(h3)
add_subdirectory(liburing)
diff --git a/contrib/libs/simdjson/AUTHORS b/contrib/libs/simdjson/AUTHORS
new file mode 100644
index 000000000000..e23c6beb4b3a
--- /dev/null
+++ b/contrib/libs/simdjson/AUTHORS
@@ -0,0 +1,4 @@
+# List of authors for copyright purposes, in no particular order
+Daniel Lemire
+Geoff Langdale
+John Keiser
diff --git a/contrib/libs/simdjson/CMakeLists.txt b/contrib/libs/simdjson/CMakeLists.txt
new file mode 100644
index 000000000000..8bd7baa1260d
--- /dev/null
+++ b/contrib/libs/simdjson/CMakeLists.txt
@@ -0,0 +1,42 @@
+# This file was generated by the YaTool build system (https://github.com/yandex/yatool),
+# from a source YaTool build configuration provided in ya.make files.
+#
+# If the repository supports both CMake and ya build configurations, please modify both of them.
+#
+# If only CMake build configuration is supported then modify only CMake files and note that only
+# simple modifications are allowed like adding source-files to targets or adding simple properties
+# like target_include_directories. These modifications will be ported to original ya.make files
+# by maintainers. Any complex modifications which can't be easily ported back to the ya build
+# system may be rejected.
+#
+# Please refer to the build instructions in the repository for more information about manual
+# changes in this file.
+
+find_package(linux-headers-generic REQUIRED)
+
+add_library(contrib-libs-simdjson)
+
+
+target_compile_options(contrib-libs-simdjson PRIVATE
+ -DSIMDJSON_AVX512_ALLOWED=1
+ -DSIMDJSON_UTF8VALIDATION=1
+ $,,-Wno-everything>
+)
+
+target_include_directories(contrib-libs-simdjson PUBLIC
+ ${PROJECT_SOURCE_DIR}/contrib/libs/simdjson/include
+)
+
+target_include_directories(contrib-libs-simdjson PRIVATE
+ ${PROJECT_SOURCE_DIR}/contrib/libs/simdjson/src
+)
+
+target_link_libraries(contrib-libs-simdjson PUBLIC
+ linux-headers-generic::linux-headers-generic
+ contrib-libs-cxxsupp
+)
+
+target_sources(contrib-libs-simdjson PRIVATE
+ ${PROJECT_SOURCE_DIR}/contrib/libs/simdjson/src/simdjson.cpp
+)
+
diff --git a/contrib/libs/simdjson/CONTRIBUTING.md b/contrib/libs/simdjson/CONTRIBUTING.md
new file mode 100644
index 000000000000..a6b70a0bf246
--- /dev/null
+++ b/contrib/libs/simdjson/CONTRIBUTING.md
@@ -0,0 +1,103 @@
+Contributing
+============
+
+The simdjson library is an open project written in C++. Contributions are invited. Contributors
+agree to the project's license.
+
+We have an extensive list of issues, and contributions toward any of these issues is invited.
+Contributions can take the form of code samples, better documentation or design ideas.
+
+In particular, the following contributions are invited:
+
+- The library is focused on performance. Well-documented performance optimization are invited.
+- Fixes to known or newly discovered bugs are always welcome. Typically, a bug fix should come with
+ a test demonstrating that the bug has been fixed.
+- The simdjson library is advanced software and maintainability and flexibility are always a
+ concern. Specific contributions to improve maintainability and flexibility are invited.
+
+We discourage the following types of contributions:
+
+- Code refactoring. We all have our preferences as to how code should be written, but unnecessary
+ refactoring can waste time and introduce new bugs. If you believe that refactoring is needed, you
+ first must explain how it helps in concrete terms. Does it improve the performance?
+- Applications of new language features for their own sake. Using advanced C++ language constructs
+ is actually a negative as it may reduce portability (to old compilers, old standard libraries and
+ systems) and reduce accessibility (to programmers that have not kept up), so it must be offsetted
+ by clear gains like performance or maintainability. When in doubt, avoid advanced C++ features
+ (beyond C++11).
+- Style formatting. In general, please abstain from reformatting code just to make it look prettier.
+ Though code formatting is important, it can also be a waste of time if several contributors try to
+ tweak the code base toward their own preference. Please do not introduce unneeded white-space
+ changes.
+
+In short, most code changes should either bring new features or better performance. We want to avoid unmotivated code changes.
+
+
+Specific rules
+----------
+
+We have few hard rules, but we have some:
+
+- Printing to standard output or standard error (`stderr`, `stdout`, `std::cerr`, `std::cout`) in the core library is forbidden. This follows from the [Writing R Extensions](https://cran.r-project.org/doc/manuals/R-exts.html) manual which states that "Compiled code should not write to stdout or stderr".
+- Calls to `abort()` are forbidden in the core library. This follows from the [Writing R Extensions](https://cran.r-project.org/doc/manuals/R-exts.html) manual which states that "Under no circumstances should your compiled code ever call abort or exit".
+- All source code files (.h, .cpp) must be ASCII.
+- All C macros introduced in public headers need to be prefixed with either `SIMDJSON_` or `simdjson_`.
+- We avoid trailing white space characters within lines. That is, your lines of code should not terminate with unnecessary spaces. Generally, please avoid making unnecessary changes to white-space characters when contributing code.
+
+Tools, tests and benchmarks are not held to these same strict rules.
+
+General Guidelines
+----------
+
+Contributors are encouraged to :
+
+- Document their changes. Though we do not enforce a rule regarding code comments, we prefer that non-trivial algorithms and techniques be somewhat documented in the code.
+- Follow as much as possible the existing code style. We do not enforce a specific code style, but we prefer consistency. We avoid contractions (isn't, aren't) in the comments.
+- Modify as few lines of code as possible when working on an issue. The more lines you modify, the harder it is for your fellow human beings to understand what is going on.
+- Tools may report "problems" with the code, but we never delegate programming to tools: if there is a problem with the code, we need to understand it. Thus we will not "fix" code merely to please a static analyzer.
+- Provide tests for any new feature. We will not merge a new feature without tests.
+- Run before/after benchmarks so that we can appreciate the effect of the changes on the performance.
+
+Pull Requests
+--------------
+
+Pull requests are always invited. However, we ask that you follow these guidelines:
+
+- It is wise to discuss your ideas first as part of an issue before you start coding. If you omit this step and code first, be prepared to have your code receive scrutiny and be dropped.
+- Users should provide a rationale for their changes. Does it improve performance? Does it add a feature? Does it improve maintainability? Does it fix a bug? This must be explicitly stated as part of the pull request. Do not propose changes based on taste or intuition. We do not delegate programming to tools: that some tool suggested a code change is not reason enough to change the code.
+ 1. When your code improves performance, please document the gains with a benchmark using hard numbers.
+ 2. If your code fixes a bug, please either fix a failing test, or propose a new test.
+ 3. Other types of changes must be clearly motivated. We openly discourage changes with no identifiable benefits.
+- Changes should be focused and minimal. You should change as few lines of code as possible. Please do not reformat or touch files needlessly.
+- New features must be accompanied by new tests, in general.
+- Your code should pass our continuous-integration tests. It is your responsibility to ensure that your proposal pass the tests. We do not merge pull requests that would break our build.
+ - An exception to this would be changes to non-code files, such as documentation and assets, or trivial changes to code, such as comments, where it is encouraged to explicitly ask for skipping a CI run using the `[skip ci]` prefix in your Pull Request title **and** in the first line of the most recent commit in a push. Example for such a commit: `[skip ci] Fixed typo in power_of_ten's docs`
+ This benefits the project in such a way that the CI pipeline is not burdened by running jobs on changes that don't change any behavior in the code, which reduces wait times for other Pull Requests that do change behavior and require testing.
+
+If the benefits of your proposed code remain unclear, we may choose to discard your code: that is not an insult, we frequently discard our own code. We may also consider various alternatives and choose another path. Again, that is not an insult or a sign that you have wasted your time.
+
+Style
+-----
+
+Our formatting style is inspired by the LLVM style.
+The simdjson library is written using the snake case: when a variable or a function is a phrase, each space is replaced by an underscore character, and the first letter of each word written in lowercase. Compile-time constants are written entirely in uppercase with the same underscore convention.
+
+Code of Conduct
+---------------
+
+Though we do not have a formal code of conduct, we will not tolerate bullying, bigotry or
+intimidation. Everyone is welcome to contribute. If you have concerns, you can raise them privately with the core team members (e.g., D. Lemire, J. Keiser).
+
+We welcome contributions from women and less represented groups. If you need help, please reach out.
+
+Consider the following points when engaging with the project:
+
+- We discourage arguments from authority: ideas are discusssed on their own merits and not based on who stated it.
+- Be mindful that what you may view as an aggression is maybe merely a difference of opinion or a misunderstanding.
+- Be mindful that a collection of small aggressions, even if mild in isolation, can become harmful.
+
+Getting Started Hacking
+-----------------------
+
+An overview of simdjson's directory structure, with pointers to architecture and design
+considerations and other helpful notes, can be found at [HACKING.md](HACKING.md).
diff --git a/contrib/libs/simdjson/HACKING.md b/contrib/libs/simdjson/HACKING.md
new file mode 100644
index 000000000000..8ee62672f7de
--- /dev/null
+++ b/contrib/libs/simdjson/HACKING.md
@@ -0,0 +1,332 @@
+
+Hacking simdjson
+================
+
+Here is wisdom about how to build, test and run simdjson from within the repository. This is mostly useful for people who plan to contribute simdjson, or maybe study the design.
+
+If you plan to contribute to simdjson, please read our [CONTRIBUTING](https://github.com/simdjson/simdjson/blob/master/CONTRIBUTING.md) guide.
+
+- [Hacking simdjson](#hacking-simdjson)
+ - [Build Quickstart](#build-quickstart)
+ - [Design notes](#design-notes)
+ - [Developer mode](#developer-mode)
+ - [Directory Structure and Source](#directory-structure-and-source)
+ - [Runtime Dispatching](#runtime-dispatching)
+ - [Regenerating Single-Header Files](#regenerating-single-header-files)
+ - [Usage (CMake on 64-bit platforms like Linux, FreeBSD or macOS)](#usage-cmake-on-64-bit-platforms-like-linux-freebsd-or-macos)
+ - [Usage (CMake on 64-bit Windows using Visual Studio 2019 or better)](#usage-cmake-on-64-bit-windows-using-visual-studio-2019-or-better)
+ - [Various References](#various-references)
+
+Build Quickstart
+------------------------------
+
+```bash
+mkdir build
+cd build
+cmake -D SIMDJSON_DEVELOPER_MODE=ON ..
+cmake --build .
+```
+
+Design notes
+------------------------------
+
+The parser works in two stages:
+
+- Stage 1. (Find marks) Identifies quickly structure elements, strings, and so forth. We validate UTF-8 encoding at that stage.
+- Stage 2. (Structure building) Involves constructing a "tree" of sort (materialized as a tape) to navigate through the data. Strings and numbers are parsed at this stage.
+
+
+The role of stage 1 is to identify pseudo-structural characters as quickly as possible. A character is pseudo-structural if and only if:
+
+1. Not enclosed in quotes, AND
+2. Is a non-whitespace character, AND
+3. Its preceding character is either:
+ (a) a structural character, OR
+ (b) whitespace OR
+ (c) the final quote in a string.
+
+This helps as we redefine some new characters as pseudo-structural such as the characters 1, G, n in the following:
+
+> { "foo" : 1.5, "bar" : 1.5 GEOFF_IS_A_DUMMY bla bla , "baz", null }
+
+Stage 1 also does unicode validation.
+
+Stage 2 handles all of the rest: number parsings, recognizing atoms like true, false, null, and so forth.
+
+Developer mode
+--------------
+
+Build system targets that are only useful for developers of the simdjson
+library are behind the `SIMDJSON_DEVELOPER_MODE` option. Enabling this option
+makes tests, examples, benchmarks and other developer targets available. Not
+enabling this option means that you are a consumer of simdjson and thus you
+only get the library targets and options.
+
+Developer mode is forced to be on when the `CI` environment variable is set to
+a value that CMake recognizes as "on", which is set to `true` in all of the CI
+workflows used by simdjson.
+
+Directory Structure and Source
+------------------------------
+
+simdjson's source structure, from the top level, looks like this:
+
+* **CMakeLists.txt:** The main build system.
+* **include:** User-facing declarations and inline definitions (most user-facing functions are inlined).
+ * simdjson.h: the `simdjson` namespace. A "main include" that includes files from include/simdjson/. This is equivalent to
+ the distributed simdjson.h.
+ * simdjson/*.h: Declarations for public simdjson classes and functions.
+ * simdjson/*-inl.h: Definitions for public simdjson classes and functions.
+ * simdjson/internal/*.h: the `simdjson::internal` namespace. Private classes and functions used by the rest of simdjson.
+ * simdjson/dom.h: the `simdjson::dom` namespace. Includes all public DOM classes.
+ * simdjson/dom/*.h: Declarations/definitions for individual DOM classes.
+ * simdjson/arm64|fallback|haswell|icelake|ppc64|westmere.h: `simdjson::` namespace. Common implementation-specific tools like number and string parsing, as well as minification.
+ * simdjson/arm64|fallback|haswell|icelake|ppc64|westmere/*.h: implementation-specific functions such as , etc.
+ * simdjson/generic/*.h: the bulk of the actual code, written generically and compiled for each implementation, using functions defined in the implementation's .h files.
+ * simdjson/generic/dependencies.h: dependencies on common, non-implementation-specific simdjson classes. This will be included before including amalgamated.h.
+ * simdjson/generic/amalgamated.h: all generic ondemand classes for an implementation.
+ * simdjson/ondemand.h: the `simdjson::ondemand` namespace. Includes all public ondemand classes.
+ * simdjson/builtin.h: the `simdjson::builtin` namespace. Aliased to the most universal implementation available.
+ * simdjson/builtin/ondemand.h: the `simdjson::builtin::ondemand` namespace.
+ * simdjson/arm64|fallback|haswell|icelake|ppc64|westmere/ondemand.h: the `simdjson::::ondemand` namespace. On-Demand compiled for the specific implementation.
+ * simdjson/generic/ondemand/*.h: individual On-Demand classes, generically written.
+ * simdjson/generic/ondemand/dependencies.h: dependencies on common, non-implementation-specific simdjson classes. This will be included before including amalgamated.h.
+ * simdjson/generic/ondemand/amalgamated.h: all generic ondemand classes for an implementation.
+* **src:** The source files for non-inlined functionality (e.g. the architecture-specific parser
+ implementations).
+ * simdjson.cpp: A "main source" that includes all implementation files from src/. This is
+ equivalent to the distributed simdjson.cpp.
+ * *.cpp: other misc. implementations, such as `simdjson::implementation` and the minifier.
+ * arm64|fallback|haswell|icelake|ppc64|westmere.cpp: Architecture-specific parser implementations.
+ * generic/*.h: `simdjson::` namespace. Generic implementation of the parser, particularly the `dom_parser_implementation`.
+ * generic/stage1/*.h: `simdjson::::stage1` namespace. Generic implementation of the simd-heavy tokenizer/indexer pass of the simdjson parser. Used for the On-Demand interface
+ * generic/stage2/*.h: `simdjson::::stage2` namespace. Generic implementation of the tape creator, which consumes the index from stage 1 and actually parses numbers and string and such. Used for the DOM interface.
+
+Other important files and directories:
+* **.drone.yml:** Definitions for Drone CI.
+* **.appveyor.yml:** Definitions for Appveyor CI (Windows).
+* **.circleci:** Definitions for Circle CI.
+* **.github/workflows:** Definitions for GitHub Actions (CI).
+* **singleheader:** Contains generated `simdjson.h` and `simdjson.cpp` that we release. The files `singleheader/simdjson.h` and `singleheader/simdjson.cpp` should never be edited by hand.
+* **singleheader/amalgamate.py:** Generates `singleheader/simdjson.h` and `singleheader/simdjson.cpp` for release (python script).
+* **benchmark:** This is where we do benchmarking. Benchmarking is core to every change we make; the
+ cardinal rule is don't regress performance without knowing exactly why, and what you're trading
+ for it. Many of our benchmarks are microbenchmarks. We are effectively doing controlled scientific experiments for the purpose of understanding what affects our performance. So we simplify as much as possible. We try to avoid irrelevant factors such as page faults, interrupts, unnecessary system calls. We recommend checking the performance as follows:
+ ```bash
+ mkdir build
+ cd build
+ cmake -D SIMDJSON_DEVELOPER_MODE=ON ..
+ cmake --build . --config Release
+ benchmark/dom/parse ../jsonexamples/twitter.json
+ ```
+ The last line becomes `./benchmark/Release/parse.exe ../jsonexample/twitter.json` under Windows. You may also use Google Benchmark:
+ ```bash
+ mkdir build
+ cd build
+ cmake -D SIMDJSON_DEVELOPER_MODE=ON ..
+ cmake --build . --target bench_parse_call --config Release
+ ./benchmark/bench_parse_call
+ ```
+ The last line becomes `./benchmark/Release/bench_parse_call.exe` under Windows. Under Windows, you can also build with the clang compiler by adding `-T ClangCL` to the call to `cmake ..`: `cmake -T ClangCL ..`.
+* **fuzz:** The source for fuzz testing. This lets us explore important edge and middle cases
+* **fuzz:** The source for fuzz testing. This lets us explore important edge and middle cases
+ automatically, and is run in CI.
+* **jsonchecker:** A set of JSON files used to check different functionality of the parser.
+ * **pass*.json:** Files that should pass validation.
+ * **fail*.json:** Files that should fail validation.
+ * **jsonchecker/minefield/y_*.json:** Files that should pass validation.
+ * **jsonchecker/minefield/n_*.json:** Files that should fail validation.
+* **jsonexamples:** A wide spread of useful, real-world JSON files with different characteristics
+ and sizes.
+* **test:** The tests are here. basictests.cpp and errortests.cpp are the primary ones.
+* **tools:** Source for executables that can be distributed with simdjson. Some examples:
+ * `json2json mydoc.json` parses the document, constructs a model and then dumps back the result to standard output.
+ * `json2json -d mydoc.json` parses the document, constructs a model and then dumps model (as a tape) to standard output. The tape format is described in the accompanying file `tape.md`.
+ * `minify mydoc.json` minifies the JSON document, outputting the result to standard output. Minifying means to remove the unneeded white space characters.
+ * `jsonpointer mydoc.json ... ` parses the document, constructs a model and then processes a series of [JSON Pointer paths](https://tools.ietf.org/html/rfc6901). The result is itself a JSON document.
+
+
+> **Don't modify the files in singleheader/ directly; these are automatically generated.**
+
+
+While simdjson distributes just two files from the singleheader/ directory, we *maintain* the code in
+multiple files under include/ and src/. The files include/simdjson.h and src/simdjson.cpp are the "spine" for
+these, and you can include them as if they were the corresponding singleheader/ files.
+
+
+
+Runtime Dispatching
+--------------------
+
+A key feature of simdjson is the ability to compile different processing kernels, optimized for specific instruction sets, and to select
+the most appropriate kernel at runtime. This ensures that users get the very best performance while still enabling simdjson to run everywhere.
+This technique is frequently called runtime dispatching. The simdjson achieves runtime dispatching entirely in C++: we do not assume
+that the user is building the code using CMake, for example.
+
+To make runtime dispatching work, it is critical that the code be compiled for the lowest supported processor. In particular, you should
+not use flags such as -mavx2, /arch:AVX2 and so forth while compiling simdjson. When you do so, you allow the compiler to use advanced
+instructions. In turn, these advanced instructions present in the code may cause a runtime failure if the runtime processor does not
+support them. Even a simple loop, compiled with these flags, might generate binary code that only run on advanced processors.
+
+So we compile simdjson for a generic processor. Our users should do the same if they want simdjson's runtime dispatch to work. It is important
+to understand that if runtime dispatching does not work, then simdjson will cause crashes on older processors. Of course, if a user chooses
+to compile their code for a specific instruction set (e.g., AVX2), they are responsible for the failures if they later run their code
+on a processor that does not support AVX2. Yet, if we were to entice these users to do so, we would share the blame: thus we carefully instruct
+users to compile their code in a generic way without doing anything to enable advanced instructions.
+
+
+We only use runtime dispatching on x64 (AMD/Intel) platforms, at the moment. On ARM processors, we would need a standard way to query, at runtime,
+the processor for its supported features. We do not know how to do so on ARM systems in general. Thankfully it is not yet a concern: 64-bit ARM
+processors are fairly uniform as far as the instruction sets they support.
+
+
+In all cases, simdjson uses advanced instructions by relying on "intrinsic functions": we do not write assembly code. The intrinsic functions
+are special functions that the compiler might recognize and translate into fast code. To make runtime dispatching work, we rely on the fact that
+the header providing these instructions
+(intrin.h under Visual Studio, x86intrin.h elsewhere) defines all of the intrinsic functions, including those that are not supported
+processor.
+
+At this point, we are require to use one of two main strategies.
+
+1. On POSIX systems, the main compilers (LLVM clang, GNU gcc) allow us to use any intrinsic function after including the header, but they fail to inline the resulting instruction if the target processor does not support them. Because we compile for a generic processor, we would not be able to use most intrinsic functions. Thankfully, more recent versions of these compilers allow us to flag a region of code with a specific target, so that we can compile only some of the code with support for advanced instructions. Thus in our C++, one might notice macros like `TARGET_HASWELL`. It is then our responsibility, at runtime, to only run the regions of code (that we call kernels) matching the properties of the runtime processor. The benefit of this approach is that the compiler not only let us use intrinsic functions, but it can also optimize the rest of the code in the kernel with advanced instructions we enabled.
+
+2. Under Visual Studio, the problem is somewhat simpler. Visual Studio will not only provide the intrinsic functions, but it will also allow us to use them. They will compile just fine. It is at runtime that they may cause a crash. So we do not need to mark regions of code for compilation toward advanced processors (e.g., with `TARGET_HASWELL` macros). The downside of the Visual Studio approach is that the compiler is not allowed to use advanced instructions others than those we specify. In principle, this means that Visual Studio has weaker optimization opportunities.
+
+
+
+We also handle the special case where a user is compiling using LLVM clang under Windows, [using the Visual Studio toolchain](https://devblogs.microsoft.com/cppblog/clang-llvm-support-in-visual-studio/). If you compile with LLVM clang under Visual Studio, then the header files (intrin.h or x86intrin.h) no longer provides the intrinsic functions that are unsupported by the processor. This appears to be deliberate on the part of the LLVM engineers. With a few lines of code, we handle this scenario just like LLVM clang under a POSIX system, but forcing the inclusion of the specific headers, and rolling our own intrinsic function as needed.
+
+
+
+
+
+Regenerating Single-Header Files
+---------------------------------------
+
+The simdjson.h and simdjson.cpp files in the singleheader directory are not always up-to-date with the rest of the code; they are only ever
+systematically regenerated on releases. To ensure you have the latest code, you can regenerate them by running this at the top level:
+
+```bash
+mkdir build
+cd build
+cmake -D SIMDJSON_DEVELOPER_MODE=ON ..
+cmake --build . # needed, because currently dependencies do not work fully for the amalgamate target
+cmake --build . --target amalgamate
+```
+
+You need to have python3 installed on your system.
+
+The amalgamator script `amalgamate.py` generates singleheader/simdjson.h by
+reading through include/simdjson.h, copy/pasting each header file into the amalgamated file at the
+point it gets included (but only once per header). singleheader/simdjson.cpp is generated from
+src/simdjson.cpp the same way, except files under generic/ may be included and copy/pasted multiple
+times.
+
+## Usage (CMake on 64-bit platforms like Linux, FreeBSD or macOS)
+
+Requirements: In addition to git, we require a recent version of CMake as well as bash.
+
+1. On macOS, the easiest way to install cmake might be to use [brew](https://brew.sh) and then type
+```
+brew install cmake
+```
+2. Under Linux, you might be able to install CMake as follows:
+```
+apt-get update -qq
+apt-get install -y cmake
+```
+3. On FreeBSD, you might be able to install bash and CMake as follows:
+```
+pkg update -f
+pkg install bash
+pkg install cmake
+```
+
+You need a recent compiler like clang or gcc. We recommend at least GNU GCC/G++ 7 or LLVM clang 6.
+
+
+Building: While in the project repository, do the following:
+
+```
+mkdir build
+cd build
+cmake -D SIMDJSON_DEVELOPER_MODE=ON ..
+cmake --build .
+ctest
+```
+
+CMake will build a library. By default, it builds a static library (e.g., libsimdjson.a on Linux).
+
+You can build a shared library:
+
+```
+mkdir buildshared
+cd buildshared
+cmake -D BUILD_SHARED_LIBS=ON -D SIMDJSON_DEVELOPER_MODE=ON ..
+cmake --build .
+ctest
+```
+
+In some cases, you may want to specify your compiler, especially if the default compiler on your system is too old. You need to tell cmake which compiler you wish to use by setting the CC and CXX variables. Under bash, you can do so with commands such as `export CC=gcc-7` and `export CXX=g++-7`. You can also do it as part of the `cmake` command: `cmake -DCMAKE_CXX_COMPILER=g++ ..`. You may proceed as follows:
+
+```
+brew install gcc@8
+mkdir build
+cd build
+export CXX=g++-8 CC=gcc-8
+cmake -D SIMDJSON_DEVELOPER_MODE=ON ..
+cmake --build .
+ctest
+```
+
+If your compiler does not default on C++11 support or better you may get failing tests. If so, you may be able to exclude the failing tests by replacing `ctest` with `ctest -E "^quickstart$"`.
+
+Note that the name of directory (`build`) is arbitrary, you can name it as you want (e.g., `buildgcc`) and you can have as many different such directories as you would like (one per configuration).
+
+## Usage (CMake on 64-bit Windows using Visual Studio 2019 or better)
+
+Recent versions of Visual Studio support CMake natively, [please refer to the Visual Studio documentation](https://learn.microsoft.com/en-us/cpp/build/cmake-projects-in-visual-studio?view=msvc-170).
+
+We assume you have a common 64-bit Windows PC with at least Visual Studio 2019.
+
+- Grab the simdjson code from GitHub, e.g., by cloning it using [GitHub Desktop](https://desktop.github.com/).
+- Install [CMake](https://cmake.org/download/). When you install it, make sure to ask that `cmake` be made available from the command line. Please choose a recent version of cmake.
+- Create a subdirectory within simdjson, such as `build`.
+- Using a shell, go to this newly created directory. You can start a shell directly from GitHub Desktop (Repository > Open in Command Prompt).
+- Type `cmake ..` in the shell while in the `build` repository.
+- This last command (`cmake ...`) created a Visual Studio solution file in the newly created directory (e.g., `simdjson.sln`). Open this file in Visual Studio. You should now be able to build the project and run the tests. For example, in the `Solution Explorer` window (available from the `View` menu), right-click `ALL_BUILD` and select `Build`. To test the code, still in the `Solution Explorer` window, select `RUN_TESTS` and select `Build`.
+
+
+Though having Visual Studio installed is necessary, one can build simdjson using only cmake commands:
+
+- `mkdir build`
+- `cd build`
+- `cmake ..`
+- `cmake --build . --config Release`
+
+
+Furthermore, if you have installed LLVM clang on Windows, for example as a component of Visual Studio 2019, you can configure and build simdjson using LLVM clang on Windows using cmake:
+
+- `mkdir build`
+- `cd build`
+- `cmake -T ClangCL ..`
+- `cmake --build . --config Release`
+
+## Various References
+
+- [How to implement atoi using SIMD?](https://stackoverflow.com/questions/35127060/how-to-implement-atoi-using-simd)
+- [Parsing JSON is a Minefield 💣](http://seriot.ch/parsing_json.php)
+- https://tools.ietf.org/html/rfc7159
+- http://rapidjson.org/md_doc_sax.html
+- https://github.com/Geal/parser_benchmarks/tree/master/json
+- Gron: A command line tool that makes JSON greppable https://news.ycombinator.com/item?id=16727665
+- GoogleGson https://github.com/google/gson
+- Jackson https://github.com/FasterXML/jackson
+- https://www.yelp.com/dataset_challenge
+- RapidJSON. http://rapidjson.org/
+
+Inspiring links:
+
+- https://auth0.com/blog/beating-json-performance-with-protobuf/
+- https://gist.github.com/shijuvar/25ad7de9505232c87034b8359543404a
+- https://github.com/frankmcsherry/blog/blob/master/posts/2018-02-11.md
diff --git a/contrib/libs/simdjson/LICENSE b/contrib/libs/simdjson/LICENSE
new file mode 100644
index 000000000000..71f65b598d90
--- /dev/null
+++ b/contrib/libs/simdjson/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "{}"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright 2018-2023 The simdjson authors
+
+ Licensed 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.
diff --git a/contrib/libs/simdjson/README.md b/contrib/libs/simdjson/README.md
new file mode 100644
index 000000000000..b92c22bb7553
--- /dev/null
+++ b/contrib/libs/simdjson/README.md
@@ -0,0 +1,227 @@
+
+[![Ubuntu 20.04 CI](https://github.com/simdjson/simdjson/workflows/Ubuntu%2020.04%20CI%20(GCC%209)/badge.svg)](https://simdjson.org/plots.html)
+[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/simdjson.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:simdjson)
+[![][license img]][license]
+
+[![Doxygen Documentation](https://img.shields.io/badge/docs-doxygen-green.svg)](https://simdjson.github.io/simdjson/)
+
+simdjson : Parsing gigabytes of JSON per second
+===============================================
+
+
+JSON is everywhere on the Internet. Servers spend a *lot* of time parsing it. We need a fresh
+approach. The simdjson library uses commonly available SIMD instructions and microparallel algorithms
+to parse JSON 4x faster than RapidJSON and 25x faster than JSON for Modern C++.
+
+* **Fast:** Over 4x faster than commonly used production-grade JSON parsers.
+* **Record Breaking Features:** Minify JSON at 6 GB/s, validate UTF-8 at 13 GB/s, NDJSON at 3.5 GB/s.
+* **Easy:** First-class, easy to use and carefully documented APIs.
+* **Strict:** Full JSON and UTF-8 validation, lossless parsing. Performance with no compromises.
+* **Automatic:** Selects a CPU-tailored parser at runtime. No configuration needed.
+* **Reliable:** From memory allocation to error handling, simdjson's design avoids surprises.
+* **Peer Reviewed:** Our research appears in venues like VLDB Journal, Software: Practice and Experience.
+
+This library is part of the [Awesome Modern C++](https://awesomecpp.com) list.
+
+Table of Contents
+-----------------
+
+* [Real-world usage](#real-world-usage)
+* [Quick Start](#quick-start)
+* [Documentation](#documentation)
+* [Godbolt](#godbolt)
+* [Performance results](#performance-results)
+* [Bindings and Ports of simdjson](#bindings-and-ports-of-simdjson)
+* [About simdjson](#about-simdjson)
+* [Funding](#funding)
+* [Contributing to simdjson](#contributing-to-simdjson)
+* [License](#license)
+
+
+Real-world usage
+----------------
+
+- [Node.js](https://nodejs.org/)
+- [ClickHouse](https://github.com/ClickHouse/ClickHouse)
+- [Meta Velox](https://velox-lib.io)
+- [Google Pax](https://github.com/google/paxml)
+- [milvus](https://github.com/milvus-io/milvus)
+- [QuestDB](https://questdb.io/blog/questdb-release-8-0-3/)
+- [Clang Build Analyzer](https://github.com/aras-p/ClangBuildAnalyzer)
+- [Shopify HeapProfiler](https://github.com/Shopify/heap-profiler)
+- [StarRocks](https://github.com/StarRocks/starrocks)
+- [Microsoft FishStore](https://github.com/microsoft/FishStore)
+- [Intel PCM](https://github.com/intel/pcm)
+- [WatermelonDB](https://github.com/Nozbe/WatermelonDB)
+- [Apache Doris](https://github.com/apache/doris)
+- [Dgraph](https://github.com/dgraph-io/dgraph)
+- [UJRPC](https://github.com/unum-cloud/ujrpc)
+- [fastgltf](https://github.com/spnda/fastgltf)
+- [vast](https://github.com/tenzir/vast)
+- [ada-url](https://github.com/ada-url/ada)
+- [fastgron](https://github.com/adamritter/fastgron)
+- [WasmEdge](https://wasmedge.org)
+
+If you are planning to use simdjson in a product, please work from one of our releases.
+
+Quick Start
+-----------
+
+The simdjson library is easily consumable with a single .h and .cpp file.
+
+0. Prerequisites: `g++` (version 7 or better) or `clang++` (version 6 or better), and a 64-bit
+ system with a command-line shell (e.g., Linux, macOS, freeBSD). We also support programming
+ environments like Visual Studio and Xcode, but different steps are needed. Users of clang++ may need to specify the C++ version (e.g., `c++ -std=c++17`) since clang++ tends to default on C++98.
+1. Pull [simdjson.h](singleheader/simdjson.h) and [simdjson.cpp](singleheader/simdjson.cpp) into a
+ directory, along with the sample file [twitter.json](jsonexamples/twitter.json). You can download them with the `wget` utility:
+
+ ```
+ wget https://raw.githubusercontent.com/simdjson/simdjson/master/singleheader/simdjson.h https://raw.githubusercontent.com/simdjson/simdjson/master/singleheader/simdjson.cpp https://raw.githubusercontent.com/simdjson/simdjson/master/jsonexamples/twitter.json
+ ```
+2. Create `quickstart.cpp`:
+
+```c++
+#include
+#include "simdjson.h"
+using namespace simdjson;
+int main(void) {
+ ondemand::parser parser;
+ padded_string json = padded_string::load("twitter.json");
+ ondemand::document tweets = parser.iterate(json);
+ std::cout << uint64_t(tweets["search_metadata"]["count"]) << " results." << std::endl;
+}
+```
+3. `c++ -o quickstart quickstart.cpp simdjson.cpp`
+4. `./quickstart`
+
+ ```
+ 100 results.
+ ```
+
+
+Documentation
+-------------
+
+Usage documentation is available:
+
+* [Basics](doc/basics.md) is an overview of how to use simdjson and its APIs.
+* [Performance](doc/performance.md) shows some more advanced scenarios and how to tune for them.
+* [Implementation Selection](doc/implementation-selection.md) describes runtime CPU detection and
+ how you can work with it.
+* [API](https://simdjson.github.io/simdjson/) contains the automatically generated API documentation.
+
+Godbolt
+-------------
+
+Some users may want to browse code along with the compiled assembly. You want to check out the following lists of examples:
+* [simdjson examples with errors handled through exceptions](https://godbolt.org/z/7G5qE4sr9)
+* [simdjson examples with errors without exceptions](https://godbolt.org/z/e9dWb9E4v)
+
+Performance results
+-------------------
+
+The simdjson library uses three-quarters less instructions than state-of-the-art parser [RapidJSON](https://rapidjson.org). To our knowledge, simdjson is the first fully-validating JSON parser
+to run at [gigabytes per second](https://en.wikipedia.org/wiki/Gigabyte) (GB/s) on commodity processors. It can parse millions of JSON documents per second on a single core.
+
+The following figure represents parsing speed in GB/s for parsing various files
+on an Intel Skylake processor (3.4 GHz) using the GNU GCC 10 compiler (with the -O3 flag).
+We compare against the best and fastest C++ libraries on benchmarks that load and process the data.
+The simdjson library offers full unicode ([UTF-8](https://en.wikipedia.org/wiki/UTF-8)) validation and exact
+number parsing.
+
+
+
+The simdjson library offers high speed whether it processes tiny files (e.g., 300 bytes)
+or larger files (e.g., 3MB). The following plot presents parsing
+speed for [synthetic files over various sizes generated with a script](https://github.com/simdjson/simdjson_experiments_vldb2019/blob/master/experiments/growing/gen.py) on a 3.4 GHz Skylake processor (GNU GCC 9, -O3).
+
+
+
+[All our experiments are reproducible](https://github.com/simdjson/simdjson_experiments_vldb2019).
+
+
+For NDJSON files, we can exceed 3 GB/s with [our multithreaded parsing functions](https://github.com/simdjson/simdjson/blob/master/doc/parse_many.md).
+
+
+
+
+Bindings and Ports of simdjson
+------------------------------
+
+We distinguish between "bindings" (which just wrap the C++ code) and a port to another programming language (which reimplements everything).
+
+- [ZippyJSON](https://github.com/michaeleisel/zippyjson): Swift bindings for the simdjson project.
+- [libpy_simdjson](https://github.com/gerrymanoim/libpy_simdjson/): high-speed Python bindings for simdjson using [libpy](https://github.com/quantopian/libpy).
+- [pysimdjson](https://github.com/TkTech/pysimdjson): Python bindings for the simdjson project.
+- [cysimdjson](https://github.com/TeskaLabs/cysimdjson): high-speed Python bindings for the simdjson project.
+- [simdjson-rs](https://github.com/simd-lite): Rust port.
+- [simdjson-rust](https://github.com/SunDoge/simdjson-rust): Rust wrapper (bindings).
+- [SimdJsonSharp](https://github.com/EgorBo/SimdJsonSharp): C# version for .NET Core (bindings and full port).
+- [simdjson_nodejs](https://github.com/luizperes/simdjson_nodejs): Node.js bindings for the simdjson project.
+- [simdjson_php](https://github.com/crazyxman/simdjson_php): PHP bindings for the simdjson project.
+- [simdjson_ruby](https://github.com/saka1/simdjson_ruby): Ruby bindings for the simdjson project.
+- [fast_jsonparser](https://github.com/anilmaurya/fast_jsonparser): Ruby bindings for the simdjson project.
+- [simdjson-go](https://github.com/minio/simdjson-go): Go port using Golang assembly.
+- [rcppsimdjson](https://github.com/eddelbuettel/rcppsimdjson): R bindings.
+- [simdjson_erlang](https://github.com/ChomperT/simdjson_erlang): erlang bindings.
+- [simdjsone](https://github.com/saleyn/simdjsone): erlang bindings.
+- [lua-simdjson](https://github.com/FourierTransformer/lua-simdjson): lua bindings.
+- [hermes-json](https://hackage.haskell.org/package/hermes-json): haskell bindings.
+- [simdjzon](https://github.com/travisstaloch/simdjzon): zig port.
+- [JSON-Simd](https://github.com/rawleyfowler/JSON-simd): Raku bindings.
+- [JSON::SIMD](https://metacpan.org/pod/JSON::SIMD): Perl bindings; fully-featured JSON module that uses simdjson for decoding.
+- [gemmaJSON](https://github.com/sainttttt/gemmaJSON): Nim JSON parser based on simdjson bindings.
+- [simdjson-java](https://github.com/simdjson/simdjson-java): Java port.
+
+About simdjson
+--------------
+
+The simdjson library takes advantage of modern microarchitectures, parallelizing with SIMD vector
+instructions, reducing branch misprediction, and reducing data dependency to take advantage of each
+CPU's multiple execution cores.
+
+Our default front-end is called On-Demand, and we wrote a paper about it:
+
+- John Keiser, Daniel Lemire, [On-Demand JSON: A Better Way to Parse Documents?](http://arxiv.org/abs/2312.17149), Software: Practice and Experience 54 (6), 2024.
+
+Some people [enjoy reading the first (2019) simdjson paper](https://arxiv.org/abs/1902.08318): A description of the design
+and implementation of simdjson is in our research article:
+- Geoff Langdale, Daniel Lemire, [Parsing Gigabytes of JSON per Second](https://arxiv.org/abs/1902.08318), VLDB Journal 28 (6), 2019.
+
+We have an in-depth paper focused on the UTF-8 validation:
+
+- John Keiser, Daniel Lemire, [Validating UTF-8 In Less Than One Instruction Per Byte](https://arxiv.org/abs/2010.03090), Software: Practice & Experience 51 (5), 2021.
+
+We also have an informal [blog post providing some background and context](https://branchfree.org/2019/02/25/paper-parsing-gigabytes-of-json-per-second/).
+
+For the video inclined,
+[![simdjson at QCon San Francisco 2019](http://img.youtube.com/vi/wlvKAT7SZIQ/0.jpg)](http://www.youtube.com/watch?v=wlvKAT7SZIQ)
+(It was the best voted talk, we're kinda proud of it.)
+
+Funding
+-------
+
+The work is supported by the Natural Sciences and Engineering Research Council of Canada under grants
+RGPIN-2017-03910 and RGPIN-2024-03787.
+
+[license]: LICENSE
+[license img]: https://img.shields.io/badge/License-Apache%202-blue.svg
+
+Contributing to simdjson
+------------------------
+
+Head over to [CONTRIBUTING.md](CONTRIBUTING.md) for information on contributing to simdjson, and
+[HACKING.md](HACKING.md) for information on source, building, and architecture/design.
+
+License
+-------
+
+This code is made available under the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0.html).
+
+Under Windows, we build some tools using the windows/dirent_portable.h file (which is outside our library code): it is under the liberal (business-friendly) MIT license.
+
+For compilers that do not support [C++17](https://en.wikipedia.org/wiki/C%2B%2B17), we bundle the string-view library which is published under the [Boost license](http://www.boost.org/LICENSE_1_0.txt). Like the Apache license, the Boost license is a permissive license allowing commercial redistribution.
+
+For efficient number serialization, we bundle Florian Loitsch's implementation of the Grisu2 algorithm for binary to decimal floating-point numbers. The implementation was slightly modified by JSON for Modern C++ library. Both Florian Loitsch's implementation and JSON for Modern C++ are provided under the MIT license.
+
+For runtime dispatching, we use some code from the PyTorch project licensed under 3-clause BSD.
diff --git a/contrib/libs/simdjson/SECURITY.md b/contrib/libs/simdjson/SECURITY.md
new file mode 100644
index 000000000000..87c4c9b35e31
--- /dev/null
+++ b/contrib/libs/simdjson/SECURITY.md
@@ -0,0 +1,7 @@
+# Security Policy
+
+## Reporting a Vulnerability
+
+Please use the following contact information for reporting a vulnerability:
+
+- [Daniel Lemire](https://github.com/lemire) - daniel@lemire.me
diff --git a/contrib/libs/simdjson/include/simdjson.h b/contrib/libs/simdjson/include/simdjson.h
new file mode 100644
index 000000000000..f77ab12b3ec5
--- /dev/null
+++ b/contrib/libs/simdjson/include/simdjson.h
@@ -0,0 +1,57 @@
+#ifndef SIMDJSON_H
+#define SIMDJSON_H
+
+/**
+ * @mainpage
+ *
+ * Check the [README.md](https://github.com/simdjson/simdjson/blob/master/README.md#simdjson--parsing-gigabytes-of-json-per-second).
+ *
+ * Sample code. See https://github.com/simdjson/simdjson/blob/master/doc/basics.md for more examples.
+
+ #include "simdjson.h"
+
+ int main(void) {
+ // load from `twitter.json` file:
+ simdjson::dom::parser parser;
+ simdjson::dom::element tweets = parser.load("twitter.json");
+ std::cout << tweets["search_metadata"]["count"] << " results." << std::endl;
+
+ // Parse and iterate through an array of objects
+ auto abstract_json = R"( [
+ { "12345" : {"a":12.34, "b":56.78, "c": 9998877} },
+ { "12545" : {"a":11.44, "b":12.78, "c": 11111111} }
+ ] )"_padded;
+
+ for (simdjson::dom::object obj : parser.parse(abstract_json)) {
+ for(const auto key_value : obj) {
+ cout << "key: " << key_value.key << " : ";
+ simdjson::dom::object innerobj = key_value.value;
+ cout << "a: " << double(innerobj["a"]) << ", ";
+ cout << "b: " << double(innerobj["b"]) << ", ";
+ cout << "c: " << int64_t(innerobj["c"]) << endl;
+ }
+ }
+ }
+ */
+
+#include "simdjson/common_defs.h"
+
+// This provides the public API for simdjson.
+// DOM and ondemand are amalgamated separately, in simdjson.h
+#include "simdjson/simdjson_version.h"
+
+#include "simdjson/base.h"
+
+#include "simdjson/error.h"
+#include "simdjson/error-inl.h"
+#include "simdjson/implementation.h"
+#include "simdjson/minify.h"
+#include "simdjson/padded_string.h"
+#include "simdjson/padded_string-inl.h"
+#include "simdjson/padded_string_view.h"
+#include "simdjson/padded_string_view-inl.h"
+
+#include "simdjson/dom.h"
+#include "simdjson/ondemand.h"
+
+#endif // SIMDJSON_H
diff --git a/contrib/libs/simdjson/include/simdjson/arm64.h b/contrib/libs/simdjson/include/simdjson/arm64.h
new file mode 100644
index 000000000000..1493c3562a5d
--- /dev/null
+++ b/contrib/libs/simdjson/include/simdjson/arm64.h
@@ -0,0 +1,8 @@
+#ifndef SIMDJSON_ARM64_H
+#define SIMDJSON_ARM64_H
+
+#include "simdjson/arm64/begin.h"
+#include "simdjson/generic/amalgamated.h"
+#include "simdjson/arm64/end.h"
+
+#endif // SIMDJSON_ARM64_H
\ No newline at end of file
diff --git a/contrib/libs/simdjson/include/simdjson/arm64/base.h b/contrib/libs/simdjson/include/simdjson/arm64/base.h
new file mode 100644
index 000000000000..8f23d18d80e4
--- /dev/null
+++ b/contrib/libs/simdjson/include/simdjson/arm64/base.h
@@ -0,0 +1,26 @@
+#ifndef SIMDJSON_ARM64_BASE_H
+#define SIMDJSON_ARM64_BASE_H
+
+#ifndef SIMDJSON_CONDITIONAL_INCLUDE
+#include "simdjson/base.h"
+#endif // SIMDJSON_CONDITIONAL_INCLUDE
+
+namespace simdjson {
+/**
+ * Implementation for NEON (ARMv8).
+ */
+namespace arm64 {
+
+class implementation;
+
+namespace {
+namespace simd {
+template struct simd8;
+template struct simd8x64;
+} // namespace simd
+} // unnamed namespace
+
+} // namespace arm64
+} // namespace simdjson
+
+#endif // SIMDJSON_ARM64_BASE_H
diff --git a/contrib/libs/simdjson/include/simdjson/arm64/begin.h b/contrib/libs/simdjson/include/simdjson/arm64/begin.h
new file mode 100644
index 000000000000..ee48cec05150
--- /dev/null
+++ b/contrib/libs/simdjson/include/simdjson/arm64/begin.h
@@ -0,0 +1,10 @@
+#define SIMDJSON_IMPLEMENTATION arm64
+#include "simdjson/arm64/base.h"
+#include "simdjson/arm64/intrinsics.h"
+#include "simdjson/arm64/bitmanipulation.h"
+#include "simdjson/arm64/bitmask.h"
+#include "simdjson/arm64/numberparsing_defs.h"
+#include "simdjson/arm64/simd.h"
+#include "simdjson/arm64/stringparsing_defs.h"
+
+#define SIMDJSON_SKIP_BACKSLASH_SHORT_CIRCUIT 1
\ No newline at end of file
diff --git a/contrib/libs/simdjson/include/simdjson/arm64/bitmanipulation.h b/contrib/libs/simdjson/include/simdjson/arm64/bitmanipulation.h
new file mode 100644
index 000000000000..019869b1b0b2
--- /dev/null
+++ b/contrib/libs/simdjson/include/simdjson/arm64/bitmanipulation.h
@@ -0,0 +1,106 @@
+#ifndef SIMDJSON_ARM64_BITMANIPULATION_H
+#define SIMDJSON_ARM64_BITMANIPULATION_H
+
+#ifndef SIMDJSON_CONDITIONAL_INCLUDE
+#include "simdjson/arm64/base.h"
+#include "simdjson/arm64/intrinsics.h"
+#endif // SIMDJSON_CONDITIONAL_INCLUDE
+
+namespace simdjson {
+namespace arm64 {
+namespace {
+
+// We sometimes call trailing_zero on inputs that are zero,
+// but the algorithms do not end up using the returned value.
+// Sadly, sanitizers are not smart enough to figure it out.
+SIMDJSON_NO_SANITIZE_UNDEFINED
+// This function can be used safely even if not all bytes have been
+// initialized.
+// See issue https://github.com/simdjson/simdjson/issues/1965
+SIMDJSON_NO_SANITIZE_MEMORY
+simdjson_inline int trailing_zeroes(uint64_t input_num) {
+#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
+ unsigned long ret;
+ // Search the mask data from least significant bit (LSB)
+ // to the most significant bit (MSB) for a set bit (1).
+ _BitScanForward64(&ret, input_num);
+ return (int)ret;
+#else // SIMDJSON_REGULAR_VISUAL_STUDIO
+ return __builtin_ctzll(input_num);
+#endif // SIMDJSON_REGULAR_VISUAL_STUDIO
+}
+
+/* result might be undefined when input_num is zero */
+simdjson_inline uint64_t clear_lowest_bit(uint64_t input_num) {
+ return input_num & (input_num-1);
+}
+
+/* result might be undefined when input_num is zero */
+simdjson_inline int leading_zeroes(uint64_t input_num) {
+#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
+ unsigned long leading_zero = 0;
+ // Search the mask data from most significant bit (MSB)
+ // to least significant bit (LSB) for a set bit (1).
+ if (_BitScanReverse64(&leading_zero, input_num))
+ return (int)(63 - leading_zero);
+ else
+ return 64;
+#else
+ return __builtin_clzll(input_num);
+#endif// SIMDJSON_REGULAR_VISUAL_STUDIO
+}
+
+/* result might be undefined when input_num is zero */
+simdjson_inline int count_ones(uint64_t input_num) {
+ return vaddv_u8(vcnt_u8(vcreate_u8(input_num)));
+}
+
+
+#if defined(__GNUC__) // catches clang and gcc
+/**
+ * ARM has a fast 64-bit "bit reversal function" that is handy. However,
+ * it is not generally available as an intrinsic function under Visual
+ * Studio (though this might be changing). Even under clang/gcc, we
+ * apparently need to invoke inline assembly.
+ */
+/*
+ * We use SIMDJSON_PREFER_REVERSE_BITS as a hint that algorithms that
+ * work well with bit reversal may use it.
+ */
+#define SIMDJSON_PREFER_REVERSE_BITS 1
+
+/* reverse the bits */
+simdjson_inline uint64_t reverse_bits(uint64_t input_num) {
+ uint64_t rev_bits;
+ __asm("rbit %0, %1" : "=r"(rev_bits) : "r"(input_num));
+ return rev_bits;
+}
+
+/**
+ * Flips bit at index 63 - lz. Thus if you have 'leading_zeroes' leading zeroes,
+ * then this will set to zero the leading bit. It is possible for leading_zeroes to be
+ * greating or equal to 63 in which case we trigger undefined behavior, but the output
+ * of such undefined behavior is never used.
+ **/
+SIMDJSON_NO_SANITIZE_UNDEFINED
+simdjson_inline uint64_t zero_leading_bit(uint64_t rev_bits, int leading_zeroes) {
+ return rev_bits ^ (uint64_t(0x8000000000000000) >> leading_zeroes);
+}
+
+#endif
+
+simdjson_inline bool add_overflow(uint64_t value1, uint64_t value2, uint64_t *result) {
+#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
+ *result = value1 + value2;
+ return *result < value1;
+#else
+ return __builtin_uaddll_overflow(value1, value2,
+ reinterpret_cast(result));
+#endif
+}
+
+} // unnamed namespace
+} // namespace arm64
+} // namespace simdjson
+
+#endif // SIMDJSON_ARM64_BITMANIPULATION_H
diff --git a/contrib/libs/simdjson/include/simdjson/arm64/bitmask.h b/contrib/libs/simdjson/include/simdjson/arm64/bitmask.h
new file mode 100644
index 000000000000..5d6121bcc7b1
--- /dev/null
+++ b/contrib/libs/simdjson/include/simdjson/arm64/bitmask.h
@@ -0,0 +1,44 @@
+#ifndef SIMDJSON_ARM64_BITMASK_H
+#define SIMDJSON_ARM64_BITMASK_H
+
+#ifndef SIMDJSON_CONDITIONAL_INCLUDE
+#include "simdjson/arm64/base.h"
+#endif // SIMDJSON_CONDITIONAL_INCLUDE
+
+namespace simdjson {
+namespace arm64 {
+namespace {
+
+//
+// Perform a "cumulative bitwise xor," flipping bits each time a 1 is encountered.
+//
+// For example, prefix_xor(00100100) == 00011100
+//
+simdjson_inline uint64_t prefix_xor(uint64_t bitmask) {
+ /////////////
+ // We could do this with PMULL, but it is apparently slow.
+ //
+ //#ifdef __ARM_FEATURE_CRYPTO // some ARM processors lack this extension
+ //return vmull_p64(-1ULL, bitmask);
+ //#else
+ // Analysis by @sebpop:
+ // When diffing the assembly for src/stage1_find_marks.cpp I see that the eors are all spread out
+ // in between other vector code, so effectively the extra cycles of the sequence do not matter
+ // because the GPR units are idle otherwise and the critical path is on the FP side.
+ // Also the PMULL requires two extra fmovs: GPR->FP (3 cycles in N1, 5 cycles in A72 )
+ // and FP->GPR (2 cycles on N1 and 5 cycles on A72.)
+ ///////////
+ bitmask ^= bitmask << 1;
+ bitmask ^= bitmask << 2;
+ bitmask ^= bitmask << 4;
+ bitmask ^= bitmask << 8;
+ bitmask ^= bitmask << 16;
+ bitmask ^= bitmask << 32;
+ return bitmask;
+}
+
+} // unnamed namespace
+} // namespace arm64
+} // namespace simdjson
+
+#endif
diff --git a/contrib/libs/simdjson/include/simdjson/arm64/end.h b/contrib/libs/simdjson/include/simdjson/arm64/end.h
new file mode 100644
index 000000000000..b92378df97fd
--- /dev/null
+++ b/contrib/libs/simdjson/include/simdjson/arm64/end.h
@@ -0,0 +1,6 @@
+#ifndef SIMDJSON_CONDITIONAL_INCLUDE
+#include "simdjson/arm64/base.h"
+#endif // SIMDJSON_CONDITIONAL_INCLUDE
+
+#undef SIMDJSON_SKIP_BACKSLASH_SHORT_CIRCUIT
+#undef SIMDJSON_IMPLEMENTATION
diff --git a/contrib/libs/simdjson/include/simdjson/arm64/implementation.h b/contrib/libs/simdjson/include/simdjson/arm64/implementation.h
new file mode 100644
index 000000000000..c9b7dd753507
--- /dev/null
+++ b/contrib/libs/simdjson/include/simdjson/arm64/implementation.h
@@ -0,0 +1,31 @@
+#ifndef SIMDJSON_ARM64_IMPLEMENTATION_H
+#define SIMDJSON_ARM64_IMPLEMENTATION_H
+
+#ifndef SIMDJSON_CONDITIONAL_INCLUDE
+#include "simdjson/base.h"
+#include "simdjson/implementation.h"
+#include "simdjson/internal/instruction_set.h"
+#endif // SIMDJSON_CONDITIONAL_INCLUDE
+
+namespace simdjson {
+namespace arm64 {
+
+/**
+ * @private
+ */
+class implementation final : public simdjson::implementation {
+public:
+ simdjson_inline implementation() : simdjson::implementation("arm64", "ARM NEON", internal::instruction_set::NEON) {}
+ simdjson_warn_unused error_code create_dom_parser_implementation(
+ size_t capacity,
+ size_t max_length,
+ std::unique_ptr& dst
+ ) const noexcept final;
+ simdjson_warn_unused error_code minify(const uint8_t *buf, size_t len, uint8_t *dst, size_t &dst_len) const noexcept final;
+ simdjson_warn_unused bool validate_utf8(const char *buf, size_t len) const noexcept final;
+};
+
+} // namespace arm64
+} // namespace simdjson
+
+#endif // SIMDJSON_ARM64_IMPLEMENTATION_H
diff --git a/contrib/libs/simdjson/include/simdjson/arm64/intrinsics.h b/contrib/libs/simdjson/include/simdjson/arm64/intrinsics.h
new file mode 100644
index 000000000000..049d99861020
--- /dev/null
+++ b/contrib/libs/simdjson/include/simdjson/arm64/intrinsics.h
@@ -0,0 +1,14 @@
+#ifndef SIMDJSON_ARM64_INTRINSICS_H
+#define SIMDJSON_ARM64_INTRINSICS_H
+
+#ifndef SIMDJSON_CONDITIONAL_INCLUDE
+#include "simdjson/arm64/base.h"
+#endif // SIMDJSON_CONDITIONAL_INCLUDE
+
+// This should be the correct header whether
+// you use visual studio or other compilers.
+#include
+
+static_assert(sizeof(uint8x16_t) <= simdjson::SIMDJSON_PADDING, "insufficient padding for arm64");
+
+#endif // SIMDJSON_ARM64_INTRINSICS_H
diff --git a/contrib/libs/simdjson/include/simdjson/arm64/numberparsing_defs.h b/contrib/libs/simdjson/include/simdjson/arm64/numberparsing_defs.h
new file mode 100644
index 000000000000..f5e85b747790
--- /dev/null
+++ b/contrib/libs/simdjson/include/simdjson/arm64/numberparsing_defs.h
@@ -0,0 +1,56 @@
+#ifndef SIMDJSON_ARM64_NUMBERPARSING_DEFS_H
+#define SIMDJSON_ARM64_NUMBERPARSING_DEFS_H
+
+#ifndef SIMDJSON_CONDITIONAL_INCLUDE
+#include "simdjson/arm64/base.h"
+#include "simdjson/arm64/intrinsics.h"
+#include "simdjson/internal/numberparsing_tables.h"
+#endif // SIMDJSON_CONDITIONAL_INCLUDE
+
+#include
+
+#if SIMDJSON_REGULAR_VISUAL_STUDIO && SIMDJSON_IS_ARM64
+// __umulh requires intrin.h
+#include
+#endif // SIMDJSON_REGULAR_VISUAL_STUDIO && SIMDJSON_IS_ARM64
+
+namespace simdjson {
+namespace arm64 {
+namespace numberparsing {
+
+// we don't have SSE, so let us use a scalar function
+// credit: https://johnnylee-sde.github.io/Fast-numeric-string-to-int/
+/** @private */
+static simdjson_inline uint32_t parse_eight_digits_unrolled(const uint8_t *chars) {
+ uint64_t val;
+ std::memcpy(&val, chars, sizeof(uint64_t));
+ val = (val & 0x0F0F0F0F0F0F0F0F) * 2561 >> 8;
+ val = (val & 0x00FF00FF00FF00FF) * 6553601 >> 16;
+ return uint32_t((val & 0x0000FFFF0000FFFF) * 42949672960001 >> 32);
+}
+
+simdjson_inline internal::value128 full_multiplication(uint64_t value1, uint64_t value2) {
+ internal::value128 answer;
+#if SIMDJSON_REGULAR_VISUAL_STUDIO || SIMDJSON_IS_32BITS
+#if SIMDJSON_IS_ARM64
+ // ARM64 has native support for 64-bit multiplications, no need to emultate
+ answer.high = __umulh(value1, value2);
+ answer.low = value1 * value2;
+#else
+ answer.low = _umul128(value1, value2, &answer.high); // _umul128 not available on ARM64
+#endif // SIMDJSON_IS_ARM64
+#else // SIMDJSON_REGULAR_VISUAL_STUDIO || SIMDJSON_IS_32BITS
+ __uint128_t r = (static_cast<__uint128_t>(value1)) * value2;
+ answer.low = uint64_t(r);
+ answer.high = uint64_t(r >> 64);
+#endif
+ return answer;
+}
+
+} // namespace numberparsing
+} // namespace arm64
+} // namespace simdjson
+
+#define SIMDJSON_SWAR_NUMBER_PARSING 1
+
+#endif // SIMDJSON_ARM64_NUMBERPARSING_DEFS_H
diff --git a/contrib/libs/simdjson/include/simdjson/arm64/ondemand.h b/contrib/libs/simdjson/include/simdjson/arm64/ondemand.h
new file mode 100644
index 000000000000..67134394675e
--- /dev/null
+++ b/contrib/libs/simdjson/include/simdjson/arm64/ondemand.h
@@ -0,0 +1,8 @@
+#ifndef SIMDJSON_ARM64_ONDEMAND_H
+#define SIMDJSON_ARM64_ONDEMAND_H
+
+#include "simdjson/arm64/begin.h"
+#include "simdjson/generic/ondemand/amalgamated.h"
+#include "simdjson/arm64/end.h"
+
+#endif // SIMDJSON_ARM64_ONDEMAND_H
diff --git a/contrib/libs/simdjson/include/simdjson/arm64/simd.h b/contrib/libs/simdjson/include/simdjson/arm64/simd.h
new file mode 100644
index 000000000000..3b0fa844f496
--- /dev/null
+++ b/contrib/libs/simdjson/include/simdjson/arm64/simd.h
@@ -0,0 +1,497 @@
+#ifndef SIMDJSON_ARM64_SIMD_H
+#define SIMDJSON_ARM64_SIMD_H
+
+#ifndef SIMDJSON_CONDITIONAL_INCLUDE
+#include "simdjson/arm64/base.h"
+#include "simdjson/arm64/bitmanipulation.h"
+#include "simdjson/internal/simdprune_tables.h"
+#endif // SIMDJSON_CONDITIONAL_INCLUDE
+
+namespace simdjson {
+namespace arm64 {
+namespace {
+namespace simd {
+
+#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
+namespace {
+// Start of private section with Visual Studio workaround
+
+
+#ifndef simdjson_make_uint8x16_t
+#define simdjson_make_uint8x16_t(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, \
+ x13, x14, x15, x16) \
+ ([=]() { \
+ uint8_t array[16] = {x1, x2, x3, x4, x5, x6, x7, x8, \
+ x9, x10, x11, x12, x13, x14, x15, x16}; \
+ return vld1q_u8(array); \
+ }())
+#endif
+#ifndef simdjson_make_int8x16_t
+#define simdjson_make_int8x16_t(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, \
+ x13, x14, x15, x16) \
+ ([=]() { \
+ int8_t array[16] = {x1, x2, x3, x4, x5, x6, x7, x8, \
+ x9, x10, x11, x12, x13, x14, x15, x16}; \
+ return vld1q_s8(array); \
+ }())
+#endif
+
+#ifndef simdjson_make_uint8x8_t
+#define simdjson_make_uint8x8_t(x1, x2, x3, x4, x5, x6, x7, x8) \
+ ([=]() { \
+ uint8_t array[8] = {x1, x2, x3, x4, x5, x6, x7, x8}; \
+ return vld1_u8(array); \
+ }())
+#endif
+#ifndef simdjson_make_int8x8_t
+#define simdjson_make_int8x8_t(x1, x2, x3, x4, x5, x6, x7, x8) \
+ ([=]() { \
+ int8_t array[8] = {x1, x2, x3, x4, x5, x6, x7, x8}; \
+ return vld1_s8(array); \
+ }())
+#endif
+#ifndef simdjson_make_uint16x8_t
+#define simdjson_make_uint16x8_t(x1, x2, x3, x4, x5, x6, x7, x8) \
+ ([=]() { \
+ uint16_t array[8] = {x1, x2, x3, x4, x5, x6, x7, x8}; \
+ return vld1q_u16(array); \
+ }())
+#endif
+#ifndef simdjson_make_int16x8_t
+#define simdjson_make_int16x8_t(x1, x2, x3, x4, x5, x6, x7, x8) \
+ ([=]() { \
+ int16_t array[8] = {x1, x2, x3, x4, x5, x6, x7, x8}; \
+ return vld1q_s16(array); \
+ }())
+#endif
+
+// End of private section with Visual Studio workaround
+} // namespace
+#endif // SIMDJSON_REGULAR_VISUAL_STUDIO
+
+
+ template
+ struct simd8;
+
+ //
+ // Base class of simd8 and simd8, both of which use uint8x16_t internally.
+ //
+ template>
+ struct base_u8 {
+ uint8x16_t value;
+ static const int SIZE = sizeof(value);
+
+ // Conversion from/to SIMD register
+ simdjson_inline base_u8(const uint8x16_t _value) : value(_value) {}
+ simdjson_inline operator const uint8x16_t&() const { return this->value; }
+ simdjson_inline operator uint8x16_t&() { return this->value; }
+
+ // Bit operations
+ simdjson_inline simd8 operator|(const simd8 other) const { return vorrq_u8(*this, other); }
+ simdjson_inline simd8 operator&(const simd8 other) const { return vandq_u8(*this, other); }
+ simdjson_inline simd8 operator^(const simd8 other) const { return veorq_u8(*this, other); }
+ simdjson_inline simd8 bit_andnot(const simd8 other) const { return vbicq_u8(*this, other); }
+ simdjson_inline simd8 operator~() const { return *this ^ 0xFFu; }
+ simdjson_inline simd8& operator|=(const simd8 other) { auto this_cast = static_cast*>(this); *this_cast = *this_cast | other; return *this_cast; }
+ simdjson_inline simd8& operator&=(const simd8 other) { auto this_cast = static_cast*>(this); *this_cast = *this_cast & other; return *this_cast; }
+ simdjson_inline simd8& operator^=(const simd8 other) { auto this_cast = static_cast*>(this); *this_cast = *this_cast ^ other; return *this_cast; }
+
+ friend simdjson_inline Mask operator==(const simd8 lhs, const simd8 rhs) { return vceqq_u8(lhs, rhs); }
+
+ template
+ simdjson_inline simd8 prev(const simd8 prev_chunk) const {
+ return vextq_u8(prev_chunk, *this, 16 - N);
+ }
+ };
+
+ // SIMD byte mask type (returned by things like eq and gt)
+ template<>
+ struct simd8: base_u8 {
+ typedef uint16_t bitmask_t;
+ typedef uint32_t bitmask2_t;
+
+ static simdjson_inline simd8 splat(bool _value) { return vmovq_n_u8(uint8_t(-(!!_value))); }
+
+ simdjson_inline simd8(const uint8x16_t _value) : base_u8(_value) {}
+ // False constructor
+ simdjson_inline simd8() : simd8(vdupq_n_u8(0)) {}
+ // Splat constructor
+ simdjson_inline simd8(bool _value) : simd8(splat(_value)) {}
+
+ // We return uint32_t instead of uint16_t because that seems to be more efficient for most
+ // purposes (cutting it down to uint16_t costs performance in some compilers).
+ simdjson_inline uint32_t to_bitmask() const {
+#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
+ const uint8x16_t bit_mask = simdjson_make_uint8x16_t(0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80,
+ 0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80);
+#else
+ const uint8x16_t bit_mask = {0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80,
+ 0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80};
+#endif
+ auto minput = *this & bit_mask;
+ uint8x16_t tmp = vpaddq_u8(minput, minput);
+ tmp = vpaddq_u8(tmp, tmp);
+ tmp = vpaddq_u8(tmp, tmp);
+ return vgetq_lane_u16(vreinterpretq_u16_u8(tmp), 0);
+ }
+ simdjson_inline bool any() const { return vmaxvq_u32(vreinterpretq_u32_u8(*this)) != 0; }
+ };
+
+ // Unsigned bytes
+ template<>
+ struct simd8: base_u8 {
+ static simdjson_inline uint8x16_t splat(uint8_t _value) { return vmovq_n_u8(_value); }
+ static simdjson_inline uint8x16_t zero() { return vdupq_n_u8(0); }
+ static simdjson_inline uint8x16_t load(const uint8_t* values) { return vld1q_u8(values); }
+
+ simdjson_inline simd8(const uint8x16_t _value) : base_u8(_value) {}
+ // Zero constructor
+ simdjson_inline simd8() : simd8(zero()) {}
+ // Array constructor
+ simdjson_inline simd8(const uint8_t values[16]) : simd8(load(values)) {}
+ // Splat constructor
+ simdjson_inline simd8(uint8_t _value) : simd8(splat(_value)) {}
+ // Member-by-member initialization
+#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
+ simdjson_inline simd8(
+ uint8_t v0, uint8_t v1, uint8_t v2, uint8_t v3, uint8_t v4, uint8_t v5, uint8_t v6, uint8_t v7,
+ uint8_t v8, uint8_t v9, uint8_t v10, uint8_t v11, uint8_t v12, uint8_t v13, uint8_t v14, uint8_t v15
+ ) : simd8(simdjson_make_uint8x16_t(
+ v0, v1, v2, v3, v4, v5, v6, v7,
+ v8, v9, v10,v11,v12,v13,v14,v15
+ )) {}
+#else
+ simdjson_inline simd8(
+ uint8_t v0, uint8_t v1, uint8_t v2, uint8_t v3, uint8_t v4, uint8_t v5, uint8_t v6, uint8_t v7,
+ uint8_t v8, uint8_t v9, uint8_t v10, uint8_t v11, uint8_t v12, uint8_t v13, uint8_t v14, uint8_t v15
+ ) : simd8(uint8x16_t{
+ v0, v1, v2, v3, v4, v5, v6, v7,
+ v8, v9, v10,v11,v12,v13,v14,v15
+ }) {}
+#endif
+
+ // Repeat 16 values as many times as necessary (usually for lookup tables)
+ simdjson_inline static simd8 repeat_16(
+ uint8_t v0, uint8_t v1, uint8_t v2, uint8_t v3, uint8_t v4, uint8_t v5, uint8_t v6, uint8_t v7,
+ uint8_t v8, uint8_t v9, uint8_t v10, uint8_t v11, uint8_t v12, uint8_t v13, uint8_t v14, uint8_t v15
+ ) {
+ return simd8(
+ v0, v1, v2, v3, v4, v5, v6, v7,
+ v8, v9, v10,v11,v12,v13,v14,v15
+ );
+ }
+
+ // Store to array
+ simdjson_inline void store(uint8_t dst[16]) const { return vst1q_u8(dst, *this); }
+
+ // Saturated math
+ simdjson_inline simd8 saturating_add(const simd8 other) const { return vqaddq_u8(*this, other); }
+ simdjson_inline simd8 saturating_sub(const simd8 other) const { return vqsubq_u8(*this, other); }
+
+ // Addition/subtraction are the same for signed and unsigned
+ simdjson_inline simd8 operator+(const simd8 other) const { return vaddq_u8(*this, other); }
+ simdjson_inline simd8 operator-(const simd8 other) const { return vsubq_u8(*this, other); }
+ simdjson_inline simd8& operator+=(const simd8 other) { *this = *this + other; return *this; }
+ simdjson_inline simd8& operator-=(const simd8 other) { *this = *this - other; return *this; }
+
+ // Order-specific operations
+ simdjson_inline uint8_t max_val() const { return vmaxvq_u8(*this); }
+ simdjson_inline uint8_t min_val() const { return vminvq_u8(*this); }
+ simdjson_inline simd8 max_val(const simd8 other) const { return vmaxq_u8(*this, other); }
+ simdjson_inline simd8 min_val(const simd8 other) const { return vminq_u8(*this, other); }
+ simdjson_inline simd8 operator<=(const simd8 other) const { return vcleq_u8(*this, other); }
+ simdjson_inline simd8 operator>=(const simd8 other) const { return vcgeq_u8(*this, other); }
+ simdjson_inline simd8 operator<(const simd8 other) const { return vcltq_u8(*this, other); }
+ simdjson_inline simd8 operator>(const simd8 other) const { return vcgtq_u8(*this, other); }
+ // Same as >, but instead of guaranteeing all 1's == true, false = 0 and true = nonzero. For ARM, returns all 1's.
+ simdjson_inline simd8 gt_bits(const simd8 other) const { return simd8(*this > other); }
+ // Same as <, but instead of guaranteeing all 1's == true, false = 0 and true = nonzero. For ARM, returns all 1's.
+ simdjson_inline simd8 lt_bits(const simd8 other) const { return simd8(*this < other); }
+
+ // Bit-specific operations
+ simdjson_inline simd8 any_bits_set(simd8 bits) const { return vtstq_u8(*this, bits); }
+ simdjson_inline bool any_bits_set_anywhere() const { return this->max_val() != 0; }
+ simdjson_inline bool any_bits_set_anywhere(simd8 bits) const { return (*this & bits).any_bits_set_anywhere(); }
+ template
+ simdjson_inline simd8 shr() const { return vshrq_n_u8(*this, N); }
+ template
+ simdjson_inline simd8 shl() const { return vshlq_n_u8(*this, N); }
+
+ // Perform a lookup assuming the value is between 0 and 16 (undefined behavior for out of range values)
+ template
+ simdjson_inline simd8 lookup_16(simd8 lookup_table) const {
+ return lookup_table.apply_lookup_16_to(*this);
+ }
+
+
+ // Copies to 'output" all bytes corresponding to a 0 in the mask (interpreted as a bitset).
+ // Passing a 0 value for mask would be equivalent to writing out every byte to output.
+ // Only the first 16 - count_ones(mask) bytes of the result are significant but 16 bytes
+ // get written.
+ // Design consideration: it seems like a function with the
+ // signature simd8 compress(uint16_t mask) would be
+ // sensible, but the AVX ISA makes this kind of approach difficult.
+ template
+ simdjson_inline void compress(uint16_t mask, L * output) const {
+ using internal::thintable_epi8;
+ using internal::BitsSetTable256mul2;
+ using internal::pshufb_combine_table;
+ // this particular implementation was inspired by work done by @animetosho
+ // we do it in two steps, first 8 bytes and then second 8 bytes
+ uint8_t mask1 = uint8_t(mask); // least significant 8 bits
+ uint8_t mask2 = uint8_t(mask >> 8); // most significant 8 bits
+ // next line just loads the 64-bit values thintable_epi8[mask1] and
+ // thintable_epi8[mask2] into a 128-bit register, using only
+ // two instructions on most compilers.
+ uint64x2_t shufmask64 = {thintable_epi8[mask1], thintable_epi8[mask2]};
+ uint8x16_t shufmask = vreinterpretq_u8_u64(shufmask64);
+ // we increment by 0x08 the second half of the mask
+#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
+ uint8x16_t inc = simdjson_make_uint8x16_t(0, 0, 0, 0, 0, 0, 0, 0, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08);
+#else
+ uint8x16_t inc = {0, 0, 0, 0, 0, 0, 0, 0, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08};
+#endif
+ shufmask = vaddq_u8(shufmask, inc);
+ // this is the version "nearly pruned"
+ uint8x16_t pruned = vqtbl1q_u8(*this, shufmask);
+ // we still need to put the two halves together.
+ // we compute the popcount of the first half:
+ int pop1 = BitsSetTable256mul2[mask1];
+ // then load the corresponding mask, what it does is to write
+ // only the first pop1 bytes from the first 8 bytes, and then
+ // it fills in with the bytes from the second 8 bytes + some filling
+ // at the end.
+ uint8x16_t compactmask = vld1q_u8(reinterpret_cast(pshufb_combine_table + pop1 * 8));
+ uint8x16_t answer = vqtbl1q_u8(pruned, compactmask);
+ vst1q_u8(reinterpret_cast(output), answer);
+ }
+
+ // Copies all bytes corresponding to a 0 in the low half of the mask (interpreted as a
+ // bitset) to output1, then those corresponding to a 0 in the high half to output2.
+ template
+ simdjson_inline void compress_halves(uint16_t mask, L *output1, L *output2) const {
+ using internal::thintable_epi8;
+ uint8_t mask1 = uint8_t(mask); // least significant 8 bits
+ uint8_t mask2 = uint8_t(mask >> 8); // most significant 8 bits
+ uint8x8_t compactmask1 = vcreate_u8(thintable_epi8[mask1]);
+ uint8x8_t compactmask2 = vcreate_u8(thintable_epi8[mask2]);
+ // we increment by 0x08 the second half of the mask
+#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
+ uint8x8_t inc = simdjson_make_uint8x8_t(0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08);
+#else
+ uint8x8_t inc = {0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08};
+#endif
+ compactmask2 = vadd_u8(compactmask2, inc);
+ // store each result (with the second store possibly overlapping the first)
+ vst1_u8((uint8_t*)output1, vqtbl1_u8(*this, compactmask1));
+ vst1_u8((uint8_t*)output2, vqtbl1_u8(*this, compactmask2));
+ }
+
+ template
+ simdjson_inline simd8 lookup_16(
+ L replace0, L replace1, L replace2, L replace3,
+ L replace4, L replace5, L replace6, L replace7,
+ L replace8, L replace9, L replace10, L replace11,
+ L replace12, L replace13, L replace14, L replace15) const {
+ return lookup_16(simd8::repeat_16(
+ replace0, replace1, replace2, replace3,
+ replace4, replace5, replace6, replace7,
+ replace8, replace9, replace10, replace11,
+ replace12, replace13, replace14, replace15
+ ));
+ }
+
+ template
+ simdjson_inline simd8 apply_lookup_16_to(const simd8 original) {
+ return vqtbl1q_u8(*this, simd8(original));
+ }
+ };
+
+ // Signed bytes
+ template<>
+ struct simd8 {
+ int8x16_t value;
+
+ static simdjson_inline simd8 splat(int8_t _value) { return vmovq_n_s8(_value); }
+ static simdjson_inline simd8 zero() { return vdupq_n_s8(0); }
+ static simdjson_inline simd8 load(const int8_t values[16]) { return vld1q_s8(values); }
+
+ // Conversion from/to SIMD register
+ simdjson_inline simd8(const int8x16_t _value) : value{_value} {}
+ simdjson_inline operator const int8x16_t&() const { return this->value; }
+ simdjson_inline operator int8x16_t&() { return this->value; }
+
+ // Zero constructor
+ simdjson_inline simd8() : simd8(zero()) {}
+ // Splat constructor
+ simdjson_inline simd8(int8_t _value) : simd8(splat(_value)) {}
+ // Array constructor
+ simdjson_inline simd8(const int8_t* values) : simd8(load(values)) {}
+ // Member-by-member initialization
+#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
+ simdjson_inline simd8(
+ int8_t v0, int8_t v1, int8_t v2, int8_t v3, int8_t v4, int8_t v5, int8_t v6, int8_t v7,
+ int8_t v8, int8_t v9, int8_t v10, int8_t v11, int8_t v12, int8_t v13, int8_t v14, int8_t v15
+ ) : simd8(simdjson_make_int8x16_t(
+ v0, v1, v2, v3, v4, v5, v6, v7,
+ v8, v9, v10,v11,v12,v13,v14,v15
+ )) {}
+#else
+ simdjson_inline simd8(
+ int8_t v0, int8_t v1, int8_t v2, int8_t v3, int8_t v4, int8_t v5, int8_t v6, int8_t v7,
+ int8_t v8, int8_t v9, int8_t v10, int8_t v11, int8_t v12, int8_t v13, int8_t v14, int8_t v15
+ ) : simd8(int8x16_t{
+ v0, v1, v2, v3, v4, v5, v6, v7,
+ v8, v9, v10,v11,v12,v13,v14,v15
+ }) {}
+#endif
+ // Repeat 16 values as many times as necessary (usually for lookup tables)
+ simdjson_inline static simd8 repeat_16(
+ int8_t v0, int8_t v1, int8_t v2, int8_t v3, int8_t v4, int8_t v5, int8_t v6, int8_t v7,
+ int8_t v8, int8_t v9, int8_t v10, int8_t v11, int8_t v12, int8_t v13, int8_t v14, int8_t v15
+ ) {
+ return simd8(
+ v0, v1, v2, v3, v4, v5, v6, v7,
+ v8, v9, v10,v11,v12,v13,v14,v15
+ );
+ }
+
+ // Store to array
+ simdjson_inline void store(int8_t dst[16]) const { return vst1q_s8(dst, *this); }
+
+ // Explicit conversion to/from unsigned
+ //
+ // Under Visual Studio/ARM64 uint8x16_t and int8x16_t are apparently the same type.
+ // In theory, we could check this occurrence with std::same_as and std::enabled_if but it is C++14
+ // and relatively ugly and hard to read.
+#ifndef SIMDJSON_REGULAR_VISUAL_STUDIO
+ simdjson_inline explicit simd8(const uint8x16_t other): simd8(vreinterpretq_s8_u8(other)) {}
+#endif
+ simdjson_inline explicit operator simd8() const { return vreinterpretq_u8_s8(this->value); }
+
+ // Math
+ simdjson_inline simd8 operator+(const simd8 other) const { return vaddq_s8(*this, other); }
+ simdjson_inline simd8 operator-(const simd8 other) const { return vsubq_s8(*this, other); }
+ simdjson_inline simd8& operator+=(const simd8 other) { *this = *this + other; return *this; }
+ simdjson_inline simd8& operator-=(const simd8 other) { *this = *this - other; return *this; }
+
+ // Order-sensitive comparisons
+ simdjson_inline simd8 max_val(const simd8 other) const { return vmaxq_s8(*this, other); }
+ simdjson_inline simd8 min_val(const simd8 other) const { return vminq_s8(*this, other); }
+ simdjson_inline simd8 operator>(const simd8 other) const { return vcgtq_s8(*this, other); }
+ simdjson_inline simd8 operator<(const simd8 other) const { return vcltq_s8(*this, other); }
+ simdjson_inline simd8 operator==(const simd8 other) const { return vceqq_s8(*this, other); }
+
+ template
+ simdjson_inline simd8 prev(const simd8 prev_chunk) const {
+ return vextq_s8(prev_chunk, *this, 16 - N);
+ }
+
+ // Perform a lookup assuming no value is larger than 16
+ template
+ simdjson_inline simd8 lookup_16(simd8 lookup_table) const {
+ return lookup_table.apply_lookup_16_to(*this);
+ }
+ template
+ simdjson_inline simd8 lookup_16(
+ L replace0, L replace1, L replace2, L replace3,
+ L replace4, L replace5, L replace6, L replace7,
+ L replace8, L replace9, L replace10, L replace11,
+ L replace12, L replace13, L replace14, L replace15) const {
+ return lookup_16(simd8::repeat_16(
+ replace0, replace1, replace2, replace3,
+ replace4, replace5, replace6, replace7,
+ replace8, replace9, replace10, replace11,
+ replace12, replace13, replace14, replace15
+ ));
+ }
+
+ template
+ simdjson_inline simd8 apply_lookup_16_to(const simd8 original) {
+ return vqtbl1q_s8(*this, simd8(original));
+ }
+ };
+
+ template
+ struct simd8x64 {
+ static constexpr int NUM_CHUNKS = 64 / sizeof(simd8);
+ static_assert(NUM_CHUNKS == 4, "ARM kernel should use four registers per 64-byte block.");
+ const simd8 chunks[NUM_CHUNKS];
+
+ simd8x64(const simd8x64& o) = delete; // no copy allowed
+ simd8x64& operator=(const simd8& other) = delete; // no assignment allowed
+ simd8x64() = delete; // no default constructor allowed
+
+ simdjson_inline simd8x64(const simd8 chunk0, const simd8 chunk1, const simd8 chunk2, const simd8 chunk3) : chunks{chunk0, chunk1, chunk2, chunk3} {}
+ simdjson_inline simd8x64(const T ptr[64]) : chunks{simd8::load(ptr), simd8::load(ptr+16), simd8::load(ptr+32), simd8::load(ptr+48)} {}
+
+ simdjson_inline void store(T ptr[64]) const {
+ this->chunks[0].store(ptr+sizeof(simd8)*0);
+ this->chunks[1].store(ptr+sizeof(simd8)*1);
+ this->chunks[2].store(ptr+sizeof(simd8)*2);
+ this->chunks[3].store(ptr+sizeof(simd8)*3);
+ }
+
+ simdjson_inline simd8 reduce_or() const {
+ return (this->chunks[0] | this->chunks[1]) | (this->chunks[2] | this->chunks[3]);
+ }
+
+
+ simdjson_inline uint64_t compress(uint64_t mask, T * output) const {
+ uint64_t popcounts = vget_lane_u64(vreinterpret_u64_u8(vcnt_u8(vcreate_u8(~mask))), 0);
+ // compute the prefix sum of the popcounts of each byte
+ uint64_t offsets = popcounts * 0x0101010101010101;
+ this->chunks[0].compress_halves(uint16_t(mask), output, &output[popcounts & 0xFF]);
+ this->chunks[1].compress_halves(uint16_t(mask >> 16), &output[(offsets >> 8) & 0xFF], &output[(offsets >> 16) & 0xFF]);
+ this->chunks[2].compress_halves(uint16_t(mask >> 32), &output[(offsets >> 24) & 0xFF], &output[(offsets >> 32) & 0xFF]);
+ this->chunks[3].compress_halves(uint16_t(mask >> 48), &output[(offsets >> 40) & 0xFF], &output[(offsets >> 48) & 0xFF]);
+ return offsets >> 56;
+ }
+
+ simdjson_inline uint64_t to_bitmask() const {
+#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
+ const uint8x16_t bit_mask = simdjson_make_uint8x16_t(
+ 0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80,
+ 0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80
+ );
+#else
+ const uint8x16_t bit_mask = {
+ 0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80,
+ 0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80
+ };
+#endif
+ // Add each of the elements next to each other, successively, to stuff each 8 byte mask into one.
+ uint8x16_t sum0 = vpaddq_u8(this->chunks[0] & bit_mask, this->chunks[1] & bit_mask);
+ uint8x16_t sum1 = vpaddq_u8(this->chunks[2] & bit_mask, this->chunks[3] & bit_mask);
+ sum0 = vpaddq_u8(sum0, sum1);
+ sum0 = vpaddq_u8(sum0, sum0);
+ return vgetq_lane_u64(vreinterpretq_u64_u8(sum0), 0);
+ }
+
+ simdjson_inline uint64_t eq(const T m) const {
+ const simd8 mask = simd8::splat(m);
+ return simd8x64(
+ this->chunks[0] == mask,
+ this->chunks[1] == mask,
+ this->chunks[2] == mask,
+ this->chunks[3] == mask
+ ).to_bitmask();
+ }
+
+ simdjson_inline uint64_t lteq(const T m) const {
+ const simd8 mask = simd8::splat(m);
+ return simd8x64(
+ this->chunks[0] <= mask,
+ this->chunks[1] <= mask,
+ this->chunks[2] <= mask,
+ this->chunks[3] <= mask
+ ).to_bitmask();
+ }
+ }; // struct simd8x64
+
+} // namespace simd
+} // unnamed namespace
+} // namespace arm64
+} // namespace simdjson
+
+#endif // SIMDJSON_ARM64_SIMD_H
diff --git a/contrib/libs/simdjson/include/simdjson/arm64/stringparsing_defs.h b/contrib/libs/simdjson/include/simdjson/arm64/stringparsing_defs.h
new file mode 100644
index 000000000000..30d02faff3f9
--- /dev/null
+++ b/contrib/libs/simdjson/include/simdjson/arm64/stringparsing_defs.h
@@ -0,0 +1,53 @@
+#ifndef SIMDJSON_ARM64_STRINGPARSING_DEFS_H
+#define SIMDJSON_ARM64_STRINGPARSING_DEFS_H
+
+#ifndef SIMDJSON_CONDITIONAL_INCLUDE
+#include "simdjson/arm64/base.h"
+#include "simdjson/arm64/simd.h"
+#include "simdjson/arm64/bitmanipulation.h"
+#endif // SIMDJSON_CONDITIONAL_INCLUDE
+
+namespace simdjson {
+namespace arm64 {
+namespace {
+
+using namespace simd;
+
+// Holds backslashes and quotes locations.
+struct backslash_and_quote {
+public:
+ static constexpr uint32_t BYTES_PROCESSED = 32;
+ simdjson_inline static backslash_and_quote copy_and_find(const uint8_t *src, uint8_t *dst);
+
+ simdjson_inline bool has_quote_first() { return ((bs_bits - 1) & quote_bits) != 0; }
+ simdjson_inline bool has_backslash() { return bs_bits != 0; }
+ simdjson_inline int quote_index() { return trailing_zeroes(quote_bits); }
+ simdjson_inline int backslash_index() { return trailing_zeroes(bs_bits); }
+
+ uint32_t bs_bits;
+ uint32_t quote_bits;
+}; // struct backslash_and_quote
+
+simdjson_inline backslash_and_quote backslash_and_quote::copy_and_find(const uint8_t *src, uint8_t *dst) {
+ // this can read up to 31 bytes beyond the buffer size, but we require
+ // SIMDJSON_PADDING of padding
+ static_assert(SIMDJSON_PADDING >= (BYTES_PROCESSED - 1), "backslash and quote finder must process fewer than SIMDJSON_PADDING bytes");
+ simd8 v0(src);
+ simd8 v1(src + sizeof(v0));
+ v0.store(dst);
+ v1.store(dst + sizeof(v0));
+
+ // Getting a 64-bit bitmask is much cheaper than multiple 16-bit bitmasks on ARM; therefore, we
+ // smash them together into a 64-byte mask and get the bitmask from there.
+ uint64_t bs_and_quote = simd8x64(v0 == '\\', v1 == '\\', v0 == '"', v1 == '"').to_bitmask();
+ return {
+ uint32_t(bs_and_quote), // bs_bits
+ uint32_t(bs_and_quote >> 32) // quote_bits
+ };
+}
+
+} // unnamed namespace
+} // namespace arm64
+} // namespace simdjson
+
+#endif // SIMDJSON_ARM64_STRINGPARSING_DEFS_H
diff --git a/contrib/libs/simdjson/include/simdjson/base.h b/contrib/libs/simdjson/include/simdjson/base.h
new file mode 100644
index 000000000000..a73b84bd082e
--- /dev/null
+++ b/contrib/libs/simdjson/include/simdjson/base.h
@@ -0,0 +1,60 @@
+/**
+ * @file Base declarations for all simdjson headers
+ * @private
+ */
+#ifndef SIMDJSON_BASE_H
+#define SIMDJSON_BASE_H
+
+#include "simdjson/common_defs.h"
+#include "simdjson/compiler_check.h"
+#include "simdjson/error.h"
+#include "simdjson/portability.h"
+
+/**
+ * @brief The top level simdjson namespace, containing everything the library provides.
+ */
+namespace simdjson {
+
+SIMDJSON_PUSH_DISABLE_UNUSED_WARNINGS
+
+/** The maximum document size supported by simdjson. */
+constexpr size_t SIMDJSON_MAXSIZE_BYTES = 0xFFFFFFFF;
+
+/**
+ * The amount of padding needed in a buffer to parse JSON.
+ *
+ * The input buf should be readable up to buf + SIMDJSON_PADDING
+ * this is a stopgap; there should be a better description of the
+ * main loop and its behavior that abstracts over this
+ * See https://github.com/simdjson/simdjson/issues/174
+ */
+constexpr size_t SIMDJSON_PADDING = 64;
+
+/**
+ * By default, simdjson supports this many nested objects and arrays.
+ *
+ * This is the default for parser::max_depth().
+ */
+constexpr size_t DEFAULT_MAX_DEPTH = 1024;
+
+SIMDJSON_POP_DISABLE_UNUSED_WARNINGS
+
+class implementation;
+struct padded_string;
+class padded_string_view;
+enum class stage1_mode;
+
+namespace internal {
+
+template
+class atomic_ptr;
+class dom_parser_implementation;
+class escape_json_string;
+class tape_ref;
+struct value128;
+enum class tape_type;
+
+} // namespace internal
+} // namespace simdjson
+
+#endif // SIMDJSON_BASE_H
diff --git a/contrib/libs/simdjson/include/simdjson/builtin.h b/contrib/libs/simdjson/include/simdjson/builtin.h
new file mode 100644
index 000000000000..4788007f88c9
--- /dev/null
+++ b/contrib/libs/simdjson/include/simdjson/builtin.h
@@ -0,0 +1,33 @@
+#ifndef SIMDJSON_BUILTIN_H
+#define SIMDJSON_BUILTIN_H
+
+#include "simdjson/builtin/base.h"
+#include "simdjson/builtin/implementation.h"
+
+#include "simdjson/generic/dependencies.h"
+
+#define SIMDJSON_CONDITIONAL_INCLUDE
+
+#if SIMDJSON_BUILTIN_IMPLEMENTATION_IS(arm64)
+#include "simdjson/arm64.h"
+#elif SIMDJSON_BUILTIN_IMPLEMENTATION_IS(fallback)
+#include "simdjson/fallback.h"
+#elif SIMDJSON_BUILTIN_IMPLEMENTATION_IS(haswell)
+#include "simdjson/haswell.h"
+#elif SIMDJSON_BUILTIN_IMPLEMENTATION_IS(icelake)
+#include "simdjson/icelake.h"
+#elif SIMDJSON_BUILTIN_IMPLEMENTATION_IS(ppc64)
+#include "simdjson/ppc64.h"
+#elif SIMDJSON_BUILTIN_IMPLEMENTATION_IS(westmere)
+#include "simdjson/westmere.h"
+#elif SIMDJSON_BUILTIN_IMPLEMENTATION_IS(lsx)
+#include "simdjson/lsx.h"
+#elif SIMDJSON_BUILTIN_IMPLEMENTATION_IS(lasx)
+#include "simdjson/lasx.h"
+#else
+#error Unknown SIMDJSON_BUILTIN_IMPLEMENTATION
+#endif
+
+#undef SIMDJSON_CONDITIONAL_INCLUDE
+
+#endif // SIMDJSON_BUILTIN_H
diff --git a/contrib/libs/simdjson/include/simdjson/builtin/base.h b/contrib/libs/simdjson/include/simdjson/builtin/base.h
new file mode 100644
index 000000000000..ce1678013e48
--- /dev/null
+++ b/contrib/libs/simdjson/include/simdjson/builtin/base.h
@@ -0,0 +1,41 @@
+#ifndef SIMDJSON_BUILTIN_BASE_H
+#define SIMDJSON_BUILTIN_BASE_H
+
+#include "simdjson/base.h"
+#include "simdjson/implementation_detection.h"
+
+namespace simdjson {
+#if SIMDJSON_BUILTIN_IMPLEMENTATION_IS(arm64)
+ namespace arm64 {}
+#elif SIMDJSON_BUILTIN_IMPLEMENTATION_IS(fallback)
+ namespace fallback {}
+#elif SIMDJSON_BUILTIN_IMPLEMENTATION_IS(haswell)
+ namespace haswell {}
+#elif SIMDJSON_BUILTIN_IMPLEMENTATION_IS(icelake)
+ namespace icelake {}
+#elif SIMDJSON_BUILTIN_IMPLEMENTATION_IS(ppc64)
+ namespace ppc64 {}
+#elif SIMDJSON_BUILTIN_IMPLEMENTATION_IS(westmere)
+ namespace westmere {}
+#elif SIMDJSON_BUILTIN_IMPLEMENTATION_IS(lsx)
+ namespace lsx {}
+#elif SIMDJSON_BUILTIN_IMPLEMENTATION_IS(lasx)
+ namespace lasx {}
+#else
+#error Unknown SIMDJSON_BUILTIN_IMPLEMENTATION
+#endif
+
+ /**
+ * Represents the best statically linked simdjson implementation that can be used by the compiling
+ * program.
+ *
+ * Detects what options the program is compiled against, and picks the minimum implementation that
+ * will work on any computer that can run the program. For example, if you compile with g++
+ * -march=westmere, it will pick the westmere implementation. The haswell implementation will
+ * still be available, and can be selected at runtime, but the builtin implementation (and any
+ * code that uses it) will use westmere.
+ */
+ namespace builtin = SIMDJSON_BUILTIN_IMPLEMENTATION;
+} // namespace simdjson
+
+#endif // SIMDJSON_BUILTIN_BASE_H
diff --git a/contrib/libs/simdjson/include/simdjson/builtin/implementation.h b/contrib/libs/simdjson/include/simdjson/builtin/implementation.h
new file mode 100644
index 000000000000..68a175d07ae3
--- /dev/null
+++ b/contrib/libs/simdjson/include/simdjson/builtin/implementation.h
@@ -0,0 +1,42 @@
+#ifndef SIMDJSON_BUILTIN_IMPLEMENTATION_H
+#define SIMDJSON_BUILTIN_IMPLEMENTATION_H
+
+#include "simdjson/builtin/base.h"
+
+#include "simdjson/generic/dependencies.h"
+
+#define SIMDJSON_CONDITIONAL_INCLUDE
+
+#if SIMDJSON_BUILTIN_IMPLEMENTATION_IS(arm64)
+#include "simdjson/arm64/implementation.h"
+#elif SIMDJSON_BUILTIN_IMPLEMENTATION_IS(fallback)
+#include "simdjson/fallback/implementation.h"
+#elif SIMDJSON_BUILTIN_IMPLEMENTATION_IS(haswell)
+#include "simdjson/haswell/implementation.h"
+#elif SIMDJSON_BUILTIN_IMPLEMENTATION_IS(icelake)
+#include "simdjson/icelake/implementation.h"
+#elif SIMDJSON_BUILTIN_IMPLEMENTATION_IS(ppc64)
+#error #include "simdjson/ppc64/implementation.h"
+#elif SIMDJSON_BUILTIN_IMPLEMENTATION_IS(westmere)
+#include "simdjson/westmere/implementation.h"
+#elif SIMDJSON_BUILTIN_IMPLEMENTATION_IS(lsx)
+#include "simdjson/lsx/implementation.h"
+#elif SIMDJSON_BUILTIN_IMPLEMENTATION_IS(lasx)
+#include "simdjson/lasx/implementation.h"
+#else
+#error Unknown SIMDJSON_BUILTIN_IMPLEMENTATION
+#endif
+
+#undef SIMDJSON_CONDITIONAL_INCLUDE
+
+namespace simdjson {
+ /**
+ * Function which returns a pointer to an implementation matching the "builtin" implementation.
+ * The builtin implementation is the best statically linked simdjson implementation that can be used by the compiling
+ * program. If you compile with g++ -march=haswell, this will return the haswell implementation.
+ * It is handy to be able to check what builtin was used: builtin_implementation()->name().
+ */
+ const implementation * builtin_implementation();
+} // namespace simdjson
+
+#endif // SIMDJSON_BUILTIN_IMPLEMENTATION_H
\ No newline at end of file
diff --git a/contrib/libs/simdjson/include/simdjson/builtin/ondemand.h b/contrib/libs/simdjson/include/simdjson/builtin/ondemand.h
new file mode 100644
index 000000000000..483fa8760adf
--- /dev/null
+++ b/contrib/libs/simdjson/include/simdjson/builtin/ondemand.h
@@ -0,0 +1,40 @@
+#ifndef SIMDJSON_BUILTIN_ONDEMAND_H
+#define SIMDJSON_BUILTIN_ONDEMAND_H
+
+#include "simdjson/builtin.h"
+#include "simdjson/builtin/base.h"
+
+#include "simdjson/generic/ondemand/dependencies.h"
+
+#define SIMDJSON_CONDITIONAL_INCLUDE
+
+#if SIMDJSON_BUILTIN_IMPLEMENTATION_IS(arm64)
+#include "simdjson/arm64/ondemand.h"
+#elif SIMDJSON_BUILTIN_IMPLEMENTATION_IS(fallback)
+#include "simdjson/fallback/ondemand.h"
+#elif SIMDJSON_BUILTIN_IMPLEMENTATION_IS(haswell)
+#include "simdjson/haswell/ondemand.h"
+#elif SIMDJSON_BUILTIN_IMPLEMENTATION_IS(icelake)
+#include "simdjson/icelake/ondemand.h"
+#elif SIMDJSON_BUILTIN_IMPLEMENTATION_IS(ppc64)
+#error #include "simdjson/ppc64/ondemand.h"
+#elif SIMDJSON_BUILTIN_IMPLEMENTATION_IS(westmere)
+#include "simdjson/westmere/ondemand.h"
+#elif SIMDJSON_BUILTIN_IMPLEMENTATION_IS(lsx)
+#include "simdjson/lsx/ondemand.h"
+#elif SIMDJSON_BUILTIN_IMPLEMENTATION_IS(lasx)
+#include "simdjson/lasx/ondemand.h"
+#else
+#error Unknown SIMDJSON_BUILTIN_IMPLEMENTATION
+#endif
+
+#undef SIMDJSON_CONDITIONAL_INCLUDE
+
+namespace simdjson {
+ /**
+ * @copydoc simdjson::SIMDJSON_BUILTIN_IMPLEMENTATION::ondemand
+ */
+ namespace ondemand = SIMDJSON_BUILTIN_IMPLEMENTATION::ondemand;
+} // namespace simdjson
+
+#endif // SIMDJSON_BUILTIN_ONDEMAND_H
\ No newline at end of file
diff --git a/contrib/libs/simdjson/include/simdjson/common_defs.h b/contrib/libs/simdjson/include/simdjson/common_defs.h
new file mode 100644
index 000000000000..d0ae083ecba9
--- /dev/null
+++ b/contrib/libs/simdjson/include/simdjson/common_defs.h
@@ -0,0 +1,347 @@
+#ifndef SIMDJSON_COMMON_DEFS_H
+#define SIMDJSON_COMMON_DEFS_H
+
+#include
+#include "simdjson/compiler_check.h"
+#include "simdjson/portability.h"
+
+namespace simdjson {
+namespace internal {
+/**
+ * @private
+ * Our own implementation of the C++17 to_chars function.
+ * Defined in src/to_chars
+ */
+char *to_chars(char *first, const char *last, double value);
+/**
+ * @private
+ * A number parsing routine.
+ * Defined in src/from_chars
+ */
+double from_chars(const char *first) noexcept;
+double from_chars(const char *first, const char* end) noexcept;
+}
+
+#ifndef SIMDJSON_EXCEPTIONS
+#if __cpp_exceptions
+#define SIMDJSON_EXCEPTIONS 1
+#else
+#define SIMDJSON_EXCEPTIONS 0
+#endif
+#endif
+
+} // namespace simdjson
+
+#if defined(__GNUC__)
+ // Marks a block with a name so that MCA analysis can see it.
+ #define SIMDJSON_BEGIN_DEBUG_BLOCK(name) __asm volatile("# LLVM-MCA-BEGIN " #name);
+ #define SIMDJSON_END_DEBUG_BLOCK(name) __asm volatile("# LLVM-MCA-END " #name);
+ #define SIMDJSON_DEBUG_BLOCK(name, block) BEGIN_DEBUG_BLOCK(name); block; END_DEBUG_BLOCK(name);
+#else
+ #define SIMDJSON_BEGIN_DEBUG_BLOCK(name)
+ #define SIMDJSON_END_DEBUG_BLOCK(name)
+ #define SIMDJSON_DEBUG_BLOCK(name, block)
+#endif
+
+// Align to N-byte boundary
+#define SIMDJSON_ROUNDUP_N(a, n) (((a) + ((n)-1)) & ~((n)-1))
+#define SIMDJSON_ROUNDDOWN_N(a, n) ((a) & ~((n)-1))
+
+#define SIMDJSON_ISALIGNED_N(ptr, n) (((uintptr_t)(ptr) & ((n)-1)) == 0)
+
+#if SIMDJSON_REGULAR_VISUAL_STUDIO
+ // We could use [[deprecated]] but it requires C++14
+ #define simdjson_deprecated __declspec(deprecated)
+
+ #define simdjson_really_inline __forceinline
+ #define simdjson_never_inline __declspec(noinline)
+
+ #define simdjson_unused
+ #define simdjson_warn_unused
+
+ #ifndef simdjson_likely
+ #define simdjson_likely(x) x
+ #endif
+ #ifndef simdjson_unlikely
+ #define simdjson_unlikely(x) x
+ #endif
+
+ #define SIMDJSON_PUSH_DISABLE_WARNINGS __pragma(warning( push ))
+ #define SIMDJSON_PUSH_DISABLE_ALL_WARNINGS __pragma(warning( push, 0 ))
+ #define SIMDJSON_DISABLE_VS_WARNING(WARNING_NUMBER) __pragma(warning( disable : WARNING_NUMBER ))
+ // Get rid of Intellisense-only warnings (Code Analysis)
+ // Though __has_include is C++17, it is supported in Visual Studio 2017 or better (_MSC_VER>=1910).
+ #ifdef __has_include
+ #if __has_include()
+ #error #include
+ #define SIMDJSON_DISABLE_UNDESIRED_WARNINGS SIMDJSON_DISABLE_VS_WARNING(ALL_CPPCORECHECK_WARNINGS)
+ #endif
+ #endif
+
+ #ifndef SIMDJSON_DISABLE_UNDESIRED_WARNINGS
+ #define SIMDJSON_DISABLE_UNDESIRED_WARNINGS
+ #endif
+
+ #define SIMDJSON_DISABLE_DEPRECATED_WARNING SIMDJSON_DISABLE_VS_WARNING(4996)
+ #define SIMDJSON_DISABLE_STRICT_OVERFLOW_WARNING
+ #define SIMDJSON_POP_DISABLE_WARNINGS __pragma(warning( pop ))
+
+ #define SIMDJSON_PUSH_DISABLE_UNUSED_WARNINGS
+ #define SIMDJSON_POP_DISABLE_UNUSED_WARNINGS
+
+#else // SIMDJSON_REGULAR_VISUAL_STUDIO
+ // We could use [[deprecated]] but it requires C++14
+ #define simdjson_deprecated __attribute__((deprecated))
+
+ #define simdjson_really_inline inline __attribute__((always_inline))
+ #define simdjson_never_inline inline __attribute__((noinline))
+
+ #define simdjson_unused __attribute__((unused))
+ #define simdjson_warn_unused __attribute__((warn_unused_result))
+
+ #ifndef simdjson_likely
+ #define simdjson_likely(x) __builtin_expect(!!(x), 1)
+ #endif
+ #ifndef simdjson_unlikely
+ #define simdjson_unlikely(x) __builtin_expect(!!(x), 0)
+ #endif
+
+ #define SIMDJSON_PUSH_DISABLE_WARNINGS _Pragma("GCC diagnostic push")
+ // gcc doesn't seem to disable all warnings with all and extra, add warnings here as necessary
+ // We do it separately for clang since it has different warnings.
+ #ifdef __clang__
+ // clang is missing -Wmaybe-uninitialized.
+ #define SIMDJSON_PUSH_DISABLE_ALL_WARNINGS SIMDJSON_PUSH_DISABLE_WARNINGS \
+ SIMDJSON_DISABLE_GCC_WARNING(-Weffc++) \
+ SIMDJSON_DISABLE_GCC_WARNING(-Wall) \
+ SIMDJSON_DISABLE_GCC_WARNING(-Wconversion) \
+ SIMDJSON_DISABLE_GCC_WARNING(-Wextra) \
+ SIMDJSON_DISABLE_GCC_WARNING(-Wattributes) \
+ SIMDJSON_DISABLE_GCC_WARNING(-Wimplicit-fallthrough) \
+ SIMDJSON_DISABLE_GCC_WARNING(-Wnon-virtual-dtor) \
+ SIMDJSON_DISABLE_GCC_WARNING(-Wreturn-type) \
+ SIMDJSON_DISABLE_GCC_WARNING(-Wshadow) \
+ SIMDJSON_DISABLE_GCC_WARNING(-Wunused-parameter) \
+ SIMDJSON_DISABLE_GCC_WARNING(-Wunused-variable)
+ #else // __clang__
+ #define SIMDJSON_PUSH_DISABLE_ALL_WARNINGS SIMDJSON_PUSH_DISABLE_WARNINGS \
+ SIMDJSON_DISABLE_GCC_WARNING(-Weffc++) \
+ SIMDJSON_DISABLE_GCC_WARNING(-Wall) \
+ SIMDJSON_DISABLE_GCC_WARNING(-Wconversion) \
+ SIMDJSON_DISABLE_GCC_WARNING(-Wextra) \
+ SIMDJSON_DISABLE_GCC_WARNING(-Wattributes) \
+ SIMDJSON_DISABLE_GCC_WARNING(-Wimplicit-fallthrough) \
+ SIMDJSON_DISABLE_GCC_WARNING(-Wnon-virtual-dtor) \
+ SIMDJSON_DISABLE_GCC_WARNING(-Wreturn-type) \
+ SIMDJSON_DISABLE_GCC_WARNING(-Wshadow) \
+ SIMDJSON_DISABLE_GCC_WARNING(-Wunused-parameter) \
+ SIMDJSON_DISABLE_GCC_WARNING(-Wunused-variable) \
+ SIMDJSON_DISABLE_GCC_WARNING(-Wmaybe-uninitialized) \
+ SIMDJSON_DISABLE_GCC_WARNING(-Wformat-security)
+ #endif // __clang__
+
+ #define SIMDJSON_PRAGMA(P) _Pragma(#P)
+ #define SIMDJSON_DISABLE_GCC_WARNING(WARNING) SIMDJSON_PRAGMA(GCC diagnostic ignored #WARNING)
+ #if SIMDJSON_CLANG_VISUAL_STUDIO
+ #define SIMDJSON_DISABLE_UNDESIRED_WARNINGS SIMDJSON_DISABLE_GCC_WARNING(-Wmicrosoft-include)
+ #else
+ #define SIMDJSON_DISABLE_UNDESIRED_WARNINGS
+ #endif
+ #define SIMDJSON_DISABLE_DEPRECATED_WARNING SIMDJSON_DISABLE_GCC_WARNING(-Wdeprecated-declarations)
+ #define SIMDJSON_DISABLE_STRICT_OVERFLOW_WARNING SIMDJSON_DISABLE_GCC_WARNING(-Wstrict-overflow)
+ #define SIMDJSON_POP_DISABLE_WARNINGS _Pragma("GCC diagnostic pop")
+
+ #define SIMDJSON_PUSH_DISABLE_UNUSED_WARNINGS SIMDJSON_PUSH_DISABLE_WARNINGS \
+ SIMDJSON_DISABLE_GCC_WARNING(-Wunused)
+ #define SIMDJSON_POP_DISABLE_UNUSED_WARNINGS SIMDJSON_POP_DISABLE_WARNINGS
+
+
+
+#endif // MSC_VER
+
+#if defined(simdjson_inline)
+ // Prefer the user's definition of simdjson_inline; don't define it ourselves.
+#elif defined(__GNUC__) && !defined(__OPTIMIZE__)
+ // If optimizations are disabled, forcing inlining can lead to significant
+ // code bloat and high compile times. Don't use simdjson_really_inline for
+ // unoptimized builds.
+ #define simdjson_inline inline
+#else
+ // Force inlining for most simdjson functions.
+ #define simdjson_inline simdjson_really_inline
+#endif
+
+#if SIMDJSON_VISUAL_STUDIO
+ /**
+ * Windows users need to do some extra work when building
+ * or using a dynamic library (DLL). When building, we need
+ * to set SIMDJSON_DLLIMPORTEXPORT to __declspec(dllexport).
+ * When *using* the DLL, the user needs to set
+ * SIMDJSON_DLLIMPORTEXPORT __declspec(dllimport).
+ *
+ * Static libraries not need require such work.
+ *
+ * It does not matter here whether you are using
+ * the regular visual studio or clang under visual
+ * studio, you still need to handle these issues.
+ *
+ * Non-Windows systems do not have this complexity.
+ */
+ #if SIMDJSON_BUILDING_WINDOWS_DYNAMIC_LIBRARY
+ // We set SIMDJSON_BUILDING_WINDOWS_DYNAMIC_LIBRARY when we build a DLL under Windows.
+ // It should never happen that both SIMDJSON_BUILDING_WINDOWS_DYNAMIC_LIBRARY and
+ // SIMDJSON_USING_WINDOWS_DYNAMIC_LIBRARY are set.
+ #define SIMDJSON_DLLIMPORTEXPORT __declspec(dllexport)
+ #elif SIMDJSON_USING_WINDOWS_DYNAMIC_LIBRARY
+ // Windows user who call a dynamic library should set SIMDJSON_USING_WINDOWS_DYNAMIC_LIBRARY to 1.
+ #define SIMDJSON_DLLIMPORTEXPORT __declspec(dllimport)
+ #else
+ // We assume by default static linkage
+ #define SIMDJSON_DLLIMPORTEXPORT
+ #endif
+
+/**
+ * Workaround for the vcpkg package manager. Only vcpkg should
+ * ever touch the next line. The SIMDJSON_USING_LIBRARY macro is otherwise unused.
+ */
+#if SIMDJSON_USING_LIBRARY
+#define SIMDJSON_DLLIMPORTEXPORT __declspec(dllimport)
+#endif
+/**
+ * End of workaround for the vcpkg package manager.
+ */
+#else
+ #define SIMDJSON_DLLIMPORTEXPORT
+#endif
+
+// C++17 requires string_view.
+#if SIMDJSON_CPLUSPLUS17
+#define SIMDJSON_HAS_STRING_VIEW
+#include // by the standard, this has to be safe.
+#endif
+
+// This macro (__cpp_lib_string_view) has to be defined
+// for C++17 and better, but if it is otherwise defined,
+// we are going to assume that string_view is available
+// even if we do not have C++17 support.
+#ifdef __cpp_lib_string_view
+#define SIMDJSON_HAS_STRING_VIEW
+#endif
+
+// Some systems have string_view even if we do not have C++17 support,
+// and even if __cpp_lib_string_view is undefined, it is the case
+// with Apple clang version 11.
+// We must handle it. *This is important.*
+#ifndef SIMDJSON_HAS_STRING_VIEW
+#if defined __has_include
+// do not combine the next #if with the previous one (unsafe)
+#if __has_include ()
+// now it is safe to trigger the include
+#include // though the file is there, it does not follow that we got the implementation
+#if defined(_LIBCPP_STRING_VIEW)
+// Ah! So we under libc++ which under its Library Fundamentals Technical Specification, which preceded C++17,
+// included string_view.
+// This means that we have string_view *even though* we may not have C++17.
+#define SIMDJSON_HAS_STRING_VIEW
+#endif // _LIBCPP_STRING_VIEW
+#endif // __has_include ()
+#endif // defined __has_include
+#endif // def SIMDJSON_HAS_STRING_VIEW
+// end of complicated but important routine to try to detect string_view.
+
+//
+// Backfill std::string_view using nonstd::string_view on systems where
+// we expect that string_view is missing. Important: if we get this wrong,
+// we will end up with two string_view definitions and potential trouble.
+// That is why we work so hard above to avoid it.
+//
+#ifndef SIMDJSON_HAS_STRING_VIEW
+SIMDJSON_PUSH_DISABLE_ALL_WARNINGS
+#error #include "simdjson/nonstd/string_view.hpp"
+SIMDJSON_POP_DISABLE_WARNINGS
+
+namespace std {
+ using string_view = nonstd::string_view;
+}
+#endif // SIMDJSON_HAS_STRING_VIEW
+#undef SIMDJSON_HAS_STRING_VIEW // We are not going to need this macro anymore.
+
+/// If EXPR is an error, returns it.
+#define SIMDJSON_TRY(EXPR) { auto _err = (EXPR); if (_err) { return _err; } }
+
+// Unless the programmer has already set SIMDJSON_DEVELOPMENT_CHECKS,
+// we want to set it under debug builds. We detect a debug build
+// under Visual Studio when the _DEBUG macro is set. Under the other
+// compilers, we use the fact that they define __OPTIMIZE__ whenever
+// they allow optimizations.
+// It is possible that this could miss some cases where SIMDJSON_DEVELOPMENT_CHECKS
+// is helpful, but the programmer can set the macro SIMDJSON_DEVELOPMENT_CHECKS.
+// It could also wrongly set SIMDJSON_DEVELOPMENT_CHECKS (e.g., if the programmer
+// sets _DEBUG in a release build under Visual Studio, or if some compiler fails to
+// set the __OPTIMIZE__ macro).
+#ifndef SIMDJSON_DEVELOPMENT_CHECKS
+#ifdef _MSC_VER
+// Visual Studio seems to set _DEBUG for debug builds.
+#ifdef _DEBUG
+#define SIMDJSON_DEVELOPMENT_CHECKS 1
+#endif // _DEBUG
+#else // _MSC_VER
+// All other compilers appear to set __OPTIMIZE__ to a positive integer
+// when the compiler is optimizing.
+#ifndef __OPTIMIZE__
+#define SIMDJSON_DEVELOPMENT_CHECKS 1
+#endif // __OPTIMIZE__
+#endif // _MSC_VER
+#endif // SIMDJSON_DEVELOPMENT_CHECKS
+
+// The SIMDJSON_CHECK_EOF macro is a feature flag for the "don't require padding"
+// feature.
+
+#if SIMDJSON_CPLUSPLUS17
+// if we have C++, then fallthrough is a default attribute
+# define simdjson_fallthrough [[fallthrough]]
+// check if we have __attribute__ support
+#elif defined(__has_attribute)
+// check if we have the __fallthrough__ attribute
+#if __has_attribute(__fallthrough__)
+// we are good to go:
+# define simdjson_fallthrough __attribute__((__fallthrough__))
+#endif // __has_attribute(__fallthrough__)
+#endif // SIMDJSON_CPLUSPLUS17
+// on some systems, we simply do not have support for fallthrough, so use a default:
+#ifndef simdjson_fallthrough
+# define simdjson_fallthrough do {} while (0) /* fallthrough */
+#endif // simdjson_fallthrough
+
+#if SIMDJSON_DEVELOPMENT_CHECKS
+#define SIMDJSON_DEVELOPMENT_ASSERT(expr) do { assert ((expr)); } while (0)
+#else
+#define SIMDJSON_DEVELOPMENT_ASSERT(expr) do { } while (0)
+#endif
+
+#ifndef SIMDJSON_UTF8VALIDATION
+#define SIMDJSON_UTF8VALIDATION 1
+#endif
+
+#ifdef __has_include
+// How do we detect that a compiler supports vbmi2?
+// For sure if the following header is found, we are ok?
+#if __has_include()
+#define SIMDJSON_COMPILER_SUPPORTS_VBMI2 1
+#endif
+#endif
+
+#ifdef _MSC_VER
+#if _MSC_VER >= 1920
+// Visual Studio 2019 and up support VBMI2 under x64 even if the header
+// avx512vbmi2intrin.h is not found.
+#define SIMDJSON_COMPILER_SUPPORTS_VBMI2 1
+#endif
+#endif
+
+// By default, we allow AVX512.
+#ifndef SIMDJSON_AVX512_ALLOWED
+#define SIMDJSON_AVX512_ALLOWED 1
+#endif
+
+#endif // SIMDJSON_COMMON_DEFS_H
diff --git a/contrib/libs/simdjson/include/simdjson/compiler_check.h b/contrib/libs/simdjson/include/simdjson/compiler_check.h
new file mode 100644
index 000000000000..1d0d03d1545d
--- /dev/null
+++ b/contrib/libs/simdjson/include/simdjson/compiler_check.h
@@ -0,0 +1,53 @@
+#ifndef SIMDJSON_COMPILER_CHECK_H
+#define SIMDJSON_COMPILER_CHECK_H
+
+#ifndef __cplusplus
+#error simdjson requires a C++ compiler
+#endif
+
+#ifndef SIMDJSON_CPLUSPLUS
+#if defined(_MSVC_LANG) && !defined(__clang__)
+#define SIMDJSON_CPLUSPLUS (_MSC_VER == 1900 ? 201103L : _MSVC_LANG)
+#else
+#define SIMDJSON_CPLUSPLUS __cplusplus
+#endif
+#endif
+
+// C++ 23
+#if !defined(SIMDJSON_CPLUSPLUS23) && (SIMDJSON_CPLUSPLUS >= 202302L)
+#define SIMDJSON_CPLUSPLUS23 1
+#endif
+
+// C++ 20
+#if !defined(SIMDJSON_CPLUSPLUS20) && (SIMDJSON_CPLUSPLUS >= 202002L)
+#define SIMDJSON_CPLUSPLUS20 1
+#endif
+
+// C++ 17
+#if !defined(SIMDJSON_CPLUSPLUS17) && (SIMDJSON_CPLUSPLUS >= 201703L)
+#define SIMDJSON_CPLUSPLUS17 1
+#endif
+
+// C++ 14
+#if !defined(SIMDJSON_CPLUSPLUS14) && (SIMDJSON_CPLUSPLUS >= 201402L)
+#define SIMDJSON_CPLUSPLUS14 1
+#endif
+
+// C++ 11
+#if !defined(SIMDJSON_CPLUSPLUS11) && (SIMDJSON_CPLUSPLUS >= 201103L)
+#define SIMDJSON_CPLUSPLUS11 1
+#endif
+
+#ifndef SIMDJSON_CPLUSPLUS11
+#error simdjson requires a compiler compliant with the C++11 standard
+#endif
+
+#ifndef SIMDJSON_IF_CONSTEXPR
+#if SIMDJSON_CPLUSPLUS17
+#define SIMDJSON_IF_CONSTEXPR if constexpr
+#else
+#define SIMDJSON_IF_CONSTEXPR if
+#endif
+#endif
+
+#endif // SIMDJSON_COMPILER_CHECK_H
diff --git a/contrib/libs/simdjson/include/simdjson/dom.h b/contrib/libs/simdjson/include/simdjson/dom.h
new file mode 100644
index 000000000000..bcf22ac22dc4
--- /dev/null
+++ b/contrib/libs/simdjson/include/simdjson/dom.h
@@ -0,0 +1,23 @@
+#ifndef SIMDJSON_DOM_H
+#define SIMDJSON_DOM_H
+
+#include "simdjson/dom/base.h"
+#include "simdjson/dom/array.h"
+#include "simdjson/dom/document_stream.h"
+#include "simdjson/dom/document.h"
+#include "simdjson/dom/element.h"
+#include "simdjson/dom/object.h"
+#include "simdjson/dom/parser.h"
+#include "simdjson/dom/serialization.h"
+
+// Inline functions
+#include "simdjson/dom/array-inl.h"
+#include "simdjson/dom/document_stream-inl.h"
+#include "simdjson/dom/document-inl.h"
+#include "simdjson/dom/element-inl.h"
+#include "simdjson/dom/object-inl.h"
+#include "simdjson/dom/parser-inl.h"
+#include "simdjson/internal/tape_ref-inl.h"
+#include "simdjson/dom/serialization-inl.h"
+
+#endif // SIMDJSON_DOM_H
diff --git a/contrib/libs/simdjson/include/simdjson/dom/array-inl.h b/contrib/libs/simdjson/include/simdjson/dom/array-inl.h
new file mode 100644
index 000000000000..6a29ef855321
--- /dev/null
+++ b/contrib/libs/simdjson/include/simdjson/dom/array-inl.h
@@ -0,0 +1,181 @@
+#ifndef SIMDJSON_ARRAY_INL_H
+#define SIMDJSON_ARRAY_INL_H
+
+#include
+
+#include "simdjson/dom/base.h"
+#include "simdjson/dom/array.h"
+#include "simdjson/dom/element.h"
+#include "simdjson/error-inl.h"
+#include "simdjson/internal/tape_ref-inl.h"
+
+#include
+
+namespace simdjson {
+
+//
+// simdjson_result inline implementation
+//
+simdjson_inline simdjson_result::simdjson_result() noexcept
+ : internal::simdjson_result_base() {}
+simdjson_inline simdjson_result::simdjson_result(dom::array value) noexcept
+ : internal::simdjson_result_base(std::forward(value)) {}
+simdjson_inline simdjson_result::simdjson_result(error_code error) noexcept
+ : internal::simdjson_result_base(error) {}
+
+#if SIMDJSON_EXCEPTIONS
+
+inline dom::array::iterator simdjson_result::begin() const noexcept(false) {
+ if (error()) { throw simdjson_error(error()); }
+ return first.begin();
+}
+inline dom::array::iterator simdjson_result::end() const noexcept(false) {
+ if (error()) { throw simdjson_error(error()); }
+ return first.end();
+}
+inline size_t simdjson_result::size() const noexcept(false) {
+ if (error()) { throw simdjson_error(error()); }
+ return first.size();
+}
+
+#endif // SIMDJSON_EXCEPTIONS
+
+inline simdjson_result simdjson_result::at_pointer(std::string_view json_pointer) const noexcept {
+ if (error()) { return error(); }
+ return first.at_pointer(json_pointer);
+}
+inline simdjson_result simdjson_result::at(size_t index) const noexcept {
+ if (error()) { return error(); }
+ return first.at(index);
+}
+
+namespace dom {
+
+//
+// array inline implementation
+//
+simdjson_inline array::array() noexcept : tape{} {}
+simdjson_inline array::array(const internal::tape_ref &_tape) noexcept : tape{_tape} {}
+inline array::iterator array::begin() const noexcept {
+ SIMDJSON_DEVELOPMENT_ASSERT(tape.usable()); // https://github.com/simdjson/simdjson/issues/1914
+ return internal::tape_ref(tape.doc, tape.json_index + 1);
+}
+inline array::iterator array::end() const noexcept {
+ SIMDJSON_DEVELOPMENT_ASSERT(tape.usable()); // https://github.com/simdjson/simdjson/issues/1914
+ return internal::tape_ref(tape.doc, tape.after_element() - 1);
+}
+inline size_t array::size() const noexcept {
+ SIMDJSON_DEVELOPMENT_ASSERT(tape.usable()); // https://github.com/simdjson/simdjson/issues/1914
+ return tape.scope_count();
+}
+inline size_t array::number_of_slots() const noexcept {
+ SIMDJSON_DEVELOPMENT_ASSERT(tape.usable()); // https://github.com/simdjson/simdjson/issues/1914
+ return tape.matching_brace_index() - tape.json_index;
+}
+inline simdjson_result array::at_pointer(std::string_view json_pointer) const noexcept {
+ SIMDJSON_DEVELOPMENT_ASSERT(tape.usable()); // https://github.com/simdjson/simdjson/issues/1914
+ if(json_pointer.empty()) { // an empty string means that we return the current node
+ return element(this->tape); // copy the current node
+ } else if(json_pointer[0] != '/') { // otherwise there is an error
+ return INVALID_JSON_POINTER;
+ }
+ json_pointer = json_pointer.substr(1);
+ // - means "the append position" or "the element after the end of the array"
+ // We don't support this, because we're returning a real element, not a position.
+ if (json_pointer == "-") { return INDEX_OUT_OF_BOUNDS; }
+
+ // Read the array index
+ size_t array_index = 0;
+ size_t i;
+ for (i = 0; i < json_pointer.length() && json_pointer[i] != '/'; i++) {
+ uint8_t digit = uint8_t(json_pointer[i] - '0');
+ // Check for non-digit in array index. If it's there, we're trying to get a field in an object
+ if (digit > 9) { return INCORRECT_TYPE; }
+ array_index = array_index*10 + digit;
+ }
+
+ // 0 followed by other digits is invalid
+ if (i > 1 && json_pointer[0] == '0') { return INVALID_JSON_POINTER; } // "JSON pointer array index has other characters after 0"
+
+ // Empty string is invalid; so is a "/" with no digits before it
+ if (i == 0) { return INVALID_JSON_POINTER; } // "Empty string in JSON pointer array index"
+
+ // Get the child
+ auto child = array(tape).at(array_index);
+ // If there is an error, it ends here
+ if(child.error()) {
+ return child;
+ }
+ // If there is a /, we're not done yet, call recursively.
+ if (i < json_pointer.length()) {
+ child = child.at_pointer(json_pointer.substr(i));
+ }
+ return child;
+}
+
+inline simdjson_result array::at(size_t index) const noexcept {
+ SIMDJSON_DEVELOPMENT_ASSERT(tape.usable()); // https://github.com/simdjson/simdjson/issues/1914
+ size_t i=0;
+ for (auto element : *this) {
+ if (i == index) { return element; }
+ i++;
+ }
+ return INDEX_OUT_OF_BOUNDS;
+}
+
+inline array::operator element() const noexcept {
+ return element(tape);
+}
+
+//
+// array::iterator inline implementation
+//
+simdjson_inline array::iterator::iterator(const internal::tape_ref &_tape) noexcept : tape{_tape} { }
+inline element array::iterator::operator*() const noexcept {
+ return element(tape);
+}
+inline array::iterator& array::iterator::operator++() noexcept {
+ tape.json_index = tape.after_element();
+ return *this;
+}
+inline array::iterator array::iterator::operator++(int) noexcept {
+ array::iterator out = *this;
+ ++*this;
+ return out;
+}
+inline bool array::iterator::operator!=(const array::iterator& other) const noexcept {
+ return tape.json_index != other.tape.json_index;
+}
+inline bool array::iterator::operator==(const array::iterator& other) const noexcept {
+ return tape.json_index == other.tape.json_index;
+}
+inline bool array::iterator::operator<(const array::iterator& other) const noexcept {
+ return tape.json_index < other.tape.json_index;
+}
+inline bool array::iterator::operator<=(const array::iterator& other) const noexcept {
+ return tape.json_index <= other.tape.json_index;
+}
+inline bool array::iterator::operator>=(const array::iterator& other) const noexcept {
+ return tape.json_index >= other.tape.json_index;
+}
+inline bool array::iterator::operator>(const array::iterator& other) const noexcept {
+ return tape.json_index > other.tape.json_index;
+}
+
+} // namespace dom
+
+
+} // namespace simdjson
+
+#include "simdjson/dom/element-inl.h"
+
+#if defined(__cpp_lib_ranges)
+static_assert(std::ranges::view);
+static_assert(std::ranges::sized_range);
+#if SIMDJSON_EXCEPTIONS
+static_assert(std::ranges::view>);
+static_assert(std::ranges::sized_range>);
+#endif // SIMDJSON_EXCEPTIONS
+#endif // defined(__cpp_lib_ranges)
+
+#endif // SIMDJSON_ARRAY_INL_H
diff --git a/contrib/libs/simdjson/include/simdjson/dom/array.h b/contrib/libs/simdjson/include/simdjson/dom/array.h
new file mode 100644
index 000000000000..a90813a4504f
--- /dev/null
+++ b/contrib/libs/simdjson/include/simdjson/dom/array.h
@@ -0,0 +1,183 @@
+#ifndef SIMDJSON_DOM_ARRAY_H
+#define SIMDJSON_DOM_ARRAY_H
+
+#include "simdjson/dom/base.h"
+#include "simdjson/internal/tape_ref.h"
+
+namespace simdjson {
+namespace dom {
+
+/**
+ * JSON array.
+ */
+class array {
+public:
+ /** Create a new, invalid array */
+ simdjson_inline array() noexcept;
+
+ class iterator {
+ public:
+ using value_type = element;
+ using difference_type = std::ptrdiff_t;
+ using pointer = void;
+ using reference = value_type;
+ using iterator_category = std::forward_iterator_tag;
+
+ /**
+ * Get the actual value
+ */
+ inline reference operator*() const noexcept;
+ /**
+ * Get the next value.
+ *
+ * Part of the std::iterator interface.
+ */
+ inline iterator& operator++() noexcept;
+ /**
+ * Get the next value.
+ *
+ * Part of the std::iterator interface.
+ */
+ inline iterator operator++(int) noexcept;
+ /**
+ * Check if these values come from the same place in the JSON.
+ *
+ * Part of the std::iterator interface.
+ */
+ inline bool operator!=(const iterator& other) const noexcept;
+ inline bool operator==(const iterator& other) const noexcept;
+
+ inline bool operator<(const iterator& other) const noexcept;
+ inline bool operator<=(const iterator& other) const noexcept;
+ inline bool operator>=(const iterator& other) const noexcept;
+ inline bool operator>(const iterator& other) const noexcept;
+
+ iterator() noexcept = default;
+ iterator(const iterator&) noexcept = default;
+ iterator& operator=(const iterator&) noexcept = default;
+ private:
+ simdjson_inline iterator(const internal::tape_ref &tape) noexcept;
+ internal::tape_ref tape;
+ friend class array;
+ };
+
+ /**
+ * Return the first array element.
+ *
+ * Part of the std::iterable interface.
+ */
+ inline iterator begin() const noexcept;
+ /**
+ * One past the last array element.
+ *
+ * Part of the std::iterable interface.
+ */
+ inline iterator end() const noexcept;
+ /**
+ * Get the size of the array (number of immediate children).
+ * It is a saturated value with a maximum of 0xFFFFFF: if the value
+ * is 0xFFFFFF then the size is 0xFFFFFF or greater.
+ */
+ inline size_t size() const noexcept;
+ /**
+ * Get the total number of slots used by this array on the tape.
+ *
+ * Note that this is not the same thing as `size()`, which reports the
+ * number of actual elements within an array (not counting its children).
+ *
+ * Since an element can use 1 or 2 slots on the tape, you can only use this
+ * to figure out the total size of an array (including its children,
+ * recursively) if you know its structure ahead of time.
+ **/
+ inline size_t number_of_slots() const noexcept;
+ /**
+ * Get the value associated with the given JSON pointer. We use the RFC 6901
+ * https://tools.ietf.org/html/rfc6901 standard, interpreting the current node
+ * as the root of its own JSON document.
+ *
+ * dom::parser parser;
+ * array a = parser.parse(R"([ { "foo": { "a": [ 10, 20, 30 ] }} ])"_padded);
+ * a.at_pointer("/0/foo/a/1") == 20
+ * a.at_pointer("0")["foo"]["a"].at(1) == 20
+ *
+ * @return The value associated with the given JSON pointer, or:
+ * - NO_SUCH_FIELD if a field does not exist in an object
+ * - INDEX_OUT_OF_BOUNDS if an array index is larger than an array length
+ * - INCORRECT_TYPE if a non-integer is used to access an array
+ * - INVALID_JSON_POINTER if the JSON pointer is invalid and cannot be parsed
+ */
+ inline simdjson_result at_pointer(std::string_view json_pointer) const noexcept;
+
+ /**
+ * Get the value at the given index. This function has linear-time complexity and
+ * is equivalent to the following:
+ *
+ * size_t i=0;
+ * for (auto element : *this) {
+ * if (i == index) { return element; }
+ * i++;
+ * }
+ * return INDEX_OUT_OF_BOUNDS;
+ *
+ * Avoid calling the at() function repeatedly.
+ *
+ * @return The value at the given index, or:
+ * - INDEX_OUT_OF_BOUNDS if the array index is larger than an array length
+ */
+ inline simdjson_result at(size_t index) const noexcept;
+
+ /**
+ * Implicitly convert object to element
+ */
+ inline operator element() const noexcept;
+
+private:
+ simdjson_inline array(const internal::tape_ref &tape) noexcept;
+ internal::tape_ref tape;
+ friend class element;
+ friend struct simdjson_result;
+ template
+ friend class simdjson::internal::string_builder;
+};
+
+
+} // namespace dom
+
+/** The result of a JSON conversion that may fail. */
+template<>
+struct simdjson_result : public internal::simdjson_result_base {
+public:
+ simdjson_inline simdjson_result() noexcept; ///< @private
+ simdjson_inline simdjson_result(dom::array value) noexcept; ///< @private
+ simdjson_inline simdjson_result(error_code error) noexcept; ///< @private
+
+ inline simdjson_result at_pointer(std::string_view json_pointer) const noexcept;
+ inline simdjson_result at(size_t index) const noexcept;
+
+#if SIMDJSON_EXCEPTIONS
+ inline dom::array::iterator begin() const noexcept(false);
+ inline dom::array::iterator end() const noexcept(false);
+ inline size_t size() const noexcept(false);
+#endif // SIMDJSON_EXCEPTIONS
+};
+
+
+
+} // namespace simdjson
+
+#if defined(__cpp_lib_ranges)
+#include
+
+namespace std {
+namespace ranges {
+template<>
+inline constexpr bool enable_view = true;
+#if SIMDJSON_EXCEPTIONS
+template<>
+inline constexpr bool enable_view> = true;
+#endif // SIMDJSON_EXCEPTIONS
+} // namespace ranges
+} // namespace std
+#endif // defined(__cpp_lib_ranges)
+
+#endif // SIMDJSON_DOM_ARRAY_H
diff --git a/contrib/libs/simdjson/include/simdjson/dom/base.h b/contrib/libs/simdjson/include/simdjson/dom/base.h
new file mode 100644
index 000000000000..b862277a2113
--- /dev/null
+++ b/contrib/libs/simdjson/include/simdjson/dom/base.h
@@ -0,0 +1,54 @@
+#ifndef SIMDJSON_DOM_BASE_H
+#define SIMDJSON_DOM_BASE_H
+
+#include "simdjson/base.h"
+
+namespace simdjson {
+
+/**
+ * @brief A DOM API on top of the simdjson parser.
+ */
+namespace dom {
+
+/** The default batch size for parser.parse_many() and parser.load_many() */
+static constexpr size_t DEFAULT_BATCH_SIZE = 1000000;
+/**
+ * Some adversary might try to set the batch size to 0 or 1, which might cause problems.
+ * We set a minimum of 32B since anything else is highly likely to be an error. In practice,
+ * most users will want a much larger batch size.
+ *
+ * All non-negative MINIMAL_BATCH_SIZE values should be 'safe' except that, obviously, no JSON
+ * document can ever span 0 or 1 byte and that very large values would create memory allocation issues.
+ */
+static constexpr size_t MINIMAL_BATCH_SIZE = 32;
+
+/**
+ * It is wasteful to allocate memory for tiny documents (e.g., 4 bytes).
+ */
+static constexpr size_t MINIMAL_DOCUMENT_CAPACITY = 32;
+
+class array;
+class document;
+class document_stream;
+class element;
+class key_value_pair;
+class object;
+class parser;
+
+#ifdef SIMDJSON_THREADS_ENABLED
+struct stage1_worker;
+#endif // SIMDJSON_THREADS_ENABLED
+
+} // namespace dom
+
+namespace internal {
+
+template
+class string_builder;
+class tape_ref;
+
+} // namespace internal
+
+} // namespace simdjson
+
+#endif // SIMDJSON_DOM_BASE_H
\ No newline at end of file
diff --git a/contrib/libs/simdjson/include/simdjson/dom/document-inl.h b/contrib/libs/simdjson/include/simdjson/dom/document-inl.h
new file mode 100644
index 000000000000..40d74b999e0b
--- /dev/null
+++ b/contrib/libs/simdjson/include/simdjson/dom/document-inl.h
@@ -0,0 +1,159 @@
+#ifndef SIMDJSON_DOCUMENT_INL_H
+#define SIMDJSON_DOCUMENT_INL_H
+
+// Inline implementations go in here.
+
+#include "simdjson/dom/base.h"
+#include "simdjson/dom/document.h"
+#include "simdjson/dom/element-inl.h"
+#include "simdjson/internal/tape_ref-inl.h"
+#include "simdjson/internal/jsonformatutils.h"
+
+#include
+
+namespace simdjson {
+namespace dom {
+
+//
+// document inline implementation
+//
+inline element document::root() const noexcept {
+ return element(internal::tape_ref(this, 1));
+}
+simdjson_warn_unused
+inline size_t document::capacity() const noexcept {
+ return allocated_capacity;
+}
+
+simdjson_warn_unused
+inline error_code document::allocate(size_t capacity) noexcept {
+ if (capacity == 0) {
+ string_buf.reset();
+ tape.reset();
+ allocated_capacity = 0;
+ return SUCCESS;
+ }
+
+ // a pathological input like "[[[[..." would generate capacity tape elements, so
+ // need a capacity of at least capacity + 1, but it is also possible to do
+ // worse with "[7,7,7,7,6,7,7,7,6,7,7,6,[7,7,7,7,6,7,7,7,6,7,7,6,7,7,7,7,7,7,6"
+ //where capacity + 1 tape elements are
+ // generated, see issue https://github.com/simdjson/simdjson/issues/345
+ size_t tape_capacity = SIMDJSON_ROUNDUP_N(capacity + 3, 64);
+ // a document with only zero-length strings... could have capacity/3 string
+ // and we would need capacity/3 * 5 bytes on the string buffer
+ size_t string_capacity = SIMDJSON_ROUNDUP_N(5 * capacity / 3 + SIMDJSON_PADDING, 64);
+ string_buf.reset( new (std::nothrow) uint8_t[string_capacity]);
+ tape.reset(new (std::nothrow) uint64_t[tape_capacity]);
+ if(!(string_buf && tape)) {
+ allocated_capacity = 0;
+ string_buf.reset();
+ tape.reset();
+ return MEMALLOC;
+ }
+ // Technically the allocated_capacity might be larger than capacity
+ // so the next line is pessimistic.
+ allocated_capacity = capacity;
+ return SUCCESS;
+}
+
+inline bool document::dump_raw_tape(std::ostream &os) const noexcept {
+ uint32_t string_length;
+ size_t tape_idx = 0;
+ uint64_t tape_val = tape[tape_idx];
+ uint8_t type = uint8_t(tape_val >> 56);
+ os << tape_idx << " : " << type;
+ tape_idx++;
+ size_t how_many = 0;
+ if (type == 'r') {
+ how_many = size_t(tape_val & internal::JSON_VALUE_MASK);
+ } else {
+ // Error: no starting root node?
+ return false;
+ }
+ os << "\t// pointing to " << how_many << " (right after last node)\n";
+ uint64_t payload;
+ for (; tape_idx < how_many; tape_idx++) {
+ os << tape_idx << " : ";
+ tape_val = tape[tape_idx];
+ payload = tape_val & internal::JSON_VALUE_MASK;
+ type = uint8_t(tape_val >> 56);
+ switch (type) {
+ case '"': // we have a string
+ os << "string \"";
+ std::memcpy(&string_length, string_buf.get() + payload, sizeof(uint32_t));
+ os << internal::escape_json_string(std::string_view(
+ reinterpret_cast(string_buf.get() + payload + sizeof(uint32_t)),
+ string_length
+ ));
+ os << '"';
+ os << '\n';
+ break;
+ case 'l': // we have a long int
+ if (tape_idx + 1 >= how_many) {
+ return false;
+ }
+ os << "integer " << static_cast(tape[++tape_idx]) << "\n";
+ break;
+ case 'u': // we have a long uint
+ if (tape_idx + 1 >= how_many) {
+ return false;
+ }
+ os << "unsigned integer " << tape[++tape_idx] << "\n";
+ break;
+ case 'd': // we have a double
+ os << "float ";
+ if (tape_idx + 1 >= how_many) {
+ return false;
+ }
+ double answer;
+ std::memcpy(&answer, &tape[++tape_idx], sizeof(answer));
+ os << answer << '\n';
+ break;
+ case 'n': // we have a null
+ os << "null\n";
+ break;
+ case 't': // we have a true
+ os << "true\n";
+ break;
+ case 'f': // we have a false
+ os << "false\n";
+ break;
+ case '{': // we have an object
+ os << "{\t// pointing to next tape location " << uint32_t(payload)
+ << " (first node after the scope), "
+ << " saturated count "
+ << ((payload >> 32) & internal::JSON_COUNT_MASK)<< "\n";
+ break; case '}': // we end an object
+ os << "}\t// pointing to previous tape location " << uint32_t(payload)
+ << " (start of the scope)\n";
+ break;
+ case '[': // we start an array
+ os << "[\t// pointing to next tape location " << uint32_t(payload)
+ << " (first node after the scope), "
+ << " saturated count "
+ << ((payload >> 32) & internal::JSON_COUNT_MASK)<< "\n";
+ break;
+ case ']': // we end an array
+ os << "]\t// pointing to previous tape location " << uint32_t(payload)
+ << " (start of the scope)\n";
+ break;
+ case 'r': // we start and end with the root node
+ // should we be hitting the root node?
+ return false;
+ default:
+ return false;
+ }
+ }
+ tape_val = tape[tape_idx];
+ payload = tape_val & internal::JSON_VALUE_MASK;
+ type = uint8_t(tape_val >> 56);
+ os << tape_idx << " : " << type << "\t// pointing to " << payload
+ << " (start root)\n";
+ return true;
+}
+
+} // namespace dom
+} // namespace simdjson
+
+#endif // SIMDJSON_DOCUMENT_INL_H
diff --git a/contrib/libs/simdjson/include/simdjson/dom/document.h b/contrib/libs/simdjson/include/simdjson/dom/document.h
new file mode 100644
index 000000000000..6c5e284bb47f
--- /dev/null
+++ b/contrib/libs/simdjson/include/simdjson/dom/document.h
@@ -0,0 +1,91 @@
+#ifndef SIMDJSON_DOM_DOCUMENT_H
+#define SIMDJSON_DOM_DOCUMENT_H
+
+#include "simdjson/dom/base.h"
+
+#include
+
+namespace simdjson {
+namespace dom {
+
+/**
+ * A parsed JSON document.
+ *
+ * This class cannot be copied, only moved, to avoid unintended allocations.
+ */
+class document {
+public:
+ /**
+ * Create a document container with zero capacity.
+ *
+ * The parser will allocate capacity as needed.
+ */
+ document() noexcept = default;
+ ~document() noexcept = default;
+
+ /**
+ * Take another document's buffers.
+ *
+ * @param other The document to take. Its capacity is zeroed and it is invalidated.
+ */
+ document(document &&other) noexcept = default;
+ /** @private */
+ document(const document &) = delete; // Disallow copying
+ /**
+ * Take another document's buffers.
+ *
+ * @param other The document to take. Its capacity is zeroed.
+ */
+ document &operator=(document &&other) noexcept = default;
+ /** @private */
+ document &operator=(const document &) = delete; // Disallow copying
+
+ /**
+ * Get the root element of this document as a JSON array.
+ */
+ element root() const noexcept;
+
+ /**
+ * @private Dump the raw tape for debugging.
+ *
+ * @param os the stream to output to.
+ * @return false if the tape is likely wrong (e.g., you did not parse a valid JSON).
+ */
+ bool dump_raw_tape(std::ostream &os) const noexcept;
+
+ /** @private Structural values. */
+ std::unique_ptr tape{};
+
+ /** @private String values.
+ *
+ * Should be at least byte_capacity.
+ */
+ std::unique_ptr string_buf{};
+ /** @private Allocate memory to support
+ * input JSON documents of up to len bytes.
+ *
+ * When calling this function, you lose
+ * all the data.
+ *
+ * The memory allocation is strict: you
+ * can you use this function to increase
+ * or lower the amount of allocated memory.
+ * Passsing zero clears the memory.
+ */
+ error_code allocate(size_t len) noexcept;
+ /** @private Capacity in bytes, in terms
+ * of how many bytes of input JSON we can
+ * support.
+ */
+ size_t capacity() const noexcept;
+
+
+private:
+ size_t allocated_capacity{0};
+ friend class parser;
+}; // class document
+
+} // namespace dom
+} // namespace simdjson
+
+#endif // SIMDJSON_DOM_DOCUMENT_H
diff --git a/contrib/libs/simdjson/include/simdjson/dom/document_stream-inl.h b/contrib/libs/simdjson/include/simdjson/dom/document_stream-inl.h
new file mode 100644
index 000000000000..b7062481f217
--- /dev/null
+++ b/contrib/libs/simdjson/include/simdjson/dom/document_stream-inl.h
@@ -0,0 +1,348 @@
+#ifndef SIMDJSON_DOCUMENT_STREAM_INL_H
+#define SIMDJSON_DOCUMENT_STREAM_INL_H
+
+#include "simdjson/dom/base.h"
+#include "simdjson/dom/document_stream.h"
+#include "simdjson/dom/element-inl.h"
+#include "simdjson/dom/parser-inl.h"
+#include "simdjson/error-inl.h"
+#include "simdjson/internal/dom_parser_implementation.h"
+
+namespace simdjson {
+namespace dom {
+
+#ifdef SIMDJSON_THREADS_ENABLED
+
+inline void stage1_worker::finish() {
+ // After calling "run" someone would call finish() to wait
+ // for the end of the processing.
+ // This function will wait until either the thread has done
+ // the processing or, else, the destructor has been called.
+ std::unique_lock lock(locking_mutex);
+ cond_var.wait(lock, [this]{return has_work == false;});
+}
+
+inline stage1_worker::~stage1_worker() {
+ // The thread may never outlive the stage1_worker instance
+ // and will always be stopped/joined before the stage1_worker
+ // instance is gone.
+ stop_thread();
+}
+
+inline void stage1_worker::start_thread() {
+ std::unique_lock lock(locking_mutex);
+ if(thread.joinable()) {
+ return; // This should never happen but we never want to create more than one thread.
+ }
+ thread = std::thread([this]{
+ while(true) {
+ std::unique_lock thread_lock(locking_mutex);
+ // We wait for either "run" or "stop_thread" to be called.
+ cond_var.wait(thread_lock, [this]{return has_work || !can_work;});
+ // If, for some reason, the stop_thread() method was called (i.e., the
+ // destructor of stage1_worker is called, then we want to immediately destroy
+ // the thread (and not do any more processing).
+ if(!can_work) {
+ break;
+ }
+ this->owner->stage1_thread_error = this->owner->run_stage1(*this->stage1_thread_parser,
+ this->_next_batch_start);
+ this->has_work = false;
+ // The condition variable call should be moved after thread_lock.unlock() for performance
+ // reasons but thread sanitizers may report it as a data race if we do.
+ // See https://stackoverflow.com/questions/35775501/c-should-condition-variable-be-notified-under-lock
+ cond_var.notify_one(); // will notify "finish"
+ thread_lock.unlock();
+ }
+ }
+ );
+}
+
+
+inline void stage1_worker::stop_thread() {
+ std::unique_lock lock(locking_mutex);
+ // We have to make sure that all locks can be released.
+ can_work = false;
+ has_work = false;
+ cond_var.notify_all();
+ lock.unlock();
+ if(thread.joinable()) {
+ thread.join();
+ }
+}
+
+inline void stage1_worker::run(document_stream * ds, dom::parser * stage1, size_t next_batch_start) {
+ std::unique_lock lock(locking_mutex);
+ owner = ds;
+ _next_batch_start = next_batch_start;
+ stage1_thread_parser = stage1;
+ has_work = true;
+ // The condition variable call should be moved after thread_lock.unlock() for performance
+ // reasons but thread sanitizers may report it as a data race if we do.
+ // See https://stackoverflow.com/questions/35775501/c-should-condition-variable-be-notified-under-lock
+ cond_var.notify_one(); // will notify the thread lock that we have work
+ lock.unlock();
+}
+#endif
+
+simdjson_inline document_stream::document_stream(
+ dom::parser &_parser,
+ const uint8_t *_buf,
+ size_t _len,
+ size_t _batch_size
+) noexcept
+ : parser{&_parser},
+ buf{_buf},
+ len{_len},
+ batch_size{_batch_size <= MINIMAL_BATCH_SIZE ? MINIMAL_BATCH_SIZE : _batch_size},
+ error{SUCCESS}
+#ifdef SIMDJSON_THREADS_ENABLED
+ , use_thread(_parser.threaded) // we need to make a copy because _parser.threaded can change
+#endif
+{
+#ifdef SIMDJSON_THREADS_ENABLED
+ if(worker.get() == nullptr) {
+ error = MEMALLOC;
+ }
+#endif
+}
+
+simdjson_inline document_stream::document_stream() noexcept
+ : parser{nullptr},
+ buf{nullptr},
+ len{0},
+ batch_size{0},
+ error{UNINITIALIZED}
+#ifdef SIMDJSON_THREADS_ENABLED
+ , use_thread(false)
+#endif
+{
+}
+
+simdjson_inline document_stream::~document_stream() noexcept {
+#ifdef SIMDJSON_THREADS_ENABLED
+ worker.reset();
+#endif
+}
+
+simdjson_inline document_stream::iterator::iterator() noexcept
+ : stream{nullptr}, finished{true} {
+}
+
+simdjson_inline document_stream::iterator document_stream::begin() noexcept {
+ start();
+ // If there are no documents, we're finished.
+ return iterator(this, error == EMPTY);
+}
+
+simdjson_inline document_stream::iterator document_stream::end() noexcept {
+ return iterator(this, true);
+}
+
+simdjson_inline document_stream::iterator::iterator(document_stream* _stream, bool is_end) noexcept
+ : stream{_stream}, finished{is_end} {
+}
+
+simdjson_inline document_stream::iterator::reference document_stream::iterator::operator*() noexcept {
+ // Note that in case of error, we do not yet mark
+ // the iterator as "finished": this detection is done
+ // in the operator++ function since it is possible
+ // to call operator++ repeatedly while omitting
+ // calls to operator*.
+ if (stream->error) { return stream->error; }
+ return stream->parser->doc.root();
+}
+
+simdjson_inline document_stream::iterator& document_stream::iterator::operator++() noexcept {
+ // If there is an error, then we want the iterator
+ // to be finished, no matter what. (E.g., we do not
+ // keep generating documents with errors, or go beyond
+ // a document with errors.)
+ //
+ // Users do not have to call "operator*()" when they use operator++,
+ // so we need to end the stream in the operator++ function.
+ //
+ // Note that setting finished = true is essential otherwise
+ // we would enter an infinite loop.
+ if (stream->error) { finished = true; }
+ // Note that stream->error() is guarded against error conditions
+ // (it will immediately return if stream->error casts to false).
+ // In effect, this next function does nothing when (stream->error)
+ // is true (hence the risk of an infinite loop).
+ stream->next();
+ // If that was the last document, we're finished.
+ // It is the only type of error we do not want to appear
+ // in operator*.
+ if (stream->error == EMPTY) { finished = true; }
+ // If we had any other kind of error (not EMPTY) then we want
+ // to pass it along to the operator* and we cannot mark the result
+ // as "finished" just yet.
+ return *this;
+}
+
+simdjson_inline bool document_stream::iterator::operator!=(const document_stream::iterator &other) const noexcept {
+ return finished != other.finished;
+}
+
+inline void document_stream::start() noexcept {
+ if (error) { return; }
+ error = parser->ensure_capacity(batch_size);
+ if (error) { return; }
+ // Always run the first stage 1 parse immediately
+ batch_start = 0;
+ error = run_stage1(*parser, batch_start);
+ while(error == EMPTY) {
+ // In exceptional cases, we may start with an empty block
+ batch_start = next_batch_start();
+ if (batch_start >= len) { return; }
+ error = run_stage1(*parser, batch_start);
+ }
+ if (error) { return; }
+#ifdef SIMDJSON_THREADS_ENABLED
+ if (use_thread && next_batch_start() < len) {
+ // Kick off the first thread if needed
+ error = stage1_thread_parser.ensure_capacity(batch_size);
+ if (error) { return; }
+ worker->start_thread();
+ start_stage1_thread();
+ if (error) { return; }
+ }
+#endif // SIMDJSON_THREADS_ENABLED
+ next();
+}
+
+simdjson_inline size_t document_stream::iterator::current_index() const noexcept {
+ return stream->doc_index;
+}
+
+simdjson_inline std::string_view document_stream::iterator::source() const noexcept {
+ const char* start = reinterpret_cast(stream->buf) + current_index();
+ bool object_or_array = ((*start == '[') || (*start == '{'));
+ if(object_or_array) {
+ size_t next_doc_index = stream->batch_start + stream->parser->implementation->structural_indexes[stream->parser->implementation->next_structural_index - 1];
+ return std::string_view(start, next_doc_index - current_index() + 1);
+ } else {
+ size_t next_doc_index = stream->batch_start + stream->parser->implementation->structural_indexes[stream->parser->implementation->next_structural_index];
+ size_t svlen = next_doc_index - current_index();
+ while(svlen > 1 && (std::isspace(start[svlen-1]) || start[svlen-1] == '\0')) {
+ svlen--;
+ }
+ return std::string_view(start, svlen);
+ }
+}
+
+
+inline void document_stream::next() noexcept {
+ // We always exit at once, once in an error condition.
+ if (error) { return; }
+
+ // Load the next document from the batch
+ doc_index = batch_start + parser->implementation->structural_indexes[parser->implementation->next_structural_index];
+ error = parser->implementation->stage2_next(parser->doc);
+ // If that was the last document in the batch, load another batch (if available)
+ while (error == EMPTY) {
+ batch_start = next_batch_start();
+ if (batch_start >= len) { break; }
+
+#ifdef SIMDJSON_THREADS_ENABLED
+ if(use_thread) {
+ load_from_stage1_thread();
+ } else {
+ error = run_stage1(*parser, batch_start);
+ }
+#else
+ error = run_stage1(*parser, batch_start);
+#endif
+ if (error) { continue; } // If the error was EMPTY, we may want to load another batch.
+ // Run stage 2 on the first document in the batch
+ doc_index = batch_start + parser->implementation->structural_indexes[parser->implementation->next_structural_index];
+ error = parser->implementation->stage2_next(parser->doc);
+ }
+}
+inline size_t document_stream::size_in_bytes() const noexcept {
+ return len;
+}
+
+inline size_t document_stream::truncated_bytes() const noexcept {
+ if(error == CAPACITY) { return len - batch_start; }
+ return parser->implementation->structural_indexes[parser->implementation->n_structural_indexes] - parser->implementation->structural_indexes[parser->implementation->n_structural_indexes + 1];
+}
+
+inline size_t document_stream::next_batch_start() const noexcept {
+ return batch_start + parser->implementation->structural_indexes[parser->implementation->n_structural_indexes];
+}
+
+inline error_code document_stream::run_stage1(dom::parser &p, size_t _batch_start) noexcept {
+ size_t remaining = len - _batch_start;
+ if (remaining <= batch_size) {
+ return p.implementation->stage1(&buf[_batch_start], remaining, stage1_mode::streaming_final);
+ } else {
+ return p.implementation->stage1(&buf[_batch_start], batch_size, stage1_mode::streaming_partial);
+ }
+}
+
+#ifdef SIMDJSON_THREADS_ENABLED
+
+inline void document_stream::load_from_stage1_thread() noexcept {
+ worker->finish();
+ // Swap to the parser that was loaded up in the thread. Make sure the parser has
+ // enough memory to swap to, as well.
+ std::swap(*parser, stage1_thread_parser);
+ error = stage1_thread_error;
+ if (error) { return; }
+
+ // If there's anything left, start the stage 1 thread!
+ if (next_batch_start() < len) {
+ start_stage1_thread();
+ }
+}
+
+inline void document_stream::start_stage1_thread() noexcept {
+ // we call the thread on a lambda that will update
+ // this->stage1_thread_error
+ // there is only one thread that may write to this value
+ // TODO this is NOT exception-safe.
+ this->stage1_thread_error = UNINITIALIZED; // In case something goes wrong, make sure it's an error
+ size_t _next_batch_start = this->next_batch_start();
+
+ worker->run(this, & this->stage1_thread_parser, _next_batch_start);
+}
+
+#endif // SIMDJSON_THREADS_ENABLED
+
+} // namespace dom
+
+simdjson_inline simdjson_result::simdjson_result() noexcept
+ : simdjson_result_base() {
+}
+simdjson_inline simdjson_result::simdjson_result(error_code error) noexcept
+ : simdjson_result_base(error) {
+}
+simdjson_inline simdjson_result::simdjson_result(dom::document_stream &&value) noexcept
+ : simdjson_result_base(std::forward(value)) {
+}
+
+#if SIMDJSON_EXCEPTIONS
+simdjson_inline dom::document_stream::iterator simdjson_result::begin() noexcept(false) {
+ if (error()) { throw simdjson_error(error()); }
+ return first.begin();
+}
+simdjson_inline dom::document_stream::iterator simdjson_result::end() noexcept(false) {
+ if (error()) { throw simdjson_error(error()); }
+ return first.end();
+}
+#else // SIMDJSON_EXCEPTIONS
+#ifndef SIMDJSON_DISABLE_DEPRECATED_API
+simdjson_inline dom::document_stream::iterator simdjson_result::begin() noexcept {
+ first.error = error();
+ return first.begin();
+}
+simdjson_inline dom::document_stream::iterator simdjson_result::end() noexcept {
+ first.error = error();
+ return first.end();
+}
+#endif // SIMDJSON_DISABLE_DEPRECATED_API
+#endif // SIMDJSON_EXCEPTIONS
+
+} // namespace simdjson
+#endif // SIMDJSON_DOCUMENT_STREAM_INL_H
diff --git a/contrib/libs/simdjson/include/simdjson/dom/document_stream.h b/contrib/libs/simdjson/include/simdjson/dom/document_stream.h
new file mode 100644
index 000000000000..308f20e25ae0
--- /dev/null
+++ b/contrib/libs/simdjson/include/simdjson/dom/document_stream.h
@@ -0,0 +1,322 @@
+#ifndef SIMDJSON_DOCUMENT_STREAM_H
+#define SIMDJSON_DOCUMENT_STREAM_H
+
+#include "simdjson/dom/base.h"
+#include "simdjson/dom/parser.h"
+
+#ifdef SIMDJSON_THREADS_ENABLED
+#include
+#include
+#include
+#endif
+
+namespace simdjson {
+namespace dom {
+
+#ifdef SIMDJSON_THREADS_ENABLED
+/** @private Custom worker class **/
+struct stage1_worker {
+ stage1_worker() noexcept = default;
+ stage1_worker(const stage1_worker&) = delete;
+ stage1_worker(stage1_worker&&) = delete;
+ stage1_worker operator=(const stage1_worker&) = delete;
+ ~stage1_worker();
+ /**
+ * We only start the thread when it is needed, not at object construction, this may throw.
+ * You should only call this once.
+ **/
+ void start_thread();
+ /**
+ * Start a stage 1 job. You should first call 'run', then 'finish'.
+ * You must call start_thread once before.
+ */
+ void run(document_stream * ds, dom::parser * stage1, size_t next_batch_start);
+ /** Wait for the run to finish (blocking). You should first call 'run', then 'finish'. **/
+ void finish();
+
+private:
+
+ /**
+ * Normally, we would never stop the thread. But we do in the destructor.
+ * This function is only safe assuming that you are not waiting for results. You
+ * should have called run, then finish, and be done.
+ **/
+ void stop_thread();
+
+ std::thread thread{};
+ /** These three variables define the work done by the thread. **/
+ dom::parser * stage1_thread_parser{};
+ size_t _next_batch_start{};
+ document_stream * owner{};
+ /**
+ * We have two state variables. This could be streamlined to one variable in the future but
+ * we use two for clarity.
+ */
+ bool has_work{false};
+ bool can_work{true};
+
+ /**
+ * We lock using a mutex.
+ */
+ std::mutex locking_mutex{};
+ std::condition_variable cond_var{};
+};
+#endif
+
+/**
+ * A forward-only stream of documents.
+ *
+ * Produced by parser::parse_many.
+ *
+ */
+class document_stream {
+public:
+ /**
+ * Construct an uninitialized document_stream.
+ *
+ * ```c++
+ * document_stream docs;
+ * error = parser.parse_many(json).get(docs);
+ * ```
+ */
+ simdjson_inline document_stream() noexcept;
+ /** Move one document_stream to another. */
+ simdjson_inline document_stream(document_stream &&other) noexcept = default;
+ /** Move one document_stream to another. */
+ simdjson_inline document_stream &operator=(document_stream &&other) noexcept = default;
+
+ simdjson_inline ~document_stream() noexcept;
+ /**
+ * Returns the input size in bytes.
+ */
+ inline size_t size_in_bytes() const noexcept;
+ /**
+ * After iterating through the stream, this method
+ * returns the number of bytes that were not parsed at the end
+ * of the stream. If truncated_bytes() differs from zero,
+ * then the input was truncated maybe because incomplete JSON
+ * documents were found at the end of the stream. You
+ * may need to process the bytes in the interval [size_in_bytes()-truncated_bytes(), size_in_bytes()).
+ *
+ * You should only call truncated_bytes() after streaming through all
+ * documents, like so:
+ *
+ * document_stream stream = parser.parse_many(json,window);
+ * for(auto doc : stream) {
+ * // do something with doc
+ * }
+ * size_t truncated = stream.truncated_bytes();
+ *
+ */
+ inline size_t truncated_bytes() const noexcept;
+ /**
+ * An iterator through a forward-only stream of documents.
+ */
+ class iterator {
+ public:
+ using value_type = simdjson_result;
+ using reference = value_type;
+
+ using difference_type = std::ptrdiff_t;
+
+ using iterator_category = std::input_iterator_tag;
+
+ /**
+ * Default constructor.
+ */
+ simdjson_inline iterator() noexcept;
+ /**
+ * Get the current document (or error).
+ */
+ simdjson_inline reference operator*() noexcept;
+ /**
+ * Advance to the next document (prefix).
+ */
+ inline iterator& operator++() noexcept;
+ /**
+ * Check if we're at the end yet.
+ * @param other the end iterator to compare to.
+ */
+ simdjson_inline bool operator!=(const iterator &other) const noexcept;
+ /**
+ * @private
+ *
+ * Gives the current index in the input document in bytes.
+ *
+ * document_stream stream = parser.parse_many(json,window);
+ * for(auto i = stream.begin(); i != stream.end(); ++i) {
+ * auto doc = *i;
+ * size_t index = i.current_index();
+ * }
+ *
+ * This function (current_index()) is experimental and the usage
+ * may change in future versions of simdjson: we find the API somewhat
+ * awkward and we would like to offer something friendlier.
+ */
+ simdjson_inline size_t current_index() const noexcept;
+ /**
+ * @private
+ *
+ * Gives a view of the current document.
+ *
+ * document_stream stream = parser.parse_many(json,window);
+ * for(auto i = stream.begin(); i != stream.end(); ++i) {
+ * auto doc = *i;
+ * std::string_view v = i->source();
+ * }
+ *
+ * The returned string_view instance is simply a map to the (unparsed)
+ * source string: it may thus include white-space characters and all manner
+ * of padding.
+ *
+ * This function (source()) is experimental and the usage
+ * may change in future versions of simdjson: we find the API somewhat
+ * awkward and we would like to offer something friendlier.
+ */
+ simdjson_inline std::string_view source() const noexcept;
+
+ private:
+ simdjson_inline iterator(document_stream *s, bool finished) noexcept;
+ /** The document_stream we're iterating through. */
+ document_stream* stream;
+ /** Whether we're finished or not. */
+ bool finished;
+ friend class document_stream;
+ };
+
+ /**
+ * Start iterating the documents in the stream.
+ */
+ simdjson_inline iterator begin() noexcept;
+ /**
+ * The end of the stream, for iterator comparison purposes.
+ */
+ simdjson_inline iterator end() noexcept;
+
+private:
+
+ document_stream &operator=(const document_stream &) = delete; // Disallow copying
+ document_stream(const document_stream &other) = delete; // Disallow copying
+
+ /**
+ * Construct a document_stream. Does not allocate or parse anything until the iterator is
+ * used.
+ *
+ * @param parser is a reference to the parser instance used to generate this document_stream
+ * @param buf is the raw byte buffer we need to process
+ * @param len is the length of the raw byte buffer in bytes
+ * @param batch_size is the size of the windows (must be strictly greater or equal to the largest JSON document)
+ */
+ simdjson_inline document_stream(
+ dom::parser &parser,
+ const uint8_t *buf,
+ size_t len,
+ size_t batch_size
+ ) noexcept;
+
+ /**
+ * Parse the first document in the buffer. Used by begin(), to handle allocation and
+ * initialization.
+ */
+ inline void start() noexcept;
+
+ /**
+ * Parse the next document found in the buffer previously given to document_stream.
+ *
+ * The content should be a valid JSON document encoded as UTF-8. If there is a
+ * UTF-8 BOM, the parser skips it.
+ *
+ * You do NOT need to pre-allocate a parser. This function takes care of
+ * pre-allocating a capacity defined by the batch_size defined when creating the
+ * document_stream object.
+ *
+ * The function returns simdjson::EMPTY if there is no more data to be parsed.
+ *
+ * The function returns simdjson::SUCCESS (as integer = 0) in case of success
+ * and indicates that the buffer has successfully been parsed to the end.
+ * Every document it contained has been parsed without error.
+ *
+ * The function returns an error code from simdjson/simdjson.h in case of failure
+ * such as simdjson::CAPACITY, simdjson::MEMALLOC, simdjson::DEPTH_ERROR and so forth;
+ * the simdjson::error_message function converts these error codes into a string).
+ *
+ * You can also check validity by calling parser.is_valid(). The same parser can
+ * and should be reused for the other documents in the buffer.
+ */
+ inline void next() noexcept;
+
+ /**
+ * Pass the next batch through stage 1 and return when finished.
+ * When threads are enabled, this may wait for the stage 1 thread to finish.
+ */
+ inline void load_batch() noexcept;
+
+ /** Get the next document index. */
+ inline size_t next_batch_start() const noexcept;
+
+ /** Pass the next batch through stage 1 with the given parser. */
+ inline error_code run_stage1(dom::parser &p, size_t batch_start) noexcept;
+
+ dom::parser *parser;
+ const uint8_t *buf;
+ size_t len;
+ size_t batch_size;
+ /** The error (or lack thereof) from the current document. */
+ error_code error;
+ size_t batch_start{0};
+ size_t doc_index{};
+#ifdef SIMDJSON_THREADS_ENABLED
+ /** Indicates whether we use threads. Note that this needs to be a constant during the execution of the parsing. */
+ bool use_thread;
+
+ inline void load_from_stage1_thread() noexcept;
+
+ /** Start a thread to run stage 1 on the next batch. */
+ inline void start_stage1_thread() noexcept;
+
+ /** Wait for the stage 1 thread to finish and capture the results. */
+ inline void finish_stage1_thread() noexcept;
+
+ /** The error returned from the stage 1 thread. */
+ error_code stage1_thread_error{UNINITIALIZED};
+ /** The thread used to run stage 1 against the next batch in the background. */
+ friend struct stage1_worker;
+ std::unique_ptr worker{new(std::nothrow) stage1_worker()};
+ /**
+ * The parser used to run stage 1 in the background. Will be swapped
+ * with the regular parser when finished.
+ */
+ dom::parser stage1_thread_parser{};
+#endif // SIMDJSON_THREADS_ENABLED
+
+ friend class dom::parser;
+ friend struct simdjson_result;
+ friend struct internal::simdjson_result_base;
+
+}; // class document_stream
+
+} // namespace dom
+
+template<>
+struct simdjson_result : public internal::simdjson_result_base {
+public:
+ simdjson_inline simdjson_result() noexcept; ///< @private
+ simdjson_inline simdjson_result(error_code error) noexcept; ///< @private
+ simdjson_inline simdjson_result(dom::document_stream &&value) noexcept; ///< @private
+
+#if SIMDJSON_EXCEPTIONS
+ simdjson_inline dom::document_stream::iterator begin() noexcept(false);
+ simdjson_inline dom::document_stream::iterator end() noexcept(false);
+#else // SIMDJSON_EXCEPTIONS
+#ifndef SIMDJSON_DISABLE_DEPRECATED_API
+ [[deprecated("parse_many() and load_many() may return errors. Use document_stream stream; error = parser.parse_many().get(doc); instead.")]]
+ simdjson_inline dom::document_stream::iterator begin() noexcept;
+ [[deprecated("parse_many() and load_many() may return errors. Use document_stream stream; error = parser.parse_many().get(doc); instead.")]]
+ simdjson_inline dom::document_stream::iterator end() noexcept;
+#endif // SIMDJSON_DISABLE_DEPRECATED_API
+#endif // SIMDJSON_EXCEPTIONS
+}; // struct simdjson_result
+
+} // namespace simdjson
+
+#endif // SIMDJSON_DOCUMENT_STREAM_H
diff --git a/contrib/libs/simdjson/include/simdjson/dom/element-inl.h b/contrib/libs/simdjson/include/simdjson/dom/element-inl.h
new file mode 100644
index 000000000000..cab313beb901
--- /dev/null
+++ b/contrib/libs/simdjson/include/simdjson/dom/element-inl.h
@@ -0,0 +1,473 @@
+#ifndef SIMDJSON_ELEMENT_INL_H
+#define SIMDJSON_ELEMENT_INL_H
+
+#include "simdjson/dom/base.h"
+#include "simdjson/dom/element.h"
+#include "simdjson/dom/document.h"
+#include "simdjson/dom/object.h"
+#include "simdjson/internal/tape_type.h"
+
+#include "simdjson/dom/object-inl.h"
+#include "simdjson/error-inl.h"
+
+#include
+#include
+
+namespace simdjson {
+
+//
+// simdjson_result inline implementation
+//
+simdjson_inline simdjson_result::simdjson_result() noexcept
+ : internal::simdjson_result_base() {}
+simdjson_inline simdjson_result