2015-04-02 88 views
0
hbase(main):004:0> create 'htable','cf' 
0 row(s) in 0.4790 seconds 

=> Hbase::Table - htable 
hbase(main):005:0> alter 'htable', NAME => 'id', VERSIONS => 100 
Updating all regions with the new schema... 
0/1 regions updated. 
1/1 regions updated. 
Done. 
0 row(s) in 2.2790 seconds 

hbase(main):006:0> put 'htable','row1','cf:id',2 
0 row(s) in 0.1560 seconds 

hbase(main):007:0> put 'htable','row1','cf:id',4 
0 row(s) in 0.0080 seconds 

hbase(main):008:0> get 'htable', 'row1', {COLUMN => 'cf:id', VERSIONS => 4} 
COLUMN    CELL              
cf:id    timestamp=1428041368763, value=4       
1 row(s) in 0.0200 seconds 

我通过设置VERSIONS => 100更改了表格,但每次都会给出最新记录的 。如何获得旧的价值?是否有任何附加命令或设置需求?如何获取hbase shell中的旧值

回答

1

在HBase的外壳试试这个:

disable 'htable'

drop 'htable'

create 'htable',NAME=>'cf',VERSIONS=>100

put 'htable','row1','cf:id',1

scan 'htable'

put 'htable','row1','cf:id',2

scan 'htable'

put 'htable','row1','cf:id',3

scan 'htable'

put 'htable','row1','cf:id',4

scan 'htable'

get 'htable', 'row1', {COLUMN => 'cf:id', VERSIONS => 4}

Scan命令是验证和匹配时间戳。

+0

谢谢你的回答,当我在create table创建版本=> 100时,我得到了输出。但我不能放桌子。我希望在运行时,通过改变表的意思。是否有可能在更改命令后获取下一个更新值的版本? – 2015-04-03 05:55:01

+0

你不需要每次都丢掉表格。如果你不想下降,从第一个'put'命令开始。那会做。 :) – 2015-04-03 06:01:40

+0

你没有得到我,我已经有没有启用版本的表。我通过“alter'htable',NAME =>'id',VERSIONS => 100 ”来改变表格。然后将该值放在相同的行键上。当我得到行时,我只获得最后的价值。检查更新的问题 – 2015-04-03 06:13:09