Hbase-03-shell get 命令
获取一行或者一个单元数据
hbase:001:0> help 'get'
Get row or cell contents; pass table name, row, and optionally
a dictionary of column(s), timestamp, timerange and versions. Examples:
hbase> get 'ns1:t1', 'r1'
hbase> get 't1', 'r1'
hbase> get 't1', 'r1', {TIMERANGE => [ts1, ts2]}
hbase> get 't1', 'r1', {COLUMN => 'c1'}
hbase> get 't1', 'r1', {COLUMN => ['c1', 'c2', 'c3']}
hbase> get 't1', 'r1', {COLUMN => 'c1', TIMESTAMP => ts1}
hbase> get 't1', 'r1', {COLUMN => 'c1', TIMERANGE => [ts1, ts2], VERSIONS => 4}
hbase> get 't1', 'r1', {COLUMN => 'c1', TIMESTAMP => ts1, VERSIONS => 4}
hbase> get 't1', 'r1', {FILTER => "ValueFilter(=, 'binary:abc')"}
hbase> get 't1', 'r1', 'c1'
hbase> get 't1', 'r1', 'c1', 'c2'
hbase> get 't1', 'r1', ['c1', 'c2']
hbase> get 't1', 'r1', {COLUMN => 'c1', ATTRIBUTES => {'mykey'=>'myvalue'}}
hbase> get 't1', 'r1', {COLUMN => 'c1', AUTHORIZATIONS => ['PRIVATE','SECRET']}
hbase> get 't1', 'r1', {CONSISTENCY => 'TIMELINE'}
hbase> get 't1', 'r1', {CONSISTENCY => 'TIMELINE', REGION_REPLICA_ID => 1}
Besides the default 'toStringBinary' format, 'get' also supports custom formatting by
column. A user can define a FORMATTER by adding it to the column name in the get
specification. The FORMATTER can be stipulated:
1. either as a org.apache.hadoop.hbase.util.Bytes method name (e.g, toInt, toString)
2. or as a custom class followed by method name: e.g. 'c(MyFormatterClass).format'.
Example formatting cf:qualifier1 and cf:qualifier2 both as Integers:
hbase> get 't1', 'r1' {COLUMN => ['cf:qualifier1:toInt',
'cf:qualifier2:c(org.apache.hadoop.hbase.util.Bytes).toInt'] }
Note that you can specify a FORMATTER by column only (cf:qualifier). You can set a
formatter for all columns (including, all key parts) using the "FORMATTER"
and "FORMATTER_CLASS" options. The default "FORMATTER_CLASS" is
"org.apache.hadoop.hbase.util.Bytes".
hbase> get 't1', 'r1', {FORMATTER => 'toString'}
hbase> get 't1', 'r1', {FORMATTER_CLASS => 'org.apache.hadoop.hbase.util.Bytes', FORMATTER => 'toString'}
The same commands also can be run on a reference to a table (obtained via get_table or
create_table). Suppose you had a reference t to table 't1', the corresponding commands
would be:
hbase> t.get 'r1'
hbase> t.get 'r1', {TIMERANGE => [ts1, ts2]}
hbase> t.get 'r1', {COLUMN => 'c1'}
hbase> t.get 'r1', {COLUMN => ['c1', 'c2', 'c3']}
hbase> t.get 'r1', {COLUMN => 'c1', TIMESTAMP => ts1}
hbase> t.get 'r1', {COLUMN => 'c1', TIMERANGE => [ts1, ts2], VERSIONS => 4}
hbase> t.get 'r1', {COLUMN => 'c1', TIMESTAMP => ts1, VERSIONS => 4}
hbase> t.get 'r1', {FILTER => "ValueFilter(=, 'binary:abc')"}
hbase> t.get 'r1', 'c1'
hbase> t.get 'r1', 'c1', 'c2'
hbase> t.get 'r1', ['c1', 'c2']
hbase> t.get 'r1', {CONSISTENCY => 'TIMELINE'}
hbase> t.get 'r1', {CONSISTENCY => 'TIMELINE', REGION_REPLICA_ID => 1}
表中的数据
获取一行值:
hbase:043:0> get 'Student','0001'
COLUMN CELL
Grades:BigData timestamp=2021-07-19T20:31:39.473, value=80
Grades:Computer timestamp=2021-07-19T20:31:39.491, value=90
Grades:Math timestamp=2021-07-19T20:31:41.910, value=85
Stulnfo:Name timestamp=2021-07-19T20:32:27.004, value=Jim Green\x0A
1 row(s)
Took 0.0111 seconds
获取某一个列族的值
hbase:045:0> get 'Student', '0001', {COLUMN => 'Grades'}
COLUMN CELL
Grades:BigData timestamp=2021-07-19T20:31:39.473, value=80
Grades:Computer timestamp=2021-07-19T20:31:39.491, value=90
Grades:Math timestamp=2021-07-19T20:31:41.910, value=85
1 row(s)
Took 0.0074 seconds
hbase:046:0>
获取某个时间段的数据
hbase:046:0> get 'Student', '0001', {COLUMN => 'Grades',TIMERANGE =>[1626630169000,1626698581000]}
COLUMN CELL
Grades:BigData timestamp=2021-07-19T20:31:39.473, value=80
Grades:Computer timestamp=2021-07-19T20:31:39.491, value=90
Grades:Math timestamp=2021-07-19T20:31:41.910, value=85
1 row(s)
Took 0.0079 seconds
hbase:047:0>
获取3个版本的值
hbase:054:0> get 'Student', '0001', {COLUMN => 'Grades', VERSIONS => 3}
COLUMN CELL
Grades:BigData timestamp=2021-07-19T20:31:39.473, value=80
Grades:Computer timestamp=2021-07-19T20:31:39.491, value=90
Grades:Math timestamp=2021-07-19T20:31:41.910, value=85
1 row(s)
Took 0.0070 seconds
hbase:055:0>
获取某个大于某值的值
hbase:056:0> get 'Student', '0001' ,{FILTER=>"ValueFilter(=, 'binary:80')"}
COLUMN CELL
Grades:BigData timestamp=2021-07-19T20:31:39.473, value=80
1 row(s)
Took 0.0511 seconds
hbase:057:0> get 'Student', '0001' ,{FILTER=>"ValueFilter(>, 'binary:80')"}
COLUMN CELL
Grades:Computer timestamp=2021-07-19T20:31:39.491, value=90
Grades:Math timestamp=2021-07-19T20:31:41.910, value=85
Stulnfo:Name timestamp=2021-07-19T20:32:27.004, value=Jim Green\x0A
1 row(s)
Took 0.0049 seconds
hbase:058:0> get 'Student', '0001' ,{FILTER=>"ValueFilter(>=, 'binary:80')"}
COLUMN CELL
Grades:BigData timestamp=2021-07-19T20:31:39.473, value=80
Grades:Computer timestamp=2021-07-19T20:31:39.491, value=90
Grades:Math timestamp=2021-07-19T20:31:41.910, value=85
Stulnfo:Name timestamp=2021-07-19T20:32:27.004, value=Jim Green\x0A
1 row(s)
Took 0.0055 seconds
hbase:059:0>
获取某一列的值
hbase:063:0> get 'Student', '0001', {COLUMN => 'Grades:Math', VERSIONS => 3}
COLUMN CELL
Grades:Math timestamp=2021-07-19T20:31:41.910, value=85
1 row(s)
Took 0.0064 seconds
hbase:064:0>
不要小瞧女程序员
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· winform 绘制太阳,地球,月球 运作规律
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· AI 智能体引爆开源社区「GitHub 热点速览」
· Manus的开源复刻OpenManus初探
· 写一个简单的SQL生成工具
2019-07-20 19. slot插槽传递模板
2019-07-20 18. VUE created 方法作用
2019-07-20 17. Vue2.4+新增属性$listeners
2019-07-20 16. Vue2.4+新增属性$attrs
2019-07-20 1. HTML <fieldset> 标签
2019-07-20 15. Vue2.4+新增属性.sync
2019-07-20 14. VUE 子组件修改父组件的值