如何根据条件从 Hbase table 检索记录?

How to retrieve the records based on a condition from a Hbase table?

我有一个 Hbase table:employeedetails 列 families:cols-personaldetails:firstname,lastname,professionaldetails:cols-company,empid 其中包含以下数据。

 1    column=personaldetails:firstname, timestamp=1490959927100, value=Steven
 1    column=personaldetails:lastname, timestamp=1490959947478, value=Gerrard
 1    column=professionaldetails:company, timestamp=1490959968846, value=ABC
 1    column=professionaldetails:empid, timestamp=1490959978542, value=02429O
 2    column=personaldetails:firstname, timestamp=1490960007427, value=Sidhartha
 2    column=personaldetails:lastname, timestamp=1490960054615, value=Bobby
 2    column=professionaldetails:company, timestamp=1490960074243, value=DEF
 2    column=professionaldetails:empid, timestamp=1490960103882, value=02429N
 3    column=personaldetails:company, timestamp=1490960175772, value=WES
 3    column=personaldetails:empid, timestamp=1490960187863, value=987789
 3    column=personaldetails:firstname, timestamp=1490960128896, value=Sunny
 3    column=personaldetails:lastname, timestamp=1490960142031, value=Smith

有没有办法写一个命令来检索名字以'S'开头的记录。

您可以做的最好的事情是,您可以在 Hive 中创建一个外部 table,具有相同的模式映射到 HBase table,并且您可以 运行 在 Hive 上进行 Hive 查询HBase 的顶部 table.

您可以在 运行HBase table 数据顶部的 Hive 查询中使用条件。

您可以refer to this blog 将 Hive 与 HBase 集成,并 运行在 HBase 的顶部进行 Hive 查询 table。

使用SingleColumnValueFilter

This filter takes a column family, a qualifier, a compare operator and a comparator as arguments.

  1. If the specified column is not found, all the columns of that row will be emitted.
  2. If the column is found and the comparison with the comparator returns true, all the columns of the row will be emitted.
  3. If the column is found and the comparison with the comparator returns false, the row will not be emitted.

语法:

SingleColumnValueFilter (‘<family>’, ‘<qualifier>’, <compare operator>, ‘<comparator>’, <filterIfColumnMissing_boolean>, <latest_version_boolean>)

尝试:

scan 'employeedetails' ,{ FILTER => "SingleColumnValueFilter('personaldetails','firstname',=, 'binaryprefix:S', true, false)" }

如果 filterIfColumnMissing 标志设置为 true,如果在行中找不到要检查的指定列,则不会发出该行的列。

如果这检索到预期结果,请告诉我。