注意:数小时前,我已经开始使用HBase,并且我来自RDBMS背景:P
我有一个类似于RDBMS的表CUSTOMERS,具有以下各列:
我想到了以下等效的HBase:
根据我所读的内容,RDBMS表中的主键与HBase表的行键大致相似。因此,我想将CUSTOMER_ID保留为行键。
我的问题很愚蠢而直截了当:
类,如何定义行键?我什么也没找到
在 shell 程序或HBaseAdmin类中(类似
HBaseAdmin.createSuperKey(...))
***编辑后添加示例代码段
我只是想在shell中使用'put'为客户表创建一行。我是这样做的:
hbase(main):011:0> put 'CUSTOMERS', 'CUSTID12345', 'CUSTOMER_INFO:NAME','Omkar Joshi'
0 row(s) in 0.1030 seconds
hbase(main):012:0> scan 'CUSTOMERS'
ROW COLUMN+CELL
CUSTID12345 column=CUSTOMER_INFO:NAME, timestamp=1365600052104, value=Omkar Joshi
1 row(s) in 0.0500 seconds
hbase(main):013:0> put 'CUSTOMERS', 'CUSTID614', 'CUSTOMER_INFO:NAME','Prachi Shah', 'CUSTOMER_INFO:EMAIL','Prachi.Shah@lntinfotech.com'
ERROR: wrong number of arguments (6 for 5)
Here is some help for this command:
Put a cell 'value' at specified table/row/column and optionally
timestamp coordinates. To put a cell value into table 't1' at
row 'r1' under column 'c1' marked with the time 'ts1', do:
hbase> put 't1', 'r1', 'c1', 'value', ts1
hbase(main):014:0> put 'CUSTOMERS', 'CUSTID12345', 'CUSTOMER_INFO:EMAIL','Omkar.Joshi@lntinfotech.com'
0 row(s) in 0.0160 seconds
hbase(main):015:0>
hbase(main):016:0* scan 'CUSTOMERS'
ROW COLUMN+CELL
CUSTID12345 column=CUSTOMER_INFO:EMAIL, timestamp=1365600369284, value=Omkar.Joshi@lntinfotech.com
CUSTID12345 column=CUSTOMER_INFO:NAME, timestamp=1365600052104, value=Omkar Joshi
1 row(s) in 0.0230 seconds
最多投入5个参数,我无法弄清楚如何在一个put命令中插入整行。这将导致不需要的同一行的增量版本,而且我不确定CUSTOMER_ID是否被用作行键!
感谢致敬 !
最佳答案
您可以阅读/了解有关HBase模式设计here和here的信息。
关于nosql - HBase-行键基础,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15917558/