avroSchema.setFields(fields);
return avroSchema;
}
private Record extractRecord(String idPrefix, Schema avroSchema, Status status) {
User user = status.getUser();
Record doc = new Record(avroSchema);
doc.put("id", idPrefix + status.getId());
doc.put("created_at", formatterTo.format(status.getCreatedAt()));
doc.put("retweet_count", status.getRetweetCount());
doc.put("retweeted", status.isRetweet());
doc.put("in_reply_to_user_id", status.getInReplyToUserId());
doc.put("in_reply_to_status_id", status.getInReplyToStatusId());
addString(doc, "source", status.getSource());
addString(doc, "text", status.getText());
MediaEntity[] mediaEntities = status.getMediaEntities();
if (mediaEntities.length > 0) {
addString(doc, "media_url_https", mediaEntities[0].getMediaURLHttps());
addString(doc, "expanded_url", mediaEntities[0].getExpandedURL());
}
doc.put("user_friends_count", user.getFriendsCount());
doc.put("user_statuses_count", user.getStatusesCount());
doc.put("user_followers_count", user.getFollowersCount());
addString(doc, "user_location", user.getLocation());
addString(doc, "user_description", user.getDescription());
addString(doc, "user_screen_name", user.getScreenName());
addString(doc, "user_name", user.getName());
return doc;
}