我在搜索HBase内容时需要帮助。我有一个HBase表'tblsearch'。
如何查看表架构(例如,我们确实在MySQL中显示了创建表tbl_name的内容)?
我如何查看表'tblsearch'的所有内容,其中ali值= 24146其中日期='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
最佳答案
我在此处看不到任何列和日期。但是您可以借助HBase过滤器来实现。 例如,如果要获取 ali = 24146 的所有行,则可以使用:
hbase(main):001:0> import org.apache.hadoop.hbase.util.Bytes
hbase(main):002:0> import org.apache.hadoop.hbase.filter.SingleColumnValueFilter
hbase(main):003:0> import org.apache.hadoop.hbase.filter.BinaryComparator
hbase(main):004:0> import org.apache.hadoop.hbase.filter.CompareFilter
hbase(main):005:0> scan 'tblsearch', { FILTER => SingleColumnValueFilter.new(Bytes.toBytes('d'), Bytes.toBytes('ali'), CompareFilter::CompareOp.valueOf('EQUAL'), BinaryComparator.new(Bytes.toBytes('24146')))}
高温超导
关于hadoop - 搜索HBase表的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21661226/