2021-01-05 04:21:50 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#if SIMDJSON_EXCEPTIONS
|
|
|
|
|
|
|
|
#include "find_tweet.h"
|
|
|
|
|
|
|
|
namespace find_tweet {
|
|
|
|
|
|
|
|
using namespace simdjson;
|
|
|
|
|
2021-01-05 12:20:24 +08:00
|
|
|
struct simdjson_dom {
|
2021-01-07 06:38:12 +08:00
|
|
|
using StringType=std::string_view;
|
|
|
|
|
2021-01-05 04:21:50 +08:00
|
|
|
dom::parser parser{};
|
2021-01-05 12:20:24 +08:00
|
|
|
|
2021-01-06 03:31:34 +08:00
|
|
|
bool run(simdjson::padded_string &json, uint64_t find_id, std::string_view &result) {
|
|
|
|
result = "";
|
2021-01-05 04:21:50 +08:00
|
|
|
auto doc = parser.parse(json);
|
|
|
|
for (auto tweet : doc["statuses"]) {
|
|
|
|
if (uint64_t(tweet["id"]) == find_id) {
|
2021-01-06 03:31:34 +08:00
|
|
|
result = tweet["text"];
|
2021-01-05 04:21:50 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-01-06 02:45:49 +08:00
|
|
|
BENCHMARK_TEMPLATE(find_tweet, simdjson_dom)->UseManualTime();
|
2021-01-05 04:21:50 +08:00
|
|
|
|
|
|
|
} // namespace find_tweet
|
|
|
|
|
|
|
|
#endif // SIMDJSON_EXCEPTIONS
|