Skip to content

Commit 23290ae

Browse files
authoredFeb 5, 2024
retiring deprecated DOM APIs (simdjson#2109)
1 parent eb3a085 commit 23290ae

File tree

7 files changed

+0
-1108
lines changed

7 files changed

+0
-1108
lines changed
 

‎benchmark/bench_dom_api.cpp

-158
Original file line numberDiff line numberDiff line change
@@ -473,28 +473,6 @@ static void twitter_count(State& state) {
473473
}
474474
BENCHMARK(twitter_count);
475475

476-
#ifndef SIMDJSON_DISABLE_DEPRECATED_API
477-
SIMDJSON_PUSH_DISABLE_WARNINGS
478-
SIMDJSON_DISABLE_DEPRECATED_WARNING
479-
static void iterator_twitter_count(State& state) {
480-
// Prints the number of results in twitter.json
481-
padded_string json = padded_string::load(TWITTER_JSON);
482-
ParsedJson pj = build_parsed_json(json);
483-
for (simdjson_unused auto _ : state) {
484-
ParsedJson::Iterator iter(pj);
485-
// uint64_t result_count = doc["search_metadata"]["count"];
486-
if (!iter.move_to_key("search_metadata")) { return; }
487-
if (!iter.move_to_key("count")) { return; }
488-
if (!iter.is_integer()) { return; }
489-
int64_t result_count = iter.get_integer();
490-
491-
if (result_count != 100) { return; }
492-
}
493-
}
494-
BENCHMARK(iterator_twitter_count);
495-
SIMDJSON_POP_DISABLE_WARNINGS
496-
#endif // SIMDJSON_DISABLE_DEPRECATED_API
497-
498476
static void twitter_default_profile(State& state) {
499477
// Count unique users with a default profile.
500478
dom::parser parser;
@@ -578,54 +556,6 @@ static void error_code_twitter_default_profile(State& state) noexcept {
578556
}
579557
BENCHMARK(error_code_twitter_default_profile);
580558

581-
#ifndef SIMDJSON_DISABLE_DEPRECATED_API
582-
583-
SIMDJSON_PUSH_DISABLE_WARNINGS
584-
SIMDJSON_DISABLE_DEPRECATED_WARNING
585-
586-
static void iterator_twitter_default_profile(State& state) {
587-
// Count unique users with a default profile.
588-
padded_string json;
589-
auto error = padded_string::load(TWITTER_JSON).get(json);
590-
if (error) { std::cerr << error << std::endl; return; }
591-
ParsedJson pj = build_parsed_json(json);
592-
for (simdjson_unused auto _ : state) {
593-
set<string_view> default_users;
594-
ParsedJson::Iterator iter(pj);
595-
596-
// for (dom::object tweet : doc["statuses"]) {
597-
if (!(iter.move_to_key("statuses") && iter.is_array())) { return; }
598-
if (iter.down()) { // first status
599-
do {
600-
601-
// dom::object user = tweet["user"];
602-
if (!(iter.move_to_key("user") && iter.is_object())) { return; }
603-
604-
// if (user["default_profile"]) {
605-
if (iter.move_to_key("default_profile")) {
606-
if (iter.is_true()) {
607-
if (!iter.up()) { return; } // back to user
608-
609-
// default_users.insert(user["screen_name"]);
610-
if (!(iter.move_to_key("screen_name") && iter.is_string())) { return; }
611-
default_users.emplace(iter.get_string(), iter.get_string_length());
612-
}
613-
if (!iter.up()) { return; } // back to user
614-
}
615-
616-
if (!iter.up()) { return; } // back to status
617-
618-
} while (iter.next()); // next status
619-
}
620-
621-
if (default_users.size() != 86) { return; }
622-
}
623-
}
624-
625-
SIMDJSON_POP_DISABLE_WARNINGS
626-
BENCHMARK(iterator_twitter_default_profile);
627-
#endif // SIMDJSON_DISABLE_DEPRECATED_API
628-
629559
static void error_code_twitter_image_sizes(State& state) noexcept {
630560
// Count unique image sizes
631561
dom::parser parser;
@@ -680,92 +610,4 @@ static void parse_surrogate_pairs(State& state) {
680610
}
681611
BENCHMARK(parse_surrogate_pairs);
682612

683-
684-
#ifndef SIMDJSON_DISABLE_DEPRECATED_API
685-
686-
SIMDJSON_PUSH_DISABLE_WARNINGS
687-
SIMDJSON_DISABLE_DEPRECATED_WARNING
688-
static void iterator_twitter_image_sizes(State& state) {
689-
// Count unique image sizes
690-
padded_string json;
691-
auto error = padded_string::load(TWITTER_JSON).get(json);
692-
if (error) { std::cerr << error << std::endl; return; }
693-
ParsedJson pj = build_parsed_json(json);
694-
for (simdjson_unused auto _ : state) {
695-
set<tuple<uint64_t, uint64_t>> image_sizes;
696-
ParsedJson::Iterator iter(pj);
697-
698-
// for (dom::object tweet : doc["statuses"]) {
699-
if (!(iter.move_to_key("statuses") && iter.is_array())) { return; }
700-
if (iter.down()) { // first status
701-
do {
702-
703-
// dom::object media;
704-
// not_found = tweet["entities"]["media"].get(media);
705-
// if (!not_found) {
706-
if (iter.move_to_key("entities")) {
707-
if (!iter.is_object()) { return; }
708-
if (iter.move_to_key("media")) {
709-
if (!iter.is_array()) { return; }
710-
711-
// for (dom::object image : media) {
712-
if (iter.down()) { // first media
713-
do {
714-
715-
// for (auto [key, size] : dom::object(image["sizes"])) {
716-
if (!(iter.move_to_key("sizes") && iter.is_object())) { return; }
717-
if (iter.down()) { // first size
718-
do {
719-
iter.move_to_value();
720-
721-
// image_sizes.insert({ size["w"], size["h"] });
722-
if (!(iter.move_to_key("w")) && !iter.is_integer()) { return; }
723-
uint64_t width = iter.get_integer();
724-
if (!iter.up()) { return; } // back to size
725-
if (!(iter.move_to_key("h")) && !iter.is_integer()) { return; }
726-
uint64_t height = iter.get_integer();
727-
if (!iter.up()) { return; } // back to size
728-
image_sizes.emplace(width, height);
729-
730-
} while (iter.next()); // next size
731-
if (!iter.up()) { return; } // back to sizes
732-
}
733-
if (!iter.up()) { return; } // back to image
734-
} while (iter.next()); // next image
735-
if (!iter.up()) { return; } // back to media
736-
}
737-
if (!iter.up()) { return; } // back to entities
738-
}
739-
if (!iter.up()) { return; } // back to status
740-
}
741-
} while (iter.next()); // next status
742-
}
743-
744-
if (image_sizes.size() != 15) { return; };
745-
}
746-
}
747-
BENCHMARK(iterator_twitter_image_sizes);
748-
749-
#endif // SIMDJSON_DISABLE_DEPRECATED_API
750-
751-
#ifndef SIMDJSON_DISABLE_DEPRECATED_API
752-
static void print_json(State& state) noexcept {
753-
// Prints the number of results in twitter.json
754-
dom::parser parser;
755-
756-
padded_string json;
757-
auto error = padded_string::load(TWITTER_JSON).get(json);
758-
if (error) { std::cerr << error << std::endl; return; }
759-
760-
int code = json_parse(json, parser);
761-
if (code) { cerr << error_message(code) << endl; return; }
762-
for (simdjson_unused auto _ : state) {
763-
std::stringstream s;
764-
if (!parser.print_json(s)) { cerr << "print_json failed" << endl; return; }
765-
}
766-
}
767-
BENCHMARK(print_json);
768-
#endif // SIMDJSON_DISABLE_DEPRECATED_API
769-
SIMDJSON_POP_DISABLE_WARNINGS
770-
771613
BENCHMARK_MAIN();

‎benchmark/bench_parse_call.cpp

-30
Original file line numberDiff line numberDiff line change
@@ -169,22 +169,6 @@ BENCHMARK(parse_gsoc)->Repetitions(10)->ComputeStatistics("max", [](const std::v
169169
})->DisplayAggregatesOnly(true);
170170

171171

172-
173-
#ifndef SIMDJSON_DISABLE_DEPRECATED_API
174-
SIMDJSON_PUSH_DISABLE_WARNINGS
175-
SIMDJSON_DISABLE_DEPRECATED_WARNING
176-
static void json_parse(State& state) {
177-
ParsedJson pj;
178-
if (!pj.allocate_capacity(EMPTY_ARRAY.length())) { return; }
179-
for (simdjson_unused auto _ : state) {
180-
auto error = json_parse(EMPTY_ARRAY, pj);
181-
if (error) { return; }
182-
}
183-
}
184-
SIMDJSON_POP_DISABLE_WARNINGS
185-
BENCHMARK(json_parse);
186-
#endif // SIMDJSON_DISABLE_DEPRECATED_API
187-
188172
static void parser_parse_error_code(State& state) {
189173
dom::parser parser;
190174
if (parser.allocate(EMPTY_ARRAY.length())) { return; }
@@ -213,20 +197,6 @@ BENCHMARK(parser_parse_exception);
213197

214198
#endif // SIMDJSON_EXCEPTIONS
215199

216-
#ifndef SIMDJSON_DISABLE_DEPRECATED_API
217-
SIMDJSON_PUSH_DISABLE_WARNINGS
218-
SIMDJSON_DISABLE_DEPRECATED_WARNING
219-
static void build_parsed_json(State& state) {
220-
for (simdjson_unused auto _ : state) {
221-
dom::parser parser = simdjson::build_parsed_json(EMPTY_ARRAY);
222-
if (!parser.valid) { return; }
223-
}
224-
}
225-
SIMDJSON_POP_DISABLE_WARNINGS
226-
227-
BENCHMARK(build_parsed_json);
228-
#endif
229-
230200
static void document_parse_error_code(State& state) {
231201
for (simdjson_unused auto _ : state) {
232202
dom::parser parser;

‎include/simdjson/dom.h

-6
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,12 @@
1010
#include "simdjson/dom/parser.h"
1111
#include "simdjson/dom/serialization.h"
1212

13-
// Deprecated API
14-
#include "simdjson/dom/jsonparser.h"
15-
#include "simdjson/dom/parsedjson.h"
16-
#include "simdjson/dom/parsedjson_iterator.h"
17-
1813
// Inline functions
1914
#include "simdjson/dom/array-inl.h"
2015
#include "simdjson/dom/document_stream-inl.h"
2116
#include "simdjson/dom/document-inl.h"
2217
#include "simdjson/dom/element-inl.h"
2318
#include "simdjson/dom/object-inl.h"
24-
#include "simdjson/dom/parsedjson_iterator-inl.h"
2519
#include "simdjson/dom/parser-inl.h"
2620
#include "simdjson/internal/tape_ref-inl.h"
2721
#include "simdjson/dom/serialization-inl.h"

‎include/simdjson/dom/jsonparser.h

-121
This file was deleted.

‎include/simdjson/dom/parsedjson.h

-17
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.