使用给定时间范围作为行键的Hbase Shell命令

时间:2019-03-12 04:12:46

标签: hbase

我在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

1 个答案:

答案 0 :(得分:0)

在HBase Shell中无法使用排序选项。如果要获取最近的记录,则可以在行键中使用反向时间戳(Long.MAX_VALUE-timestamp)。