HBase Filter 过滤器之RowFilter详解
前言:本文详细介绍了HBase RowFilter过滤器Java&Shell API的使用,并贴出了相关示例代码以供参考。RowFilter 基于行键进行过滤,在工作中涉及到需要通过HBase Rowkey进行数据过滤时可以考虑使用它。比较器细节及原理请参照之前的更文:HBase Filter 过滤器之比较器 Comparator 原理及源码学习
一。Java Api
头部代码
public class RowFilterDemo {
private static boolean isok = false;
private static String tableName = "test";
private static String[] cfs = new String[]{"f"};
private static String[] data = new String[]{"row-ac:f:c1:v1", "row-ab:f:c2:v2", "row-bc:f:c3:v3", "row-abc:f:c4:v4"};
public static void main(String[] args) throws IOException {
MyBase myBase = new MyBase();
Connection connection = myBase.createConnection();
if (isok) {
myBase.deleteTable(connection, tableName);
myBase.createTable(connection, tableName, cfs);
myBase.putRows(connection, tableName, data); // 造数据
}
Table table = connection.getTable(TableName.valueOf(tableName));
Scan scan = new Scan();
相关文章