我需要帮助搜索HBase内容。我有一个HBase表'tblsearch'。
如何查看表模式(例如我们在MySQL中显示create table tbl_name)? 如何查看表'tblsearch'的所有内容,其中ali值= 24146,其中date ='2014-02-08'
hbase(main):026:0> describe 'tblsearch'
DESCRIPTION ENABLED
{NAME => 'tblsearch', FAMILIES => [{NAME => 'd', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'NON true
E', REPLICATION_SCOPE => '0', VERSIONS => '3', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => '-
1', KEEP_DELETED_CELLS => 'false', BLOCKSIZE => '65536', IN_MEMORY => 'false', ENCODE_ON_DISK => 'tr
ue', BLOCKCACHE => 'false'}]}
1 row(s) in 0.1040 seconds
Scanning 5 rows from the table:
hbase(main):023:0> scan 'tblsearch', {'LIMIT'=>5}
ROW COLUMN+CELL
a24146_1371760717_J=K\xF6 column=d:ali, timestamp=1379351295242, value=24146
a24146_1371760717_J=K\xF6 column=d:level, timestamp=1379351295242, value=yellow
a24146_1371760717_J=K\xF6 column=d:message_template, timestamp=1379351295242, value=ALI {ali} has no user priority value
a24146_1371760717_\xE1\xF7\x01\x0F column=d:ali, timestamp=1379351295243, value=24146
a24146_1371760717_\xE1\xF7\x01\x0F column=d:level, timestamp=1379351295243, value=yellow
a24146_1371760717_\xE1\xF7\x01\x0F column=d:message_template, timestamp=1379351295243, value=ALI {ali} has no user weight vector
a24146_1371760724_\x08\x18\xC20 column=d:ali, timestamp=1379351295243, value=24146
a24146_1371760724_\x08\x18\xC20 column=d:level, timestamp=1379351295243, value=green
a24146_1371760724_\x08\x18\xC20 column=d:message_template, timestamp=1379351295243, value=ALI {ali} has been successfully allocated
a24146_1371817802_X\xD4`\x8A column=d:ali, timestamp=1379351295361, value=24146
a24146_1371817802_X\xD4`\x8A column=d:level, timestamp=1379351295361, value=yellow
a24146_1371817802_X\xD4`\x8A column=d:message_template, timestamp=1379351295361, value=ALI {ali} has no user priority value
a24146_1371817802_\xD97\xBBe column=d:ali, timestamp=1379351295362, value=24146
a24146_1371817802_\xD97\xBBe column=d:level, timestamp=1379351295362, value=yellow
a24146_1371817802_\xD97\xBBe column=d:message_template, timestamp=1379351295362, value=ALI {ali} has no user weight vector
答案 0 :(得分:0)
我在这里看不到任何列日期。但是你可以在HBase过滤器的帮助下实现这一目标。 例如,如果您想要获取 ali = 24146 的所有行,您可以这样做:
HBase的(主):001:0> import org.apache.hadoop.hbase.util.Bytes
HBase的(主):002:0> import org.apache.hadoop.hbase.filter.SingleColumnValueFilter
HBase的(主):003:0> import org.apache.hadoop.hbase.filter.BinaryComparator
HBase的(主):004:0> import org.apache.hadoop.hbase.filter.CompareFilter
HBase的(主):005:0> scan'tblsearch',{FILTER => SingleColumnValueFilter.new(Bytes.toBytes('d'),Bytes.toBytes('ali'), CompareFilter :: CompareOp.valueOf( '平等'), BinaryComparator.new(Bytes.toBytes( '24146')))}
HTH
答案 1 :(得分:0)
你可以看到表'tblsearch'的所有内容,其中ali值= 24146,其中date ='2014-02-08'基于'tblsearch'表的rowkey,在将记录放入表中时定义或使用。
答案 2 :(得分:0)
您可以在HBase Shell中使用以下命令。不需要导入,并且在0.94.6
中适用于我scan 'tblsearch',FILTER=>"SingleColumnValueFilter('d','ali',=,'binary:24146') AND TimestampsFilter(1391167399643)"