简体   繁体   English

如何在HBase中查看3版本的数据

[英]how to see 3 version of Data in HBase

I have a SQL table with 6 columns, "row_id","customer_id","f_name","l_name","location","last_update_date". 我有一个包含6列“ row_id”,“ customer_id”,“ f_name”,“ l_name”,“ location”,“ last_update_date”的SQL表。

1) I have created a HBase table through SQOOP for the above SQL table, below is the sqoop syntax 1)我已经通过SQOOP为上面的SQL表创建了一个HBase表,下面是sqoop语法

sqoop import --connect "jdbc:sqlserver://server:port;databaseName=db" --username xxx --password xxx --table xxx --hbase-table xxx --column-family amitesh --hbase-row-key row_id,customer_id --hbase-create-table -m 1

In the above sqooping, I have created a hbase row key by concatenating 2 columns, and its working fine, so far so good. 在上面的讨论中,我通过连接2列创建了一个hbase行键,到目前为止,它工作正常。 Below is the Hbase "scan" output 下面是Hbase的“扫描”输出

hbase(main):036:0> scan 'xxx'
ROW                                          COLUMN+CELL
 111_emp1                                    column=amitesh:f_name, timestamp=1497365606380, value=dev
 111_emp1                                    column=amitesh:l_name, timestamp=1497365606380, value=saha
 111_emp1                                    column=amitesh:last_update_date, timestamp=1497365606380, value=2017-06-12
 111_emp1                                    column=amitesh:location, timestamp=1497365606380, value=hyd
 112_emp1                                    column=amitesh:f_name, timestamp=1497365606380, value=hari
 112_emp1                                    column=amitesh:l_name, timestamp=1497365606380, value=sri
 112_emp1                                    column=amitesh:last_update_date, timestamp=1497365606380, value=2017-06-13
 112_emp1                                    column=amitesh:location, timestamp=1497365606380, value=bng

2) when I "describe hbase_tbl", I found that the value of "VERSIONS =>1", AS YOU CAN SEE BELOW: 2)当我“描述hbase_tbl”时,发现“ VERSIONS => 1”的值如下所示:

hbase(main):025:0> describe 'xxx'
Table HBASE_SQOOP is ENABLED
HBASE_SQOOP
COLUMN FAMILIES DESCRIPTION
{NAME => 'amitesh', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', COMPRESSION
 => 'NONE', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE => '0'}

So, in order to change the value to 2 of version, I executed below HBase command. 因此,为了将值更改为version 2,我在HBase命令下面执行。

alter 'xxx', {NAME => 'amitesh', VERSIONS => 2}

Which happen to run successfully, and the changed value now displayed by "describe" command for VERSION was 2. 碰巧成功运行了,现在“描述”命令为VERSION显示的更改值为2。

3) Now to keep 2 version of the f_name, and l_name for the HBase row id 111_emp1, I updated the SQL Server table for row_id 111 twice, and re-sqooped it, but all I could see only the updated values, I do not see the current and past version of them, below is the "get" output" 3)现在,保留2个版本的f_name和l_name作为HBase行ID 111_emp1,我将row_id 111的SQL Server表更新了两次,并重新对其进行了查询,但是我只能看到更新的值,但我没有查看它们的当前和过去版本,下面是“获取”输出”

hbase(main):038:0> get 'xxx', '111_emp1',{COLUMN=> 'amitesh:f_name',VERSION=>2}
COLUMN                                       CELL
 amitesh:f_name                              timestamp=1497365606380, value=dev
1 row(s) in 0.0040 seconds


hbase(main):047:0> get 'xx', '111_emp1',{COLUMN=> 'amitesh:f_name',VERSION=>2}
COLUMN                                       CELL
 amitesh:f_name                              timestamp=1497365863181, value=Raj
1 row(s) in 0.0110 seconds

As you can see above 2 "get" output, in the first "get", the value for f_name is "dev", and for 2nd "get", the value is "raj". 从上面的2个“ get”输出中可以看到,在第一个“ get”中,f_name的值为“ dev”,而对于第二个“ get”,则值为“ raj”。 But I expected to see "dev", and "raj" as my output. 但是我希望看到“ dev”和“ raj”作为我的输出。 Since as per my "alter" command, the HBase should hold both of them together, but its not happening. 因为按照我的“ alter”命令,HBase应该将它们结合在一起,但是没有发生。

What am I missing? 我想念什么?

It is VERSIONS => 2 . 它是VERSIONS => 2 The correct syntax to get more than one version would be 获得多个版本的正确语法是

get 'xxx', '111_emp1',{COLUMN=> 'amitesh:f_name',VERSIONS=>2}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM