simdjson/benchmark/partial_tweets/tweet.h

62 lines
2.2 KiB
C
Raw Normal View History

#pragma once
2020-08-09 10:24:09 +08:00
#include "simdjson.h"
#include "twitter_user.h"
namespace partial_tweets {
2020-08-09 10:24:09 +08:00
2020-08-14 04:36:20 +08:00
// {
// "statuses": [
// {
// "created_at": "Sun Aug 31 00:29:15 +0000 2014",
// "id": 505874924095815700,
// "text": "@aym0566x \n\n名前:前田あゆみ\n第一印象:なんか怖っ!\n今の印象:とりあえずキモい。噛み合わない\n好きなところ:ぶすでキモいとこ😋✨✨\n思い出:んーーー、ありすぎ😊❤️\nLINE交換できる:あぁ……ごめん✋\nトプ画をみて:照れますがな😘✨\n一言:お前は一生もんのダチ💖",
// "in_reply_to_status_id": null,
// "user": {
// "id": 1186275104,
// "screen_name": "ayuu0123"
// },
// "retweet_count": 0,
// "favorite_count": 0
// }
// ]
// }
2021-01-07 06:38:12 +08:00
template<typename StringType=std::string_view>
2020-08-09 10:24:09 +08:00
struct tweet {
2021-01-07 06:38:12 +08:00
StringType created_at{};
2020-08-09 10:24:09 +08:00
uint64_t id{};
2021-01-07 06:38:12 +08:00
StringType result{};
2020-08-09 10:24:09 +08:00
uint64_t in_reply_to_status_id{};
2021-01-07 06:38:12 +08:00
twitter_user<StringType> user{};
2020-08-09 10:24:09 +08:00
uint64_t retweet_count{};
uint64_t favorite_count{};
2021-01-07 06:38:12 +08:00
template<typename OtherStringType>
simdjson_really_inline bool operator==(const tweet<OtherStringType> &other) const {
return created_at == other.created_at &&
id == other.id &&
2021-01-06 03:31:34 +08:00
result == other.result &&
in_reply_to_status_id == other.in_reply_to_status_id &&
user == other.user &&
retweet_count == other.retweet_count &&
favorite_count == other.favorite_count;
}
2021-01-07 06:38:12 +08:00
template<typename OtherStringType>
simdjson_really_inline bool operator!=(const tweet<OtherStringType> &other) const { return !(*this == other); }
2020-08-09 10:24:09 +08:00
};
2021-01-07 06:38:12 +08:00
template<typename StringType>
simdjson_unused static std::ostream &operator<<(std::ostream &o, const tweet<StringType> &t) {
o << "created_at: " << t.created_at << std::endl;
o << "id: " << t.id << std::endl;
2021-01-06 03:31:34 +08:00
o << "result: " << t.result << std::endl;
o << "in_reply_to_status_id: " << t.in_reply_to_status_id << std::endl;
o << "user.id: " << t.user.id << std::endl;
o << "user.screen_name: " << t.user.screen_name << std::endl;
o << "retweet_count: " << t.retweet_count << std::endl;
o << "favorite_count: " << t.favorite_count << std::endl;
return o;
}
} // namespace partial_tweets