【发布时间】:2014-01-07 13:05:25
【问题描述】:
我对 Hadoop 和 HBase 还很陌生,正在尝试学习和评估它是否可以用于我的用例。作为 Java 新手(我基本上是 Perl/Unix 和 DB 开发人员),如果可能的话,我会尝试在 Hbase shell 中获得解决方案。
我有一个 HBase 表(下面的架构),我试图在其中实现历史数据(可用于审计和分析)。
假设基本结构如下,
rowkey 'cf1:id', 'cf1:price', 'cf1:user', 'cf1:timestamp'
现在, rowkey - 仪器或任何对象 id - 使用它来识别哪个 col 具有最新数据。第一个条目的值为 1,然后继续 user - 更新数据的用户
例如
最初的数据看起来像,
hbase(main):009:0> scan 'price_history'
ROW COLUMN+CELL
row1 column=cf1:id, timestamp=1389020633920,value=1
row1 column=cf1:pr, timestamp=1389020654614, value=109.45
row1 column=cf1:us, timestamp=1389020668338, value=feed
row2 column=cf1:id, timestamp=1389020687334, value=1
row2 column=cf1:pr, timestamp=1389020697880, value=1345.65
row2 column=cf1:us, timestamp=1389020708403, value=feed
现在假设 row2 或工具 2 在同一天以新价格更新,
hbase(main):003:0> scan 'price_history'
ROW COLUMN+CELL
row1 column=cf1:id, timestamp=1389020633920, value=1
row1 column=cf1:pr, timestamp=1389020654614, value=109.45
row1 column=cf1:us, timestamp=1389020668338, value=feed
row2 column=cf1:id, timestamp=1389020859674, value=2
row2 column=cf1:pr, timestamp=1389020697880, value=1345.65
row2 column=cf1:pr1, timestamp=1389020869856, value=200
row2 column=cf1:us, timestamp=1389020708403, value=feed
row2 column=cf1:us1, timestamp=1389020881601, value=user1`
如果您看到 id 更改为 2 表示第二组数据是最新的。并添加了新值或列。
我想要的是,
1) Can I fetch the value of columns id? i.e. the output should be 1 or 2 and not all other attribs
2) Based on the above o/p i will fetch the further data, but can I also have a search and o/p as value of rowkey? i.e. something like give me o/p of row having VALUE as row1 (I can have list of row1, row2, rown..)
如果可能,请尽可能在 HBase shell 中提供帮助(也欢迎其他解决方案)
此外,如果任何架构师可以提出更好的解决方案来为表格建模以跟踪价格的变化/版本,我们也欢迎。
谢谢。
【问题讨论】: