av激情亚洲男人的天堂国语,日韩欧美精品一中文字幕,无码av一区二区三区无码,国产又色又爽又刺激的a片,国产又色又爽又刺激的a片

使用HBaseShell接口的幾點注意事項

本文主要介紹了使用HBase Shell接口的幾點注意事項,問題如下:

問題1,  HBase(可以理解為不需要建'name'列,hbase自動建立一個用于存儲“行標識”的“列”),舉例如下:

例一:

 
 
 
  1. create 'employees', 'SN', 'department', 'address'   這個employees表的結(jié)構(gòu)將為:  
  2.  
  3. row_id     SN    department    address  
  4.  
  5. -------------------------------------------------- 

 

共有四列,***列用于標識行, 這里你可以當做‘name’來用

插入數(shù)據(jù): put 'employees', 'HongKong', 'SN:', '20080501'

注意是put,不是Ruby的puts

對比的情況:

創(chuàng)建表:

 
 
 
  1. create 'employees', 'name', 'SN', 'department', 'address' 

 

此時數(shù)據(jù)為: 除了標識本身外,還有一個name列,下面簡單設(shè)置為一樣的值。

 
 
 
  1. put 'employees', 'HongKong', 'name:', 'HongKong' 

 

例二:

網(wǎng)上流行資料的例子:

一個存儲學生成績的表:

 
 
 
  1. name grad      course:math   course:art  
  2.  
  3. Tom    1                87                   
  4.  
  5. 97  
  6.  
  7. Tom    1                87                   
  8.  
  9. 97  
  10.  
  11. Jerry   2            100                  80 

 

這里grad對于表來說是一個列,course對于表來說是一個列族,這個列族由兩個列組成:math和art,當然我們可以根據(jù)我們的需要在course中建立更多的列族,如computer,physics等相應的列添加入course列族.  建立一個表格 scores 具有兩個列族grad 和courese

 
 
 
  1. hbase(main):002:0> create 'scores', 'grade', 'course'  
  2.  
  3. 0 row(s) in 4.1610 seconds 

 

分析,請注意,為什么創(chuàng)建的表是沒有“name”這一列呢? 其實這里的name列就對應例一的row_id,不用顯式創(chuàng)建的。

導入數(shù)據(jù)為:  put 'scores', 'Tom', 'grade:', '1'     , Tom對應name

問題2. 參數(shù)的警告說明

很多人開始都碰到類似。

 
 
 
  1. hbase(main):034:0> put 'employees', 'HongKong', 'name:', 'Hongkong', 'SN:', '20080501'  
  2.  
  3. ArgumentError: wrong number of arguments (6 for 5)  
  4.  
  5. hbase(main):033:0> put 'employees', 'Kong', 'name:' 'Kong'  
  6.  
  7. ArgumentError: wrong number of arguments (3 for 4) 

 

這是參數(shù)數(shù)量不對的說明, 請尤其注意逗號, 空格不能用來分隔參數(shù)的。

以put為例,參數(shù)一般為5個, 6個 10個都報錯。但為什么又有(3 for 4)呢?  5和4個的時候可以工作呢?  timestamp 是optional的。所以參數(shù)多的時候, 按照上限5報警,少的時候按照下限4報警。

 
 
 
  1. Put a cell 'value' at specified table/row/column and optionally  
  2.  
  3. timestamp coordinates.  To put a cell value into table 't1' at  
  4.  
  5. row 'r1' under column 'c1' marked with the time 'ts1', do:  
  6.  
  7. hbase> put 't1', 'r1', 'c1', 'value', ts1 

 

問題3.  插入數(shù)據(jù)

 
 
 
  1. hbase(main):030:0> put 'employees', 'Tom', 'name:' 'Tom', 'SN:', '20091101', 'department:', 'D&R', 'address:country', 'China', 'address:city', 'Beijing'  
  2.  
  3. ArgumentError: wrong number of arguments (11 for 5) 

 

怎么回事呢?  不要老想著SQL, put插入的Cell數(shù)據(jù),  這么多一起來,當然報錯咯

問題4.  刪除表必須先停,然后再刪: To remove the table, you must first disable it before dropping it

 
 
 
  1. hbase(main):025:0> disable 'test'  
  2.  
  3. 09/04/19 06:40:13 INFO client.HBaseAdmin: Disabled test  
  4.  
  5. 0 row(s) in 6.0426 seconds  
  6.  
  7. hbase(main):026:0> drop 'test'  
  8.  
  9. 09/04/19 06:40:17 INFO client.HBaseAdmin: Deleted test 

 

問題5.  如何運行腳本文件

${HBASE_HOME}/bin/hbase shell PATH_TO_SCRIPT

示例:

 
 
 
  1. ./hbase shell /data/automation/create_import.hbase  
  2.  
  3. --------------------------------------------------------------------------------------------  
  4.  
  5. disable 'employees'  
  6.  
  7. drop 'employees'  
  8.  
  9. create 'employees', 'SN', 'department', 'address'  
  10.  
  11. put 'employees', 'HongKong', 'SN:', '20080501189'  
  12.  
  13. put 'employees', 'HongKong', 'department:', 'R&D'  
  14.  
  15. put 'employees', 'HongKong', 'address:country', 'China'  
  16.  
  17. put 'employees', 'HongKong', 'address:city', 'Beijing'  
  18.  
  19. put 'employees', 'Cudynia', 'SN:', '20010807368'  
  20.  
  21. put 'employees', 'Cudynia', 'department:', 'HR'  
  22.  
  23. put 'employees', 'Cudynia', 'address:country', 'US'  
  24.  
  25. put 'employees', 'Cudynia', 'address:city', 'San Francisco'  
  26.  
  27. exit 

關(guān)于使用HBase Shell 接口的注意事項就介紹到這里了,希望能夠帶給您收獲!


網(wǎng)頁標題:使用HBaseShell接口的幾點注意事項
轉(zhuǎn)載源于:http://uogjgqi.cn/article/djejsjc.html
掃二維碼與項目經(jīng)理溝通

我們在微信上24小時期待你的聲音

解答本文疑問/技術(shù)咨詢/運營咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流