2013-03-05 181 views
1

嗨,我很新的HBase數據庫。我下載了一些Twitter數據並存儲到MongoDB中。現在我需要將這些數據轉換爲HBase來加速Hadoop處理。但我無法創建它的方案。在這裏,我有twitter數據轉換爲JSON格式 -從MongoDB遷移到HBase

{ 
"_id" : ObjectId("512b71e6e4b02a4322d1c0b0"), 
"id" : NumberLong("306044618179506176"), 
"source" : "<a href=\"http://www.facebook.com/twitter\" rel=\"nofollow\">Facebook</a>", 
"user" : { 
    "name" : "Dada Bhagwan", 
    "location" : "India", 
    "url" : "http://www.dadabhagwan.org", 
    "id" : 191724440, 
    "protected" : false, 
    "timeZone" : null, 
    "description" : "Founder of Akram Vignan - Practical Spiritual Science of Self Realization", 
    "screenName" : "dadabhagwan", 
    "geoEnabled" : false, 
    "profileImageURL" : "http://a0.twimg.com/profile_images/1647956820/M_DSC_0034_normal.jpg", 
    "biggerProfileImageURL" : "http://a0.twimg.com/profile_images/1647956820/M_DSC_0034_bigger.jpg", 
    "profileImageUrlHttps" : "https://si0.twimg.com/profile_images/1647956820/M_DSC_0034_normal.jpg", 
    "profileImageURLHttps" : "https://si0.twimg.com/profile_images/1647956820/M_DSC_0034_normal.jpg", 
    "biggerProfileImageURLHttps" : "https://si0.twimg.com/profile_images/1647956820/M_DSC_0034_bigger.jpg", 
    "miniProfileImageURLHttps" : "https://si0.twimg.com/profile_images/1647956820/M_DSC_0034_mini.jpg", 
    "originalProfileImageURLHttps" : "https://si0.twimg.com/profile_images/1647956820/M_DSC_0034.jpg", 
    "followersCount" : 499, 
    "profileBackgroundColor" : "EEE4C1", 
    "profileTextColor" : "333333", 
    "profileLinkColor" : "990000", 
    "lang" : "en", 
    "profileSidebarFillColor" : "FCF9EC", 
    "profileSidebarBorderColor" : "CBC09A", 
    "profileUseBackgroundImage" : true, 
    "showAllInlineMedia" : false, 
    "friendsCount" : 1, 
    "favouritesCount" : 0, 
    "profileBackgroundImageUrl" : "http://a0.twimg.com/profile_background_images/396759326/dadabhagwan-twitter.jpg", 
    "profileBackgroundImageURL" : "http://a0.twimg.com/profile_background_images/396759326/dadabhagwan-twitter.jpg", 
    "profileBackgroundImageUrlHttps" : "https://si0.twimg.com/profile_background_images/396759326/dadabhagwan-twitter.jpg", 
    "profileBannerURL" : null, 
    "profileBannerRetinaURL" : null, 
    "profileBannerIPadURL" : null, 
    "profileBannerIPadRetinaURL" : null, 
    "miniProfileImageURL" : "http://a0.twimg.com/profile_images/1647956820/M_DSC_0034_mini.jpg", 
    "originalProfileImageURL" : "http://a0.twimg.com/profile_images/1647956820/M_DSC_0034.jpg", 
    "utcOffset" : -1, 
    "contributorsEnabled" : false, 
    "status" : null, 
    "createdAt" : NumberLong("1284700143000"), 
    "profileBannerMobileURL" : null, 
    "profileBannerMobileRetinaURL" : null, 
    "profileBackgroundTiled" : false, 
    "statusesCount" : 1713, 
    "verified" : false, 
    "translator" : false, 
    "listedCount" : 6, 
    "followRequestSent" : false, 
    "descriptionURLEntities" : [ ], 
    "urlentity" : { 
     "url" : "http://www.dadabhagwan.org", 
     "start" : 0, 
     "end" : 26, 
     "expandedURL" : "http://www.dadabhagwan.org", 
     "displayURL" : "http://www.dadabhagwan.org" 
    }, 
    "rateLimitStatus" : null, 
    "accessLevel" : 0 
}, 
"contributors" : [ ], 
"geoLocation" : null, 
"place" : null, 
"favorited" : false, 
"retweet" : false, 
"retweetedStatus" : null, 
"retweetCount" : 0, 
"userMentionEntities" : [ ], 
"retweetedByMe" : false, 
"currentUserRetweetId" : -1, 
"possiblySensitive" : false, 
"urlentities" : [ 
    { 
     "url" : "http://t.co/gR1GohGjaj", 
     "start" : 113, 
     "end" : 135, 
     "expandedURL" : "http://fb.me/2j2HKHJrM", 
     "displayURL" : "fb.me/2j2HKHJrM" 
    } 
], 
"hashtagEntities" : [ ], 
"mediaEntities" : [ ], 
"truncated" : false, 
"inReplyToStatusId" : -1, 
"text" : "Spiritual Quote of the Day :\n\n‘I am Chandubhai’ is an illusion itself and from that are \nkarmas charged. When... http://t.co/gR1GohGjaj", 
"inReplyToUserId" : -1, 
"inReplyToScreenName" : null, 
"createdAt" : NumberLong("1361801697000"), 
"rateLimitStatus" : null, 
"accessLevel" : 0 
} 

這裏如何將數據劃分爲列和列族?我想做一個"twitter" column-family,其中包含source, getlocation, place, retweet etc...和另一個"user" column-family和包含name, location etc...(用戶的數據)。即每個內部子文檔的新列家族。

這種方法是否正確?現在我怎麼區分urlentity"user" column-family"twitter" column-family

,以及如何處理那些包含子文件(如urlentity)的列表鍵

回答

3

有很多方法在HBase的模型此範圍從單一的列存儲都具有用於每個不同的表子實體與其他幾個表進行「索引」。

一般來說,您基於讀取和寫入訪問模式基於hbase中的數據建模。對於示例列族而言,它們存儲在磁盤上的不同文件中。將數據劃分爲兩列的原因在於是否存在大量需要來自一個數據庫而不是另一個數據庫的情況。等

有關於HBase的架構設計好介紹伊恩·瓦利從HBaseCon 2012,您可以找到幻燈片here和視頻here