如何为Twitter数据设计HBase模式?

如何为Twitter数据设计HBase模式?,twitter,nosql,hbase,Twitter,Nosql,Hbase,我有以下Twitter数据,我想为这些数据设计一个模式。我需要执行的查询如下: 获取时间间隔的推文量、包含相应用户信息的推文、包含相应主题信息的推文等。。。根据下面的数据,任何人都能说出模式设计的正确之处。。(将rowkey设置为id+时间戳,将列族设置为用户,将其他列分组到主列中。有什么建议吗 { "created_at":"Tue Feb 19 11:16:34 +0000 2013", "id":303825398179979265, "id_str":"30382539

我有以下Twitter数据,我想为这些数据设计一个模式。我需要执行的查询如下: 获取时间间隔的推文量、包含相应用户信息的推文、包含相应主题信息的推文等。。。根据下面的数据,任何人都能说出模式设计的正确之处。。(将rowkey设置为id+时间戳,将列族设置为用户,将其他列分组到主列中。有什么建议吗

{
   "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
}

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

303825398179979265->数据\u CF

列族数据将在以下行中定义:

"created_at":"Tue Feb 19 11:16:34 +0000 2013" "id_str":"303825398179979265" ... "user_id":948385189 { take note here I'm denormalizing your dictionary } "user_name":"Innovation Plaza" “创建时间”:“2013年2月19日星期二11:16:34+0000” “id_街”:“303825398179979265” ... “user_id”:948385189{注意,我正在对你的字典进行非规范化处理} “用户名”:“创新广场” 对于列表来说,它变得有点棘手。解决方案是在类别前面加上一些使其唯一的前缀:

"entities_hashtags_":"\x00" { Here \x00 is a dummy value } “entities\u hashtags:”\x00“{这里\x00是一个伪值} 对于URL,如果排序不重要,您可以在其前面加上UUID。这将保证它是唯一的

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

对于第二个问题,如果您需要即时聚合信息,则必须按照您在另一个表中所述对其进行预计算和存储。如果您希望通过M/R生成此数据,则可以将时间戳+行id放在基于时间的位置。按主题类似于主题+行id。这允许您编写前缀sca带有开始-停止行的ns,该行将仅包括您感兴趣的时间范围或主题

玩得开心