首页 > 解决方案 > 将给定时间范围作为行键的 Hbase shell 命令

问题描述

我在 hbase 表中有以下数据结构,

fb60b40ce747_1552305177484   column=detail:ble_mac, timestamp=1552305177487, value=FB60B40CE747
fb60b40ce747_1552305177484   column=timeline:date_created, timestamp=1552305177487, value=1552305177484                                                              
fb60b40ce747_1552305177484   column=timeline:last_updated, timestamp=1552305177487, value=1552305177484
fb60b40ce747_1552305183307   column=detail:ble_mac, timestamp=1552305183310, value=FB60B40CE747
fb60b40ce747_1552305183307   column=timeline:date_created, timestamp=1552305183310, value=1552305183307                                                              
fb60b40ce747_1552305183307   column=timeline:last_updated, timestamp=1552305183310, value=1552305183307 
fb60b40ce747_1552305194792   column=detail:ble_mac, timestamp=1552305194795, value=FB60B40CE747
fb60b40ce747_1552305194792   column=timeline:date_created, timestamp=1552305194795, value=1552305194792                                                              
fb60b40ce747_1552305194792   column=timeline:last_updated, timestamp=1552305194795, value=1552305194792

我试图通过指定时间范围来提取详细信息(即,MAC Address_TimeStamp,这是这里的关键行)。我使用了以下 hbase shell 命令,

scan 'mindlogic:ble_log',{STARTROW => 'fb60b40ce747_1552305120484', ENDROW => 'fb60b40ce747_1552305204792',LIMIT=>1}

这个命令的问题是,我无法提取最近的记录。这里最近的记录是“fb60b40ce747_1552305194792”

我尝试过另一个命令,即

scan 'mindlogic:ble_log',{LIMIT => 1,FILTER => "SingleColumnValueFilter('detail','ble_mac',=, 'binary:FB60B40CE747') AND SingleColumnValueFilter('timeline','last_updated',>=, 'binary:1552305120484') AND SingleColumnValueFilter('timeline','last_updated',<=, 'binary:1552305204792')"}

现在我的问题是,如何得到如下结果,

Expected Output :-
fb60b40ce747_1552305194792   column=detail:ble_mac, timestamp=1552305194795, value=FB60B40CE747
fb60b40ce747_1552305194792   column=timeline:date_created, timestamp=1552305194795, value=1552305194792                                                              
fb60b40ce747_1552305194792   column=timeline:last_updated, timestamp=1552305194795, value=1552305194792

标签: hbase

解决方案


推荐阅读