mirror of
https://github.com/simdjson/simdjson
synced 2026-06-08 17:27:07 +00:00
Compare commits
3 Commits
version4.6.4
...
v0.9.3
| Author | SHA1 | Date | |
|---|---|---|---|
| 6a37fc1871 | |||
| c6c29c2827 | |||
| 941e903f28 |
+2
-2
@@ -9,8 +9,8 @@ project(simdjson
|
||||
|
||||
set(PROJECT_VERSION_MAJOR 0)
|
||||
set(PROJECT_VERSION_MINOR 9)
|
||||
set(PROJECT_VERSION_PATCH 1)
|
||||
set(SIMDJSON_SEMANTIC_VERSION "0.9.1" CACHE STRING "simdjson semantic version")
|
||||
set(PROJECT_VERSION_PATCH 2)
|
||||
set(SIMDJSON_SEMANTIC_VERSION "0.9.2" CACHE STRING "simdjson semantic version")
|
||||
set(SIMDJSON_LIB_VERSION "8.0.0" CACHE STRING "simdjson library version")
|
||||
set(SIMDJSON_LIB_SOVERSION "8" CACHE STRING "simdjson library soversion")
|
||||
set(SIMDJSON_GITHUB_REPOSITORY https://github.com/simdjson/simdjson)
|
||||
|
||||
@@ -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 = "0.9.1"
|
||||
PROJECT_NUMBER = "0.9.2"
|
||||
|
||||
# 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
|
||||
|
||||
@@ -37,4 +37,5 @@ if (TARGET benchmark::benchmark)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(checkperf.cmake)
|
||||
# deliberately disabling.
|
||||
# include(checkperf.cmake)
|
||||
|
||||
@@ -251,4 +251,23 @@ namespace std {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#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
|
||||
#endif
|
||||
// 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
|
||||
|
||||
|
||||
#endif // SIMDJSON_COMMON_DEFS_H
|
||||
|
||||
@@ -58,6 +58,16 @@ simdjson_warn_unused simdjson_really_inline error_code json_iterator::skip_child
|
||||
_depth--;
|
||||
if (depth() <= parent_depth) { return SUCCESS; }
|
||||
break;
|
||||
case '"':
|
||||
if(*peek() == ':') {
|
||||
// we are at a key!!! This is
|
||||
// only possible if someone searched
|
||||
// for a key and the key was not found.
|
||||
logger::log_value(*this, "key");
|
||||
advance(); // eat up the ':'
|
||||
break; // important!!!
|
||||
}
|
||||
simdjson_fallthrough;
|
||||
// Anything else must be a scalar value
|
||||
default:
|
||||
// For the first scalar, we will have incremented depth already, so we decrement it here.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#define SIMDJSON_SIMDJSON_VERSION_H
|
||||
|
||||
/** The version of simdjson being used (major.minor.revision) */
|
||||
#define SIMDJSON_VERSION 0.9.1
|
||||
#define SIMDJSON_VERSION 0.9.2
|
||||
|
||||
namespace simdjson {
|
||||
enum {
|
||||
@@ -19,7 +19,7 @@ enum {
|
||||
/**
|
||||
* The revision (major.minor.REVISION) of simdjson being used.
|
||||
*/
|
||||
SIMDJSON_VERSION_REVISION = 1
|
||||
SIMDJSON_VERSION_REVISION = 2
|
||||
};
|
||||
} // namespace simdjson
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* auto-generated on 2021-03-18 11:30:40 -0400. Do not edit! */
|
||||
/* auto-generated on 2021-03-18 11:31:38 -0400. Do not edit! */
|
||||
/* begin file src/simdjson.cpp */
|
||||
#include "simdjson.h"
|
||||
|
||||
|
||||
+32
-3
@@ -1,4 +1,4 @@
|
||||
/* auto-generated on 2021-03-18 11:30:40 -0400. Do not edit! */
|
||||
/* auto-generated on 2021-03-18 11:31:38 -0400. Do not edit! */
|
||||
/* begin file include/simdjson.h */
|
||||
#ifndef SIMDJSON_H
|
||||
#define SIMDJSON_H
|
||||
@@ -2045,6 +2045,25 @@ namespace std {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#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
|
||||
#endif
|
||||
// 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
|
||||
|
||||
|
||||
#endif // SIMDJSON_COMMON_DEFS_H
|
||||
/* end file include/simdjson/common_defs.h */
|
||||
|
||||
@@ -2059,7 +2078,7 @@ SIMDJSON_DISABLE_UNDESIRED_WARNINGS
|
||||
#define SIMDJSON_SIMDJSON_VERSION_H
|
||||
|
||||
/** The version of simdjson being used (major.minor.revision) */
|
||||
#define SIMDJSON_VERSION 0.9.1
|
||||
#define SIMDJSON_VERSION 0.9.2
|
||||
|
||||
namespace simdjson {
|
||||
enum {
|
||||
@@ -2074,7 +2093,7 @@ enum {
|
||||
/**
|
||||
* The revision (major.minor.REVISION) of simdjson being used.
|
||||
*/
|
||||
SIMDJSON_VERSION_REVISION = 1
|
||||
SIMDJSON_VERSION_REVISION = 2
|
||||
};
|
||||
} // namespace simdjson
|
||||
|
||||
@@ -21747,6 +21766,16 @@ simdjson_warn_unused simdjson_really_inline error_code json_iterator::skip_child
|
||||
_depth--;
|
||||
if (depth() <= parent_depth) { return SUCCESS; }
|
||||
break;
|
||||
case '"':
|
||||
if(*peek() == ':') {
|
||||
// we are at a key!!! This is
|
||||
// only possible if someone searched
|
||||
// for a key and the key was not found.
|
||||
logger::log_value(*this, "key");
|
||||
advance(); // eat up the ':'
|
||||
break; // important!!!
|
||||
}
|
||||
simdjson_fallthrough;
|
||||
// Anything else must be a scalar value
|
||||
default:
|
||||
// For the first scalar, we will have incremented depth already, so we decrement it here.
|
||||
|
||||
@@ -7,6 +7,122 @@ namespace object_tests {
|
||||
using namespace std;
|
||||
using simdjson::ondemand::json_type;
|
||||
|
||||
// In this test, no non-trivial object in an array have a missing key
|
||||
bool no_missing_keys() {
|
||||
TEST_START();
|
||||
simdjson::ondemand::parser parser;
|
||||
simdjson::padded_string docdata = R"([{"a":"a"},{}])"_padded;
|
||||
simdjson::ondemand::document doc;
|
||||
auto error = parser.iterate(docdata).get(doc);
|
||||
if(error != simdjson::SUCCESS) { return false; }
|
||||
simdjson::ondemand::array a;
|
||||
error = doc.get_array().get(a);
|
||||
if(error != simdjson::SUCCESS) { return false; }
|
||||
size_t counter{0};
|
||||
for(auto elem : a) {
|
||||
error = elem.find_field_unordered("a").error();
|
||||
if(counter == 0) {
|
||||
ASSERT_EQUAL( error, simdjson::SUCCESS);
|
||||
} else {
|
||||
ASSERT_EQUAL( error, simdjson::NO_SUCH_FIELD);
|
||||
}
|
||||
counter++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool missing_keys() {
|
||||
TEST_START();
|
||||
simdjson::ondemand::parser parser;
|
||||
simdjson::padded_string docdata = R"([{"a":"a"},{}])"_padded;
|
||||
simdjson::ondemand::document doc;
|
||||
auto error = parser.iterate(docdata).get(doc);
|
||||
if(error != simdjson::SUCCESS) { return false; }
|
||||
simdjson::ondemand::array a;
|
||||
error = doc.get_array().get(a);
|
||||
if(error != simdjson::SUCCESS) { return false; }
|
||||
for(auto elem : a) {
|
||||
error = elem.find_field_unordered("keynotfound").error();
|
||||
if(error != simdjson::NO_SUCH_FIELD) {
|
||||
std::cout << error << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#if SIMDJSON_EXCEPTIONS
|
||||
// used in issue_1521
|
||||
// difficult to use as a lambda because it is recursive.
|
||||
void broken_descend(ondemand::object node) {
|
||||
if(auto type = node.find_field_unordered("type"); type.error() == SUCCESS && type == "child") {
|
||||
auto n = node.find_field_unordered("name");
|
||||
if(n.error() == simdjson::SUCCESS) {
|
||||
std::cout << std::string_view(n) << std::endl;
|
||||
}
|
||||
} else {
|
||||
for (ondemand::object child_node : node["nodes"]) { broken_descend(child_node); }
|
||||
}
|
||||
}
|
||||
|
||||
bool broken_issue_1521() {
|
||||
TEST_START();
|
||||
ondemand::parser parser;
|
||||
padded_string json = R"({"type":"root","nodes":[{"type":"child","nodes":[]},{"type":"child","name":"child-name","nodes":[]}]})"_padded;
|
||||
ondemand::document file_tree = parser.iterate(json);
|
||||
try {
|
||||
broken_descend(file_tree);
|
||||
} catch(simdjson::simdjson_error& e) {
|
||||
std::cout << "The document is valid JSON: " << json << std::endl;
|
||||
TEST_FAIL(e.error());
|
||||
}
|
||||
TEST_SUCCEED();
|
||||
}
|
||||
|
||||
bool fixed_broken_issue_1521() {
|
||||
TEST_START();
|
||||
ondemand::parser parser;
|
||||
// We omit the ',"nodes":[]'
|
||||
padded_string json = R"({"type":"root","nodes":[{"type":"child"},{"type":"child","name":"child-name","nodes":[]}]})"_padded;
|
||||
ondemand::document file_tree = parser.iterate(json);
|
||||
try {
|
||||
broken_descend(file_tree);
|
||||
} catch(simdjson::simdjson_error& e) {
|
||||
std::cout << "The document is valid JSON: " << json << std::endl;
|
||||
TEST_FAIL(e.error());
|
||||
}
|
||||
TEST_SUCCEED();
|
||||
}
|
||||
|
||||
// used in issue_1521
|
||||
// difficult to use as a lambda because it is recursive.
|
||||
void descend(ondemand::object node) {
|
||||
auto n = node.find_field_unordered("name");
|
||||
if(auto type = node.find_field_unordered("type"); type.error() == SUCCESS && type == "child") {
|
||||
if(n.error() == simdjson::SUCCESS) {
|
||||
std::cout << std::string_view(n) << std::endl;
|
||||
}
|
||||
} else {
|
||||
for (ondemand::object child_node : node["nodes"]) { descend(child_node); }
|
||||
}
|
||||
}
|
||||
|
||||
bool issue_1521() {
|
||||
TEST_START();
|
||||
ondemand::parser parser;
|
||||
padded_string json = R"({"type":"root","nodes":[{"type":"child","nodes":[]},{"type":"child","name":"child-name","nodes":[]}]})"_padded;
|
||||
ondemand::document file_tree = parser.iterate(json);
|
||||
try {
|
||||
descend(file_tree);
|
||||
} catch(simdjson::simdjson_error& e) {
|
||||
std::cout << "The document is valid JSON: " << json << std::endl;
|
||||
TEST_FAIL(e.error());
|
||||
}
|
||||
TEST_SUCCEED();
|
||||
}
|
||||
#endif
|
||||
|
||||
bool iterate_object() {
|
||||
TEST_START();
|
||||
auto json = R"({ "a": 1, "b": 2, "c": 3 })"_padded;
|
||||
@@ -893,6 +1009,13 @@ namespace object_tests {
|
||||
|
||||
bool run() {
|
||||
return
|
||||
no_missing_keys() &&
|
||||
missing_keys() &&
|
||||
#if SIMDJSON_EXCEPTIONS
|
||||
fixed_broken_issue_1521() &&
|
||||
issue_1521() &&
|
||||
broken_issue_1521() &&
|
||||
#endif
|
||||
iterate_object() &&
|
||||
iterate_empty_object() &&
|
||||
object_index() &&
|
||||
|
||||
Reference in New Issue
Block a user