HBase 中带扫描查询的 RowFilter
RowFilter with Scan Query in the HBase
我在 HBase 中有以下 table;
---row--- ---columns---
15678,ctx,plm,1561356310000 etc...
15678,ctx,plm,1561388710000 etc...
15678,ctx,plm,1561476430000 etc...
26355,yt,rcc,1561356310000 etc...
26355,yt,rcc,1561356310000 etc...
... ...
我的rowKey
格式是;
<id_of_device>,<id_of_component>,<id_of_item>,<timestamp>
并且,我收到了意外的查询请求。我必须在特定 开始时间和结束时间(行中的时间戳) 之间获取特定 设备(id_of_device) 的所有值。
例如;
我想在 startTime(1561356310000)
和 endTime(1561476430000)
之间获取设备 15678
的数据。我如何为此准备扫描查询?按照我的rowKey设计,我写"id_of_component" and "id_of_item"
。但我只想使用 "id_of_device" and "start and end timestamps"
.
获取数据
scan 'mytable', {STARTROW => '15678,..,..,1561356310000', ENDROW => '15678,..,..,1561476430000'}
根据你的行键设计;您可以在开始行和停止行旁边使用带有正则表达式的 RowFilter。
scan 'mytable', {STARTROW => '15678', ENDROW => '15679', FILTER => "RowFilter(=, 'regexstring:1561356310000$')"}
会在 1561356310000 的确切时间获取数据。如果您根据日期范围创建时间戳正则表达式,则可以查询时间范围。
scan 'mytable', {STARTROW => '15678', ENDROW => '15679', FILTER => "RowFilter(=, 'regexstring:15613563.....$')"}
将在时间戳 1561356300000 和 1561356399999 之间获取 100 秒的数据
scan 'mytable', {STARTROW => '15678', ENDROW => '15679', FILTER => "RowFilter(=, 'regexstring:1561356[3|4|5].....$')"}
将在时间戳 1561356300000 和 1561356599999 之间获取 300 秒的数据
使用正则表达式过滤器可能效率不高,但 id_of_component,id_of_item
行键中间的数据会阻止使用范围进行扫描的能力。
我在 HBase 中有以下 table;
---row--- ---columns---
15678,ctx,plm,1561356310000 etc...
15678,ctx,plm,1561388710000 etc...
15678,ctx,plm,1561476430000 etc...
26355,yt,rcc,1561356310000 etc...
26355,yt,rcc,1561356310000 etc...
... ...
我的rowKey
格式是;
<id_of_device>,<id_of_component>,<id_of_item>,<timestamp>
并且,我收到了意外的查询请求。我必须在特定 开始时间和结束时间(行中的时间戳) 之间获取特定 设备(id_of_device) 的所有值。
例如;
我想在 startTime(1561356310000)
和 endTime(1561476430000)
之间获取设备 15678
的数据。我如何为此准备扫描查询?按照我的rowKey设计,我写"id_of_component" and "id_of_item"
。但我只想使用 "id_of_device" and "start and end timestamps"
.
scan 'mytable', {STARTROW => '15678,..,..,1561356310000', ENDROW => '15678,..,..,1561476430000'}
根据你的行键设计;您可以在开始行和停止行旁边使用带有正则表达式的 RowFilter。
scan 'mytable', {STARTROW => '15678', ENDROW => '15679', FILTER => "RowFilter(=, 'regexstring:1561356310000$')"}
会在 1561356310000 的确切时间获取数据。如果您根据日期范围创建时间戳正则表达式,则可以查询时间范围。
scan 'mytable', {STARTROW => '15678', ENDROW => '15679', FILTER => "RowFilter(=, 'regexstring:15613563.....$')"}
将在时间戳 1561356300000 和 1561356399999 之间获取 100 秒的数据
scan 'mytable', {STARTROW => '15678', ENDROW => '15679', FILTER => "RowFilter(=, 'regexstring:1561356[3|4|5].....$')"}
将在时间戳 1561356300000 和 1561356599999 之间获取 300 秒的数据
使用正则表达式过滤器可能效率不高,但 id_of_component,id_of_item
行键中间的数据会阻止使用范围进行扫描的能力。