HBase二 HBase資料模型

2021-09-02 10:05:37 字數 3142 閱讀 2639

hbase是基於google bigtable模型開發的,典型的key/value系統

1. hbase schema可以有多個table

2. 每個table可由多個column family組成。

3. hbase列族中的列可以隨意定義,因為hbase是無模式的。

1. byte array

2. 表中每條記錄的「主鍵」

3. row key可以是任意字串(最大長度是 64kb,實際應用中長度一般為 10-100bytes左右),hbase內部儲存為位元組陣列

4. 每一行的rowkey必須是唯一的

5. 在hbase記憶體,資料按照row key的字典序(byte order)排序儲存,因此設計key時要充分排序儲存這個特性,將經常一起讀取的行儲存放到一起。

1. 擁有乙個名稱(string)

2. 包含乙個或者多個相關列

3. table在水平方向有乙個或者多個column family組成,乙個column family中可以由任意多個column組成,即column family支援動態擴充套件,無需預先定義column的數量以及型別,所有column均以二進位制格式儲存,使用者需要自行進行型別轉換。

4. 列名都以列族作為字首。例如』courses:history』,』courses:math』,都屬於courses 這個列族。

1. 屬於某乙個column family

2. 包含在某一列中

3. familyname:columnname

4. 列名都以列族作為字首。例如』courses:history』,』courses:math』,都屬於courses 這個列族。

1. 每個rowkey唯一,即每行內部沒有重複的時間戳

2. 預設值是系統時間戳

3. 型別為long

4. 無需以遞增的順序插入

1. byte array

2. 單元格是用來存放資料值的位置,乙個單元格中可以多份資料(資料具有版本號),如上圖中,contents的有html**,有三份資料,分別是t3,t5和t6時刻的資料,t3,t5和t6是時間戳

3. table可以非常稀疏, 很多cell 可以是空的

4. cell由 唯一確定的單元。cell中的資料是沒有型別的,全部是位元組碼形式存貯。

上圖中,對前面提到的hbase資料模型進行了例項演示:

下圖是以行列形式表現的資料模型

4.1 hbase shell支援的操作

hbase(main):001:0> help

hbase shell, version 1.0.0, r6c98bff7b719efdb16f71606f3b7d8229445eb81, sat feb 14 19:49:22 pst 2015

type 'help "command"', (e.g. 'help "get"' -- the quotes are necessary) for help on a specific command.

commands are grouped. type 'help "command_group"', (e.g. 'help "general"') for help on a command group.

command groups:

group name: general

commands: status, table_help, version, whoami

group name: ddl

commands: alter, alter_async, alter_status, create, describe, disable, disable_all, drop, drop_all, enable, enable_all, exists, get_table, is_disabled, is_enabled, list, show_filters

group name: namespace

commands: alter_namespace, create_namespace, describe_namespace, drop_namespace, list_namespace, list_namespace_tables

group name: dml

group name: tools

commands: assign, balance_switch, balancer, catalogjanitor_enabled, catalogjanitor_run, catalogjanitor_switch, close_region, compact, compact_rs, flush, major_compact, merge_region, move, split, trace, unassign, wal_roll, zk_dump

group name: replication

group name: snapshots

commands: clone_snapshot, delete_all_snapshot, delete_snapshot, list_snapshots, restore_snapshot, snapshot

group name: configuration

commands: update_all_config, update_config

group name: security

commands: grant, revoke, user_permission

group name: visibility labels

commands: add_labels, clear_auths, get_auths, list_labels, set_auths, set_visibility

單行操作:

put/get/scan

多行操作:

scan

multiput

hbase不支援join操作,需要借助於map-reduce實現

hbase資料模型

與nosql資料庫們一樣,rowkey是用來檢索記錄的主鍵。訪問hbase table中的行 訪問方式 a.通過單個row key訪問,b.通過row key的range 正則 c.全表掃瞄,rowkey是任意字串,最大長度 是 64kb,實際應用中長度一般為 10 100bytes,hbase內部...

Hbase資料模型

hbase 以表的形式儲存資料。表由行和列族組成。列劃分為若干個列族 row family 其邏輯檢視如下 幾個關鍵概念 1 行鍵 rowkey 行鍵是位元組陣列,任何字串都可以作為行鍵 表中的行根據行鍵進行排序,資料按照 row key 的位元組序 byte order 排序 儲存 所有對錶的訪問...

hbase資料模型

與nosql資料庫一樣,row key是用來檢索記錄的主鍵。訪問hbase table中的行,只有三種方式 1.通過單個row key訪問 2.通過row key的range 正則 3.全表掃瞄 row key行鍵 row key 可以是任意字串 最大長度 是 64kb,實際應用中長度一般為 10 ...