Compare commits

..

26 Commits

Author SHA1 Message Date
Daniel Lemire 41ea5eebff Silly compiler. 2023-03-13 12:50:46 -04:00
Daniel Lemire 63a4133db0 Merge branch 'master' into dlemire/issue1965 2023-03-13 12:30:12 -04:00
Daniel Lemire 7bf33f6c8a Bad compiler 2023-03-13 12:29:01 -04:00
Daniel Lemire d62b789cb3 More curly. 2023-03-13 10:49:15 -04:00
Daniel Lemire 63d384068e Update developer-options.cmake 2023-03-13 10:13:30 -04:00
Daniel Lemire 33dbd44098 Better way to put -Og in debug mode (#1967)
* Better way to put -Og in debug mode

* Silly compiler

* Stupid compiler.

* Stupid compiler.

* Silly compiler
2023-03-13 10:11:33 -04:00
Daniel Lemire 1469b6677b Unnecessary fixes 2023-03-13 09:46:07 -04:00
Daniel Lemire 4ca892ac57 Stupid compilers 2023-03-12 21:16:43 -04:00
Daniel Lemire e0dcf8adc9 Silly compiler 2023-03-12 20:57:45 -04:00
Daniel Lemire 13c7366817 Silly compiler 2023-03-10 22:04:56 -05:00
Daniel Lemire 296ae0b755 Stupid compiler 2023-03-09 14:09:50 -05:00
Daniel Lemire f6237ec0da Adding test. 2023-03-09 12:23:28 -05:00
Daniel Lemire 3e68899d30 Fix macro 2023-03-09 12:03:02 -05:00
Daniel Lemire 7c1412855c Might help with issue 1965 2023-03-09 11:58:11 -05:00
Daniel Lemire 34dcd33a88 Patch. 2023-03-09 11:24:06 -05:00
Daniel Lemire 17a1a8e187 Adding -Og to debug builds. (#1964)
* Adding -Og to debug builds.

* Stupid compiler.

* bad, bad, bad compiler
2023-03-09 11:14:42 -05:00
Daniel Lemire 77ad00b63c Producing a minor patch release 2023-03-09 11:13:01 -05:00
Daniel Lemire 25e7f1765a Various tweaks. 2023-03-09 10:42:23 -05:00
Daniel Lemire 8d01255ceb Update basics.md 2023-03-09 08:27:32 -05:00
Daniel Lemire 8ec016b093 Update README.md 2023-03-08 15:30:52 -05:00
Daniel Lemire 9e726b9856 Removing obsolete badge 2023-03-08 14:50:37 -05:00
Daniel Lemire 312f1f26d3 Now obsolete. 2023-03-08 14:50:06 -05:00
Daniel Lemire ba50571d66 Merge branch 'master' of github.com:simdjson/simdjson 2023-03-06 16:05:10 -05:00
Daniel Lemire 4a587cb898 Adding guards. 2023-03-06 16:04:42 -05:00
Daniel Lemire bdf9123c92 Update README.md 2023-03-06 11:08:56 -05:00
Dominik Lohmann 6e4c29b7c5 Fix export component for simdjsonTargets.cmake (#1962)
This fixes a bug that caused simdjsonTargets.cmake not to be included in
CPack-generated packages, which—unlike `cmake --install`—does not
pick up this mislabeled install component.

I git-grepped through the code base, after this change all components
are either `simdjson_Development` or `simdjson_Runtime`.
2023-03-04 17:34:40 -05:00
35 changed files with 190 additions and 185 deletions
-29
View File
@@ -1,29 +0,0 @@
name: Performance check on Ubuntu 18.04 CI (GCC 7)
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
ubuntu-build:
if: >-
! contains(toJSON(github.event.commits.*.message), '[skip ci]') &&
! contains(toJSON(github.event.commits.*.message), '[skip github]')
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: dependencies/.cache
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
- name: Use cmake
run: |
mkdir build &&
cd build &&
cmake -DSIMDJSON_DEVELOPER_MODE=ON -DSIMDJSON_ENABLE_DOM_CHECKPERF=ON -DSIMDJSON_GOOGLE_BENCHMARKS=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX:PATH=destination .. &&
cmake --build . --target checkperf &&
ctest --output-on-failure -R checkperf ubuntu18-checkperf.yml
-31
View File
@@ -1,31 +0,0 @@
name: Ubuntu 18.04 CI (LLVM 7)
on: [push, pull_request]
jobs:
ubuntu-build:
if: >-
! contains(toJSON(github.event.commits.*.message), '[skip ci]') &&
! contains(toJSON(github.event.commits.*.message), '[skip github]')
runs-on: ubuntu-18.04
env:
CC: clang-7
CXX: clang++-7
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: dependencies/.cache
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
- name: install clang 7
run: |
sudo apt update
sudo apt install clang-7
- name: Use cmake
run: |
mkdir build &&
cd build &&
cmake -DSIMDJSON_DEVELOPER_MODE=ON -DSIMDJSON_GOOGLE_BENCHMARKS=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX:PATH=destination .. &&
cmake --build . &&
ctest -j --output-on-failure -LE explicitonly
-25
View File
@@ -1,25 +0,0 @@
name: Ubuntu 18.04 CI (GCC 7) with Thread Sanitizer
on: [push, pull_request]
jobs:
ubuntu-build:
if: >-
! contains(toJSON(github.event.commits.*.message), '[skip ci]') &&
! contains(toJSON(github.event.commits.*.message), '[skip github]')
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: dependencies/.cache
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
- name: Use cmake
run: |
mkdir build &&
cd build &&
cmake -DSIMDJSON_DEVELOPER_MODE=ON -DSIMDJSON_SANITIZE_THREADS=ON .. &&
cmake --build . --target document_stream_tests --target ondemand_document_stream_tests --target parse_many_test &&
ctest --output-on-failure -R parse_many_test &&
ctest --output-on-failure -R document_stream_tests
-25
View File
@@ -1,25 +0,0 @@
name: Ubuntu 18.04 CI (GCC 7)
on: [push, pull_request]
jobs:
ubuntu-build:
if: >-
! contains(toJSON(github.event.commits.*.message), '[skip ci]') &&
! contains(toJSON(github.event.commits.*.message), '[skip github]')
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: dependencies/.cache
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
- name: Use cmake
run: |
mkdir build &&
cd build &&
cmake -DSIMDJSON_DEVELOPER_MODE=ON -DSIMDJSON_GOOGLE_BENCHMARKS=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX:PATH=destination .. &&
cmake --build . &&
ctest -j --output-on-failure -LE explicitonly &&
make install &&
echo -e '#include <simdjson.h>\nint main(int argc,char**argv) {simdjson::dom::parser parser;simdjson::dom::element tweets = parser.load(argv[1]); }' > tmp.cpp && c++ -Idestination/include -Ldestination/lib -std=c++17 -Wl,-rpath,destination/lib -o linkandrun tmp.cpp -lsimdjson && ./linkandrun jsonexamples/twitter.json
+17 -2
View File
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.14)
project(
simdjson
# The version number is modified by tools/release.py
VERSION 3.1.3
VERSION 3.1.5
DESCRIPTION "Parsing gigabytes of JSON per second"
HOMEPAGE_URL "https://simdjson.org/"
LANGUAGES CXX C
@@ -95,6 +95,21 @@ if(
)
endif()
# GCC and Clang have horrendous Debug builds when using SIMD.
# A common fix is to use '-Og' instead.
# bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54412
if(
(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR
CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR
CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
)
message(STATUS "Adding -Og to compile flag")
simdjson_add_props(
target_compile_options PRIVATE
$<$<CONFIG:DEBUG>:-Og>
)
endif()
if(SIMDJSON_ENABLE_THREADS)
find_package(Threads REQUIRED)
simdjson_add_props(target_link_libraries PUBLIC Threads::Threads)
@@ -149,7 +164,7 @@ install(
EXPORT simdjsonTargets
NAMESPACE simdjson::
DESTINATION "${SIMDJSON_INSTALL_CMAKEDIR}"
COMPONENT example_Development
COMPONENT simdjson_Development
)
# pkg-config
+1 -1
View File
@@ -38,7 +38,7 @@ PROJECT_NAME = simdjson
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER = "3.1.3"
PROJECT_NUMBER = "3.1.5"
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
+2 -2
View File
@@ -1,5 +1,4 @@
![Ubuntu 18.04 CI](https://github.com/simdjson/simdjson/workflows/Ubuntu%2018.04%20CI%20(GCC%207)/badge.svg)
[![Ubuntu 20.04 CI](https://github.com/simdjson/simdjson/workflows/Ubuntu%2020.04%20CI%20(GCC%209)/badge.svg)](https://simdjson.org/plots.html)
![VS16-CI](https://github.com/simdjson/simdjson/workflows/VS16-CI/badge.svg)
![MinGW64-CI](https://github.com/simdjson/simdjson/workflows/MinGW64-CI/badge.svg)
@@ -122,7 +121,8 @@ Real-world usage
- [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)
If you are planning to use simdjson in a product, please work from one of our releases.
+17
View File
@@ -50,6 +50,23 @@ undefined behavior.")
endif()
endif()
option(SIMDJSON_SANITIZE_MEMORY "Sanitize memory" OFF)
if(SIMDJSON_SANITIZE_MEMORY)
message(STATUS "Setting the memory sanitizer.")
add_compile_options(
-fsanitize=memory -fno-sanitize-recover=all
)
link_libraries(
-fsanitize=memory -fno-sanitize-recover=all
)
# Ubuntu bug for GCC 5.0+ (safe for all versions)
if(CMAKE_COMPILER_IS_GNUCC)
link_libraries(-fuse-ld=gold)
endif()
endif()
if(SIMDJSON_SANITIZE_THREADS)
message(STATUS "Setting both the thread sanitizer \
and the undefined-behavior sanitizer.")
+1 -1
View File
@@ -15,7 +15,7 @@ if(SIMDJSON_GOOGLE_BENCHMARKS)
set_off(BENCHMARK_ENABLE_INSTALL)
set_off(BENCHMARK_ENABLE_WERROR)
import_dependency(google_benchmarks google/benchmark d572f47)
import_dependency(google_benchmarks google/benchmark v1.7.1)
add_dependency(google_benchmarks)
endif()
+7 -2
View File
@@ -143,6 +143,12 @@ As required by the standard, your JSON document should be in a Unicode (UTF-8) s
string, from the beginning to the end, needs to be valid: we do not attempt to tolerate bad
inputs before or after a document.
For efficiency reasons, simdjson requires a string with a few bytes (`simdjson::SIMDJSON_PADDING`)
at the end, these bytes may be read but their content does not affect the parsing. In practice,
it means that the JSON inputs should be stored in a memory region with `simdjson::SIMDJSON_PADDING`
extra bytes at the end. You do not have to set these bytes to specific values though you may
want to if you want to avoid runtime warnings with some sanitizers.
The simdjson library offers a tree-like [API](https://en.wikipedia.org/wiki/API), which you can
access by creating a `ondemand::parser` and calling the `iterate()` method. The iterate method
quickly indexes the input string and may detect some errors. The following example illustrates
@@ -154,8 +160,7 @@ auto json = padded_string::load("twitter.json"); // load JSON file 'twitter.json
ondemand::document doc = parser.iterate(json); // position a pointer at the beginning of the JSON data
```
You can also create a padded string---for efficiency reasons, simdjson requires a string
with a few bytes (`simdjson::SIMDJSON_PADDING`) at the end---and calling `iterate()`:
You can also create a padded string---and call `iterate()`:
```c++
ondemand::parser parser;
+4
View File
@@ -9,6 +9,10 @@ namespace {
// 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;
+6 -2
View File
@@ -145,7 +145,9 @@ public:
* ### REQUIRED: Buffer Padding
*
* The buffer must have at least SIMDJSON_PADDING extra allocated bytes. It does not matter what
* those bytes are initialized to, as long as they are allocated.
* those bytes are initialized to, as long as they are allocated. These bytes will be read: if you
* using a sanitizer that verifies that no uninitialized byte is read, then you should initialize the
* SIMDJSON_PADDING bytes to avoid runtime warnings.
*
* If realloc_if_needed is true (the default), it is assumed that the buffer does *not* have enough padding,
* and it is copied into an enlarged temporary buffer before parsing. Thus the following is safe:
@@ -408,7 +410,9 @@ public:
* ### REQUIRED: Buffer Padding
*
* The buffer must have at least SIMDJSON_PADDING extra allocated bytes. It does not matter what
* those bytes are initialized to, as long as they are allocated.
* those bytes are initialized to, as long as they are allocated. These bytes will be read: if you
* using a sanitizer that verifies that no uninitialized byte is read, then you should initialize the
* SIMDJSON_PADDING bytes to avoid runtime warnings.
*
* ### Threads
*
+9 -3
View File
@@ -78,7 +78,9 @@ public:
* ### REQUIRED: Buffer Padding
*
* The buffer must have at least SIMDJSON_PADDING extra allocated bytes. It does not matter what
* those bytes are initialized to, as long as they are allocated.
* those bytes are initialized to, as long as they are allocated. These bytes will be read: if you
* using a sanitizer that verifies that no uninitialized byte is read, then you should initialize the
* SIMDJSON_PADDING bytes to avoid runtime warnings.
*
* @param json The JSON to parse.
* @param len The length of the JSON.
@@ -134,7 +136,9 @@ public:
* ### REQUIRED: Buffer Padding
*
* The buffer must have at least SIMDJSON_PADDING extra allocated bytes. It does not matter what
* those bytes are initialized to, as long as they are allocated.
* those bytes are initialized to, as long as they are allocated. These bytes will be read: if you
* using a sanitizer that verifies that no uninitialized byte is read, then you should initialize the
* SIMDJSON_PADDING bytes to avoid runtime warnings.
*
* @param json The JSON to parse.
*
@@ -188,7 +192,9 @@ public:
* ### REQUIRED: Buffer Padding
*
* The buffer must have at least SIMDJSON_PADDING extra allocated bytes. It does not matter what
* those bytes are initialized to, as long as they are allocated.
* those bytes are initialized to, as long as they are allocated. These bytes will be read: if you
* using a sanitizer that verifies that no uninitialized byte is read, then you should initialize the
* SIMDJSON_PADDING bytes to avoid runtime warnings.
*
* ### Threads
*
@@ -9,6 +9,10 @@ namespace {
// 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) {
#if SIMDJSON_REGULAR_VISUAL_STUDIO
return (int)_tzcnt_u64(input_num);
@@ -9,6 +9,10 @@ namespace {
// 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) {
#if SIMDJSON_REGULAR_VISUAL_STUDIO
return (int)_tzcnt_u64(input_num);
+13
View File
@@ -148,6 +148,19 @@ use a 64-bit target such as x64, 64-bit ARM or 64-bit PPC.")
#define SIMDJSON_NO_SANITIZE_UNDEFINED
#endif
#if defined(__clang__) || defined(__GNUC__)
#if defined(__has_feature)
# if __has_feature(memory_sanitizer)
#define SIMDJSON_NO_SANITIZE_MEMORY __attribute__((no_sanitize("memory")))
# endif // if __has_feature(memory_sanitizer)
#endif // defined(__has_feature)
#endif
// make sure it is defined as 'nothing' if it is unapplicable.
#ifndef SIMDJSON_NO_SANITIZE_MEMORY
#define SIMDJSON_NO_SANITIZE_MEMORY
#endif
#if SIMDJSON_VISUAL_STUDIO
// This is one case where we do not distinguish between
// regular visual studio and clang under visual studio.
+4
View File
@@ -9,6 +9,10 @@ namespace {
// 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) {
#if SIMDJSON_REGULAR_VISUAL_STUDIO
unsigned long ret;
+2 -2
View File
@@ -4,7 +4,7 @@
#define SIMDJSON_SIMDJSON_VERSION_H
/** The version of simdjson being used (major.minor.revision) */
#define SIMDJSON_VERSION "3.1.3"
#define SIMDJSON_VERSION "3.1.5"
namespace simdjson {
enum {
@@ -19,7 +19,7 @@ enum {
/**
* The revision (major.minor.REVISION) of simdjson being used.
*/
SIMDJSON_VERSION_REVISION = 3
SIMDJSON_VERSION_REVISION = 5
};
} // namespace simdjson
@@ -9,6 +9,10 @@ namespace {
// 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) {
#if SIMDJSON_REGULAR_VISUAL_STUDIO
unsigned long ret;
+1 -1
View File
@@ -1,4 +1,4 @@
/* auto-generated on 2023-03-02 09:39:35 -0500. Do not edit! */
/* auto-generated on 2023-03-09 11:14:42 -0500. Do not edit! */
/* begin file src/simdjson.cpp */
#include "simdjson.h"
+18 -8
View File
@@ -1,4 +1,4 @@
/* auto-generated on 2023-03-02 09:39:35 -0500. Do not edit! */
/* auto-generated on 2023-03-09 11:14:42 -0500. Do not edit! */
/* begin file include/simdjson.h */
#ifndef SIMDJSON_H
#define SIMDJSON_H
@@ -43,7 +43,7 @@
#define SIMDJSON_SIMDJSON_VERSION_H
/** The version of simdjson being used (major.minor.revision) */
#define SIMDJSON_VERSION "3.1.3"
#define SIMDJSON_VERSION "3.1.5"
namespace simdjson {
enum {
@@ -58,7 +58,7 @@ enum {
/**
* The revision (major.minor.REVISION) of simdjson being used.
*/
SIMDJSON_VERSION_REVISION = 3
SIMDJSON_VERSION_REVISION = 5
};
} // namespace simdjson
@@ -4501,7 +4501,9 @@ public:
* ### REQUIRED: Buffer Padding
*
* The buffer must have at least SIMDJSON_PADDING extra allocated bytes. It does not matter what
* those bytes are initialized to, as long as they are allocated.
* those bytes are initialized to, as long as they are allocated. These bytes will be read: if you
* using a sanitizer that verifies that no uninitialized byte is read, then you should initialize the
* SIMDJSON_PADDING bytes to avoid runtime warnings.
*
* If realloc_if_needed is true (the default), it is assumed that the buffer does *not* have enough padding,
* and it is copied into an enlarged temporary buffer before parsing. Thus the following is safe:
@@ -4764,7 +4766,9 @@ public:
* ### REQUIRED: Buffer Padding
*
* The buffer must have at least SIMDJSON_PADDING extra allocated bytes. It does not matter what
* those bytes are initialized to, as long as they are allocated.
* those bytes are initialized to, as long as they are allocated. These bytes will be read: if you
* using a sanitizer that verifies that no uninitialized byte is read, then you should initialize the
* SIMDJSON_PADDING bytes to avoid runtime warnings.
*
* ### Threads
*
@@ -26318,7 +26322,9 @@ public:
* ### REQUIRED: Buffer Padding
*
* The buffer must have at least SIMDJSON_PADDING extra allocated bytes. It does not matter what
* those bytes are initialized to, as long as they are allocated.
* those bytes are initialized to, as long as they are allocated. These bytes will be read: if you
* using a sanitizer that verifies that no uninitialized byte is read, then you should initialize the
* SIMDJSON_PADDING bytes to avoid runtime warnings.
*
* @param json The JSON to parse.
* @param len The length of the JSON.
@@ -26374,7 +26380,9 @@ public:
* ### REQUIRED: Buffer Padding
*
* The buffer must have at least SIMDJSON_PADDING extra allocated bytes. It does not matter what
* those bytes are initialized to, as long as they are allocated.
* those bytes are initialized to, as long as they are allocated. These bytes will be read: if you
* using a sanitizer that verifies that no uninitialized byte is read, then you should initialize the
* SIMDJSON_PADDING bytes to avoid runtime warnings.
*
* @param json The JSON to parse.
*
@@ -26428,7 +26436,9 @@ public:
* ### REQUIRED: Buffer Padding
*
* The buffer must have at least SIMDJSON_PADDING extra allocated bytes. It does not matter what
* those bytes are initialized to, as long as they are allocated.
* those bytes are initialized to, as long as they are allocated. These bytes will be read: if you
* using a sanitizer that verifies that no uninitialized byte is read, then you should initialize the
* SIMDJSON_PADDING bytes to avoid runtime warnings.
*
* ### Threads
*
+2 -2
View File
@@ -551,7 +551,7 @@ namespace parse_api_tests {
ASSERT_SUCCESS( parser.parse_many(empty_batches_ndjson, BATCH_SIZE*16).get(stream) );
for (auto doc : stream) {
count++;
uint64_t val;
uint64_t val{};
ASSERT_SUCCESS( doc.get(val) );
ASSERT_EQUAL( val, count );
}
@@ -1039,7 +1039,7 @@ namespace dom_api_tests {
for (auto tweet : tweets) {
object user;
ASSERT_SUCCESS( tweet["user"].get(user) );
bool default_profile;
bool default_profile{};
ASSERT_SUCCESS( user["default_profile"].get(default_profile) );
if (default_profile) {
std::string_view screen_name;
+3 -3
View File
@@ -634,7 +634,7 @@ namespace document_stream_tests {
ASSERT_SUCCESS( odparser.parse_many(json.data(), json.length(), 50).get(odstream) );
for (auto doc: odstream) {
if(counter < 6) {
int64_t val;
int64_t val{};
ASSERT_SUCCESS(doc.at_pointer("/4").get(val));
ASSERT_EQUAL(val, 5);
} else {
@@ -797,7 +797,7 @@ namespace document_stream_tests {
simdjson::dom::document_stream stream;
ASSERT_SUCCESS( parser.parse_many(str, batch_size).get(stream) );
for (auto doc : stream) {
int64_t keyid;
int64_t keyid{};
ASSERT_SUCCESS( doc["id"].get(keyid) );
ASSERT_EQUAL( keyid, int64_t(count) );
@@ -837,7 +837,7 @@ namespace document_stream_tests {
simdjson::dom::document_stream stream;
ASSERT_SUCCESS( parser.parse_many(str, batch_size).get(stream) );
for (auto doc : stream) {
int64_t keyid;
int64_t keyid{};
ASSERT_SUCCESS( doc["id"].get(keyid) );
ASSERT_EQUAL( keyid, int64_t(count) );
+2 -2
View File
@@ -46,7 +46,7 @@ namespace parser_load {
ASSERT_SUCCESS(parser.parse_many(DOC).get(docs));
for (auto doc : docs) {
count++;
uint64_t val;
uint64_t val{};
auto error = doc.get(val);
if (count == 3) {
ASSERT_ERROR(error, TAPE_ERROR);
@@ -83,7 +83,7 @@ namespace parser_load {
ASSERT_SUCCESS(parser.parse_many(DOC).get(docs));
for (auto doc : docs) {
count++;
uint64_t val;
uint64_t val{};
auto error = doc.get(val);
if (count == 3) {
ASSERT_ERROR(error, TAPE_ERROR);
+2 -2
View File
@@ -33,12 +33,12 @@ static bool parse_and_validate(const std::string src, T expected) {
simdjson::dom::parser parser;
if constexpr (std::is_same<int64_t, T>::value) {
int64_t actual;
int64_t actual{};
ASSERT_SUCCESS( parser.parse(pstr)["key"].get(actual) );
std::cout << std::boolalpha << "test: " << (expected == actual) << std::endl;
ASSERT_EQUAL( expected, actual );
} else {
uint64_t actual;
uint64_t actual{};
ASSERT_SUCCESS( parser.parse(pstr)["key"].get(actual) );
std::cout << std::boolalpha << "test: " << (expected == actual) << std::endl;
ASSERT_EQUAL( expected, actual );
+1 -1
View File
@@ -140,7 +140,7 @@ bool tester(int seed, size_t volume) {
std::vector<char> buffer(1024); // large buffer (can't overflow)
simdjson::dom::parser parser;
RandomEngine rand(seed);
double result;
double result{};
for (size_t i = 0; i < volume; i++) {
if((i%100000) == 0) { std::cout << "."; std::cout.flush(); }
size_t length = build_random_string(rand, buffer.data());
+17 -17
View File
@@ -134,7 +134,7 @@ namespace array_tests {
ondemand::parser parser;
ondemand::document doc;
ASSERT_SUCCESS(parser.iterate(json).get(doc));
size_t count;
size_t count{};
ASSERT_SUCCESS(doc.count_elements().get(count));
ondemand::array arr;
ASSERT_SUCCESS(doc.get_array().get(arr));
@@ -182,7 +182,7 @@ namespace array_tests {
ASSERT_SUCCESS(doc.get_object().get(obj));
ondemand::value v;
ASSERT_SUCCESS(doc.find_field("test").get(v));
size_t count;
size_t count{};
ASSERT_SUCCESS(v.count_elements().get(count));
ASSERT_EQUAL(count, 3);
ASSERT_SUCCESS(doc.find_field("joe").get(v));
@@ -200,7 +200,7 @@ namespace array_tests {
ondemand::array array;
ASSERT_RESULT( doc_result.type(), json_type::array );
ASSERT_SUCCESS( doc_result.get_array().get(array) );
size_t count;
size_t count{};
ASSERT_SUCCESS( array.count_elements().get(count) );
ASSERT_EQUAL(count, expected_value.size());
return true;
@@ -209,13 +209,13 @@ namespace array_tests {
ondemand::array array;
ASSERT_RESULT( doc_result.type(), json_type::array );
ASSERT_SUCCESS( doc_result.get(array) );
size_t count;
size_t count{};
ASSERT_SUCCESS( array.count_elements().get(count) );
ASSERT_EQUAL(count, expected_value.size());
size_t i = 0;
std::vector<uint64_t> receiver(count);
for (auto value : array) {
uint64_t actual;
uint64_t actual{};
ASSERT_SUCCESS( value.get(actual) );
ASSERT_EQUAL(actual, expected_value[i]);
receiver[i] = actual;
@@ -235,7 +235,7 @@ namespace array_tests {
ondemand::array array;
ASSERT_RESULT( doc_result.type(), json_type::array );
ASSERT_SUCCESS( doc_result.get_array().get(array) );
size_t count;
size_t count{};
ASSERT_SUCCESS( array.count_elements().get(count) );
ASSERT_EQUAL(count, 0);
return true;
@@ -244,13 +244,13 @@ namespace array_tests {
ondemand::array array;
ASSERT_RESULT( doc_result.type(), json_type::array );
ASSERT_SUCCESS( doc_result.get(array) );
size_t count;
size_t count{};
ASSERT_SUCCESS( array.count_elements().get(count) );
ASSERT_EQUAL(count, 0);
size_t i = 0;
std::vector<uint64_t> receiver(count);
for (auto value : array) {
uint64_t actual;
uint64_t actual{};
ASSERT_SUCCESS( value.get(actual) );
i++;
}
@@ -269,7 +269,7 @@ namespace array_tests {
ondemand::array array;
ASSERT_RESULT( doc_result.type(), json_type::array );
ASSERT_SUCCESS( doc_result.get(array) );
size_t count;
size_t count{};
auto e = array.count_elements().get(count);
if( e != TAPE_ERROR) {
std::cout << e << "\n";
@@ -285,7 +285,7 @@ namespace array_tests {
TEST_START();
auto empty = R"( [] )"_padded;
SUBTEST("ondemand::empty_doc_array", test_ondemand_doc(empty, [&](auto doc_result) {
size_t count;
size_t count{};
ASSERT_RESULT( doc_result.type(), json_type::array );
ASSERT_SUCCESS( doc_result.count_elements().get(count) );
ASSERT_EQUAL( count, 0 );
@@ -293,7 +293,7 @@ namespace array_tests {
}));
auto basic = R"( [-1.234, 100000000000000, null, [1,2,3], {"t":true, "f":false}] )"_padded;
SUBTEST("ondemand::basic_doc_array", test_ondemand_doc(basic, [&](auto doc_result) {
size_t count;
size_t count{};
ASSERT_RESULT( doc_result.type(), json_type::array );
ASSERT_SUCCESS( doc_result.count_elements().get(count) );
ASSERT_EQUAL( count, 5 );
@@ -331,7 +331,7 @@ namespace array_tests {
size_t i = 0;
for (auto value : array) {
int64_t actual;
int64_t actual{};
ASSERT_SUCCESS( value.get(actual) );
ASSERT_EQUAL(actual, expected_value[i]);
i++;
@@ -355,7 +355,7 @@ namespace array_tests {
ASSERT_SUCCESS( doc_result.get(array) );
i = 0;
for (auto value : array) {
int64_t actual;
int64_t actual{};
ASSERT_SUCCESS( value.get(actual) );
container[i] = actual;
i++;
@@ -379,7 +379,7 @@ namespace array_tests {
array.reset();
i = 0;
for (auto value : array) {
int64_t actual;
int64_t actual{};
ASSERT_SUCCESS( value.get(actual) );
container[i] = actual;
i++;
@@ -435,7 +435,7 @@ namespace array_tests {
TEST_SUCCEED();
}
bool count_empty(simdjson::ondemand::array arr) {
size_t count;
size_t count{};
ASSERT_SUCCESS(arr.count_elements().get(count));
ASSERT_EQUAL(count, 0);
bool is_empty;
@@ -466,7 +466,7 @@ namespace array_tests {
for (auto d : data) {
simdjson::ondemand::array arr;
ASSERT_SUCCESS(d.get_array().get(arr));
size_t count;
size_t count{};
ASSERT_SUCCESS(arr.count_elements().get(count));
ASSERT_EQUAL(count, 4);
}
@@ -528,7 +528,7 @@ namespace array_tests {
size_t i=0;
for (auto value : array) {
int64_t actual;
int64_t actual{};
ASSERT_SUCCESS( value.get(actual) );
ASSERT_EQUAL(actual, expected_value[i]);
i++;
@@ -7,7 +7,7 @@ namespace document_stream_tests {
template <typename T>
bool process_doc(T &docref) {
int64_t val;
int64_t val{};
ASSERT_SUCCESS(docref.at_pointer("/4").get(val));
ASSERT_EQUAL(val, 5);
return true;
@@ -567,7 +567,7 @@ namespace document_stream_tests {
size_t count{0};
ASSERT_SUCCESS( parser.iterate_many(str, batch_size).get(stream) );
for (auto doc : stream) {
int64_t keyid;
int64_t keyid{};
ASSERT_SUCCESS( doc["id"].get(keyid) );
ASSERT_EQUAL( keyid, int64_t(count) );
@@ -604,7 +604,7 @@ namespace document_stream_tests {
ASSERT_SUCCESS( odparser.iterate_many(json.data(), json.length(), 50).get(odstream) );
for (auto doc: odstream) {
if(counter < 6) {
int64_t val;
int64_t val{};
ASSERT_SUCCESS(doc.at_pointer("/4").get(val));
ASSERT_EQUAL(val, 5);
} else {
@@ -643,7 +643,7 @@ namespace document_stream_tests {
size_t count{0};
ASSERT_SUCCESS( parser.iterate_many(str, batch_size).get(stream) );
for (auto doc : stream) {
int64_t keyid;
int64_t keyid{};
ASSERT_SUCCESS( doc["id"].get(keyid) );
ASSERT_EQUAL( keyid, int64_t(count) );
+1 -1
View File
@@ -67,7 +67,7 @@ namespace misc_tests {
ASSERT_SUCCESS(val.get_object().get(obj));
ondemand::array arr;
ASSERT_SUCCESS(obj["a"].get_array().get(arr));
size_t count;
size_t count{};
ASSERT_SUCCESS(arr.count_elements().get(count));
ASSERT_EQUAL(3,count);
TEST_SUCCEED();
+2 -2
View File
@@ -238,7 +238,7 @@ namespace number_tests {
ondemand::number num;
ASSERT_SUCCESS(val.get_number().get(num));
ASSERT_EQUAL(is_negative[counter], val.is_negative());
bool intvalue;
bool intvalue{};
ASSERT_SUCCESS(val.is_integer().get(intvalue));
ASSERT_EQUAL(is_integer[counter], intvalue);
ondemand::number_type t = num.get_number_type();
@@ -341,7 +341,7 @@ namespace number_tests {
ondemand::number number;
ondemand::number_type nt;
bool intvalue;
bool intvalue{};
docdata = R"(1.0)"_padded;
ASSERT_SUCCESS(parser.iterate(docdata).get(doc));
+31 -8
View File
@@ -6,6 +6,7 @@ using namespace simdjson;
namespace object_tests {
using namespace std;
using simdjson::ondemand::json_type;
bool issue1745() {
TEST_START();
auto json = R"({
@@ -225,6 +226,25 @@ namespace object_tests {
}
#if SIMDJSON_EXCEPTIONS
bool issue1965() {
TEST_START();
std::string str = "{\"query\":\"ah\"}";
std::unique_ptr<char[]> buffer(new char[str.size() + simdjson::SIMDJSON_PADDING]);
memcpy(buffer.get(), str.data(), str.size());
simdjson::padded_string_view view(buffer.get(), str.size(), str.size() + simdjson::SIMDJSON_PADDING);
simdjson::ondemand::parser parser;
simdjson::ondemand::document doc = parser.iterate(view);
simdjson::ondemand::object root = doc.get_object();
simdjson::ondemand::value query = root.find_field("query");
simdjson::ondemand::raw_json_string raw = query.get_raw_json_string();
std::unique_ptr<uint8_t[]> dst_buffer(new uint8_t[3 + simdjson::SIMDJSON_PADDING]);
uint8_t * dst = dst_buffer.get();
std::string_view fieldstring = parser.unescape(raw, dst);
std::cout << fieldstring << std::endl;
TEST_SUCCEED();
}
bool issue1745_with_exceptions() {
TEST_START();
auto json = R"({
@@ -889,7 +909,7 @@ namespace object_tests {
ondemand::document doc;
ASSERT_SUCCESS(parser.iterate(json).get(doc));
ondemand::object obj;
size_t count;
size_t count{};
ASSERT_SUCCESS(doc.get_object().get(obj));
ASSERT_SUCCESS(obj.count_fields().get(count));
ASSERT_EQUAL(count, 0);
@@ -904,7 +924,7 @@ namespace object_tests {
ASSERT_SUCCESS(parser.iterate(json).get(doc));
ondemand::object obj;
ASSERT_SUCCESS(doc.get_object().get(obj));
size_t count;
size_t count{};
ASSERT_SUCCESS(obj.count_fields().get(count));
ASSERT_EQUAL(count, 0);
for (auto field : obj) {
@@ -923,7 +943,7 @@ namespace object_tests {
ondemand::parser parser;
ondemand::document doc;
ASSERT_SUCCESS(parser.iterate(json).get(doc));
size_t count;
size_t count{};
ASSERT_SUCCESS(doc.count_fields().get(count));
ondemand::object obj;
ASSERT_SUCCESS(doc.get_object().get(obj));
@@ -969,7 +989,7 @@ namespace object_tests {
for (auto d : data) {
simdjson::ondemand::object obj;
ASSERT_SUCCESS(d.get_object().get(obj));
size_t count;
size_t count{};
ASSERT_SUCCESS(obj.count_fields().get(count));
ASSERT_EQUAL(count, 7);
}
@@ -1005,7 +1025,7 @@ namespace object_tests {
simdjson::ondemand::array data;
ASSERT_SUCCESS(doc["result"]["data"].get_array().get(data));
for (auto d : data) {
size_t count;
size_t count{};
ASSERT_SUCCESS(d.count_fields().get(count));
ASSERT_EQUAL(count, 7);
}
@@ -1019,7 +1039,7 @@ namespace object_tests {
ondemand::document doc;
ASSERT_SUCCESS(parser.iterate(json).get(doc));
ondemand::object obj;
size_t count;
size_t count{};
ASSERT_SUCCESS(doc.get_object().get(obj));
ASSERT_SUCCESS(obj.count_fields().get(count));
ASSERT_EQUAL(count, 5);
@@ -1081,7 +1101,7 @@ namespace object_tests {
TEST_START();
auto empty = R"( {} )"_padded;
SUBTEST("ondemand::empty_doc_object", test_ondemand_doc(empty, [&](auto doc_result) {
size_t count;
size_t count{};
ASSERT_RESULT( doc_result.type(), json_type::object );
ASSERT_SUCCESS( doc_result.count_fields().get(count) );
ASSERT_EQUAL( count, 0 );
@@ -1089,7 +1109,7 @@ namespace object_tests {
}));
auto basic = R"( {"a":-1.234, "b":false, "c":null, "d":[1000.1,-2000.2,3000.3], "e":{"a":true, "b":false}} )"_padded;
SUBTEST("ondemand::basic_doc_object", test_ondemand_doc(basic, [&](auto doc_result) {
size_t count;
size_t count{};
ASSERT_RESULT( doc_result.type(), json_type::object );
ASSERT_SUCCESS( doc_result.count_fields().get(count) );
ASSERT_EQUAL( count, 5 );
@@ -1221,6 +1241,9 @@ namespace object_tests {
bool run() {
return
#if SIMDJSON_EXCEPTIONS
issue1965() &&
#endif
issue1876a() &&
issue1876() &&
test_strager() &&
+5 -4
View File
@@ -320,7 +320,7 @@ bool json_object_count() {
ondemand::parser parser;
ondemand::document doc;
ASSERT_SUCCESS(parser.iterate(json).get(doc));
size_t count;
size_t count{};
ASSERT_SUCCESS(doc.count_fields().get(count));
ASSERT_EQUAL(count,1);
ondemand::object object;
@@ -778,9 +778,9 @@ bool ndjson_basics_example() {
size_t count{0};
int64_t expected[3] = {1,2,3};
for (auto doc : docs) {
int64_t actual;
int64_t actual{};
ASSERT_SUCCESS( doc["foo"].get(actual) );
ASSERT_EQUAL( actual,expected[count++] );
ASSERT_EQUAL( actual, expected[count++] );
}
TEST_SUCCEED();
}
@@ -1040,6 +1040,7 @@ struct ZuluBBox {
<< std::endl;
}
};
#if SIMDJSON_EXCEPTIONS
bool example1956() {
@@ -1200,7 +1201,7 @@ bool example1958() {
}
return true;
}
#endif
bool run() {
return true
#if SIMDJSON_EXCEPTIONS
+3 -2
View File
@@ -79,7 +79,7 @@ namespace twitter_tests {
auto media = tweet["entities"]["media"];
if (!media.error()) {
for (auto image : media) {
uint64_t id_val;
uint64_t id_val{};
std::string_view id_string;
ASSERT_SUCCESS( image["id"].get(id_val) );
ASSERT_SUCCESS( image["id_str"].get(id_string) );
@@ -91,7 +91,8 @@ namespace twitter_tests {
ASSERT_SUCCESS( size.unescaped_key().get(size_key) );
std::cout << "Type of image size = " << size_key << std::endl;
uint64_t width, height;
uint64_t width{};
uint64_t height{};
ASSERT_SUCCESS( size.value()["w"].get(width) );
ASSERT_SUCCESS( size.value()["h"].get(height) );
image_sizes.insert(make_pair(width, height));
+1 -1
View File
@@ -10,7 +10,7 @@
template<typename T, typename F>
bool test_ondemand(simdjson::ondemand::parser &parser, const simdjson::padded_string &json, const F& f) {
auto doc = parser.iterate(json);
T val;
T val{};
ASSERT_SUCCESS( doc.get(val) );
return f(val);
}
+2 -2
View File
@@ -123,7 +123,7 @@ void recurse(simdjson::dom::element element, stat_t &s, size_t depth) {
if (element.is<int64_t>()) {
s.integer_count++; // because an int can be sometimes represented as a double, we
// to check whether it is an integer first!!!
int64_t v;
int64_t v{};
error = element.get(v);
SIMDJSON_ASSUME(!error);
if((v >= std::numeric_limits<int32_t>::min()) and (v <= std::numeric_limits<int32_t>::max()) ) {
@@ -138,7 +138,7 @@ void recurse(simdjson::dom::element element, stat_t &s, size_t depth) {
} else if (element.is<double>()) {
s.float_count++;
} else if (element.is<bool>()) {
bool v;
bool v{};
error = element.get(v);
SIMDJSON_ASSUME(!error);
if (v) {