2

我有以下 Twitter 数据,我想为相同的数据设计一个模式。我需要执行的查询如下:获取时间间隔的推文量、具有相应用户信息的推文、具有相应主题信息的推文等...根据以下数据,任何人都知道架构设计在哪里是正确的..(将行键设为 id+timestamp,列族作为用户,其他分组到主列中。有什么建议吗?

{
   "created_at":"Tue Feb 19 11:16:34 +0000 2013",
   "id":303825398179979265,
   "id_str":"303825398179979265",
   "text":"Unleashing Innovation Conference Kicks Off - Wall Street Journal (India)              http:\/\/t.co\/3bkXJBz1",
   "source":"\u003ca href=\"http:\/\/dlvr.it\" rel=\"nofollow\"\u003edlvr.it\u003c\/a\u003e",
   "truncated":false,
   "in_reply_to_status_id":null,
   "in_reply_to_status_id_str":null,
   "in_reply_to_user_id":null,
   "in_reply_to_user_id_str":null,
   "in_reply_to_screen_name":null,
   "user":{
      "id":948385189,
      "id_str":"948385189",
      "name":"Innovation Plaza",
      "screen_name":"InnovationPlaza",
      "location":"",
      "url":"http:\/\/tinyurl.com\/ee4jiralp",
      "description":"All the latest breaking news about Innovation",
      "protected":false,
      "followers_count":136,
      "friends_count":1489,
      "listed_count":1,
      "created_at":"Wed Nov 14 19:49:18 +0000 2012",
      "favourites_count":0,
      "utc_offset":28800,
      "time_zone":"Beijing",
      "geo_enabled":false,
      "verified":false,
      "statuses_count":149,
      "lang":"en",
      "contributors_enabled":false,
      "is_translator":false,
      "profile_background_color":"131516",
      "profile_background_image_url":"http:\/\/a0.twimg.com\/profile_background_images\/781710342\/17a75bf22d9fdad38eebc1c0cd441527.jpeg",
      "profile_background_image_url_https":"https:\/\/si0.twimg.com\/profile_background_images\/781710342\/17a75bf22d9fdad38eebc1c0cd441527.jpeg",
      "profile_background_tile":true,
      "profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/3205718892\/8126617ac6b7a0e80fe219327c573852_normal.jpeg",
      "profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/3205718892\/8126617ac6b7a0e80fe219327c573852_normal.jpeg",
      "profile_link_color":"009999",
      "profile_sidebar_border_color":"FFFFFF",
      "profile_sidebar_fill_color":"EFEFEF",
      "profile_text_color":"333333",
      "profile_use_background_image":true,
      "default_profile":false,
      "default_profile_image":false,
      "following":null,
      "follow_request_sent":null,
      "notifications":null
   },
   "geo":null,
   "coordinates":null,
   "place":null,
   "contributors":null,
   "retweet_count":0,
   "entities":{
      "hashtags":[

      ],
      "urls":[
         {
            "url":"http:\/\/t.co\/3bkXJBz1",
            "expanded_url":"http:\/\/dlvr.it\/2yyG5C",
            "display_url":"dlvr.it\/2yyG5C",
            "indices":[
               73,
               93
            ]
         }
      ],
      "user_mentions":[

      ]
   },
   "favorited":false,
   "retweeted":false,
   "possibly_sensitive":false
}
4

1 回答 1

0

如果您 100% 确定 ID 是唯一的,则可以将其作为行键来存储大量数据:

303825398179979265 -> 数据_CF

您的列族 data_CF 将在这些行中定义:

"created_at":"2 月 19 日星期二 11:16:34 +0000 2013"
“id_str”:“303825398179979265”
...
"user_id":948385189 { 请注意我正在对您的字典进行非规范化}
"user_name":"创新广场"

列表有点棘手。解决方案是在类别前添加一些使其唯一的东西:

"entities_hashtags_":"\x00" { 这里 \x00 是一个虚拟值 }

对于 URL,如果顺序不重要,您可以在其前面加上 UUID。它将保证它是独一无二的。

这种方法的优点是如果您需要更新此数据中的字段,它将以原子方式完成,因为 HBase 保证行原子性。

对于第二个问题,如果您需要即时汇总信息,您将不得不预先计算它并将其存储在另一个表中。如果您希望通过 M/R 生成此数据,如果要基于时间,您可以输入时间戳 + 行 ID。按主题将类似于主题 + 行 ID。这允许您编写带有开始停止行的前缀扫描,其中仅包含时间范围或您感兴趣的主题。

玩得开心 !

于 2013-03-14T19:59:25.413 回答