RowFilter用于过滤row key
Operator Description
LESS 小于
LESS_OR_EQUAL 小于等于
[EQUAL 等于
NOT_EQUAL 不等于
GREATER_OR_EQUAL 大于等于
GREATER 大于
NO_OP 排除所有
Comparator Description
BinaryComparator 使用Bytes.compareTo()比较
BinaryPrefixComparator 和BinaryComparator差不多,从前面开始比较
NullComparator Does not compare against an actual value but whether a given one is null, or not  null.
BitComparator Performs a bitwise comparison, providing a BitwiseOp class with OR, and XORoperators.
RegexStringComparator 正则表达式
SubstringComparator 把数据当成字符串,用contains()来判断
  1. import java.io.IOException;
  2. import org.apache.hadoop.conf.Configuration;
  3. import org.apache.hadoop.hbase.HBaseConfiguration;
  4. import org.apache.hadoop.hbase.HColumnDescriptor;
  5. import org.apache.hadoop.hbase.HTableDescriptor;
  6. import org.apache.hadoop.hbase.client.HBaseAdmin;
  7. import org.apache.hadoop.hbase.client.HTable;
  8. import org.apache.hadoop.hbase.client.Put;
  9. import org.apache.hadoop.hbase.client.Result;
  10. import org.apache.hadoop.hbase.client.ResultScanner;
  11. import org.apache.hadoop.hbase.client.Scan;
  12. import org.apache.hadoop.hbase.filter.BinaryComparator;
  13. import org.apache.hadoop.hbase.filter.BinaryPrefixComparator;
  14. import org.apache.hadoop.hbase.filter.CompareFilter;
  15. import org.apache.hadoop.hbase.filter.Filter;
  16. import org.apache.hadoop.hbase.filter.RegexStringComparator;
  17. import org.apache.hadoop.hbase.filter.RowFilter;
  18. import org.apache.hadoop.hbase.filter.SubstringComparator;
  19. public class TestHbaseRowFilter {
  20. String tableName = "test_row_filter";
  21. Configuration config = HBaseConfiguration.create();
  22. /**
  23. * 部分代码来自hbase权威指南
  24. * @throws IOException
  25. */
  26. public void testRowFilter() throws IOException {
  27. HTable table = new HTable(config, tableName);
  28. Scan scan = new Scan();
  29. System.out.println("小于等于row010的行");
  30. Filter filter1 = new RowFilter(CompareFilter.CompareOp.LESS_OR_EQUAL,
  31. new BinaryComparator("row010".getBytes()));
  32. scan.setFilter(filter1);
  33. ResultScanner scanner1 = table.getScanner(scan);
  34. for (Result res : scanner1) {
  35. System.out.println(res);
  36. }
  37. scanner1.close();
  38. System.out.println("正则获取结尾为5的行");
  39. Filter filter2 = new RowFilter(CompareFilter.CompareOp.EQUAL,
  40. new RegexStringComparator(".*5[        DISCUZ_CODE_0        ]quot;));
  41. scan.setFilter(filter2);
  42. ResultScanner scanner2 = table.getScanner(scan);
  43. for (Result res : scanner2) {
  44. System.out.println(res);
  45. }
  46. scanner2.close();
  47. System.out.println("包含有5的行");
  48. Filter filter3 = new RowFilter(CompareFilter.CompareOp.EQUAL,
  49. new SubstringComparator("5"));
  50. scan.setFilter(filter3);
  51. ResultScanner scanner3 = table.getScanner(scan);
  52. for (Result res : scanner3) {
  53. System.out.println(res);
  54. }
  55. scanner3.close();
  56. System.out.println("开头是row01的");
  57. Filter filter4 = new RowFilter(CompareFilter.CompareOp.EQUAL,
  58. new BinaryPrefixComparator("row01".getBytes()));
  59. scan.setFilter(filter4);
  60. ResultScanner scanner4 = table.getScanner(scan);
  61. for (Result res : scanner4) {
  62. System.out.println(res);
  63. }
  64. scanner3.close();
  65. }
  66. /**
  67. * 初始化数据
  68. */
  69. public void init() {
  70. // 创建表和初始化数据
  71. try {
  72. HBaseAdmin admin = new HBaseAdmin(config);
  73. if (!admin.tableExists(tableName)) {
  74. HTableDescriptor htd = new HTableDescriptor(tableName);
  75. HColumnDescriptor hcd1 = new HColumnDescriptor("data");
  76. htd.addFamily(hcd1);
  77. HColumnDescriptor hcd2 = new HColumnDescriptor("url");
  78. htd.addFamily(hcd2);
  79. admin.createTable(htd);
  80. }
  81. HTable table = new HTable(config, tableName);
  82. table.setAutoFlush(false);
  83. int count = 50;
  84. for (int i = 1; i <= count; ++i) {
  85. Put p = new Put(String.format("row%03d", i).getBytes());
  86. p.add("data".getBytes(), String.format("col%01d", i % 10)
  87. .getBytes(), String.format("data%03d", i).getBytes());
  88. p.add("url".getBytes(), String.format("col%01d", i % 10)
  89. .getBytes(), String.format("url%03d", i).getBytes());
  90. table.put(p);
  91. }
  92. table.close();
  93. } catch (IOException e) {
  94. e.printStackTrace();
  95. }
  96. }
  97. /**
  98. * @param args
  99. * @throws IOException
  100. */
  101. public static void main(String[] args) throws IOException {
  102. TestHbaseRowFilter test = new TestHbaseRowFilter();
  103. test.init();
  104. test.testRowFilter();
  105. }
  106. }

复制代码

输出结果
  1. 小于等于row010的行
  2. keyvalues={row001/data:col1/1364133382268/Put/vlen=7, row001/url:col1/1364133382268/Put/vlen=6}
  3. keyvalues={row002/data:col2/1364133382268/Put/vlen=7, row002/url:col2/1364133382268/Put/vlen=6}
  4. keyvalues={row003/data:col3/1364133382268/Put/vlen=7, row003/url:col3/1364133382268/Put/vlen=6}
  5. keyvalues={row004/data:col4/1364133382268/Put/vlen=7, row004/url:col4/1364133382268/Put/vlen=6}
  6. keyvalues={row005/data:col5/1364133382268/Put/vlen=7, row005/url:col5/1364133382268/Put/vlen=6}
  7. keyvalues={row006/data:col6/1364133382268/Put/vlen=7, row006/url:col6/1364133382268/Put/vlen=6}
  8. keyvalues={row007/data:col7/1364133382268/Put/vlen=7, row007/url:col7/1364133382268/Put/vlen=6}
  9. keyvalues={row008/data:col8/1364133382268/Put/vlen=7, row008/url:col8/1364133382268/Put/vlen=6}
  10. keyvalues={row009/data:col9/1364133382268/Put/vlen=7, row009/url:col9/1364133382268/Put/vlen=6}
  11. keyvalues={row010/data:col0/1364133382268/Put/vlen=7, row010/url:col0/1364133382268/Put/vlen=6}
  12. 正则获取结尾为5的行
  13. keyvalues={row005/data:col5/1364133382268/Put/vlen=7, row005/url:col5/1364133382268/Put/vlen=6}
  14. keyvalues={row015/data:col5/1364133382268/Put/vlen=7, row015/url:col5/1364133382268/Put/vlen=6}
  15. keyvalues={row025/data:col5/1364133382268/Put/vlen=7, row025/url:col5/1364133382268/Put/vlen=6}
  16. keyvalues={row035/data:col5/1364133382268/Put/vlen=7, row035/url:col5/1364133382268/Put/vlen=6}
  17. keyvalues={row045/data:col5/1364133382268/Put/vlen=7, row045/url:col5/1364133382268/Put/vlen=6}
  18. 包行有5的行
  19. keyvalues={row005/data:col5/1364133382268/Put/vlen=7, row005/url:col5/1364133382268/Put/vlen=6}
  20. keyvalues={row015/data:col5/1364133382268/Put/vlen=7, row015/url:col5/1364133382268/Put/vlen=6}
  21. keyvalues={row025/data:col5/1364133382268/Put/vlen=7, row025/url:col5/1364133382268/Put/vlen=6}
  22. keyvalues={row035/data:col5/1364133382268/Put/vlen=7, row035/url:col5/1364133382268/Put/vlen=6}
  23. keyvalues={row045/data:col5/1364133382268/Put/vlen=7, row045/url:col5/1364133382268/Put/vlen=6}
  24. keyvalues={row050/data:col0/1364133382268/Put/vlen=7, row050/url:col0/1364133382268/Put/vlen=6}
  25. 开头是row01的
  26. keyvalues={row010/data:col0/1364133382268/Put/vlen=7, row010/url:col0/1364133382268/Put/vlen=6}
  27. keyvalues={row011/data:col1/1364133382268/Put/vlen=7, row011/url:col1/1364133382268/Put/vlen=6}
  28. keyvalues={row012/data:col2/1364133382268/Put/vlen=7, row012/url:col2/1364133382268/Put/vlen=6}
  29. keyvalues={row013/data:col3/1364133382268/Put/vlen=7, row013/url:col3/1364133382268/Put/vlen=6}
  30. keyvalues={row014/data:col4/1364133382268/Put/vlen=7, row014/url:col4/1364133382268/Put/vlen=6}
  31. keyvalues={row015/data:col5/1364133382268/Put/vlen=7, row015/url:col5/1364133382268/Put/vlen=6}
  32. keyvalues={row016/data:col6/1364133382268/Put/vlen=7, row016/url:col6/1364133382268/Put/vlen=6}
  33. keyvalues={row017/data:col7/1364133382268/Put/vlen=7, row017/url:col7/1364133382268/Put/vlen=6}
  34. keyvalues={row018/data:col8/1364133382268/Put/vlen=7, row018/url:col8/1364133382268/Put/vlen=6}
  35. keyvalues={row019/data:col9/1364133382268/Put/vlen=7, row019/url:col9/1364133382268/Put/vlen=6}

复制代码

 
 
 
RowFilter用于过滤row key
Operator Description
LESS 小于
LESS_OR_EQUAL 小于等于
[EQUAL 等于
NOT_EQUAL 不等于
GREATER_OR_EQUAL 大于等于
GREATER 大于
NO_OP 排除所有
Comparator Description
BinaryComparator 使用Bytes.compareTo()比较
BinaryPrefixComparator 和BinaryComparator差不多,从前面开始比较
NullComparator Does not compare against an actual value but whether a given one is null, or not  null.
BitComparator Performs a bitwise comparison, providing a BitwiseOp class with OR, and XORoperators.
RegexStringComparator 正则表达式
SubstringComparator 把数据当成字符串,用contains()来判断
  1. import java.io.IOException;
  2. import org.apache.hadoop.conf.Configuration;
  3. import org.apache.hadoop.hbase.HBaseConfiguration;
  4. import org.apache.hadoop.hbase.HColumnDescriptor;
  5. import org.apache.hadoop.hbase.HTableDescriptor;
  6. import org.apache.hadoop.hbase.client.HBaseAdmin;
  7. import org.apache.hadoop.hbase.client.HTable;
  8. import org.apache.hadoop.hbase.client.Put;
  9. import org.apache.hadoop.hbase.client.Result;
  10. import org.apache.hadoop.hbase.client.ResultScanner;
  11. import org.apache.hadoop.hbase.client.Scan;
  12. import org.apache.hadoop.hbase.filter.BinaryComparator;
  13. import org.apache.hadoop.hbase.filter.BinaryPrefixComparator;
  14. import org.apache.hadoop.hbase.filter.CompareFilter;
  15. import org.apache.hadoop.hbase.filter.Filter;
  16. import org.apache.hadoop.hbase.filter.RegexStringComparator;
  17. import org.apache.hadoop.hbase.filter.RowFilter;
  18. import org.apache.hadoop.hbase.filter.SubstringComparator;
  19. public class TestHbaseRowFilter {
  20. String tableName = "test_row_filter";
  21. Configuration config = HBaseConfiguration.create();
  22. /**
  23. * 部分代码来自hbase权威指南
  24. * @throws IOException
  25. */
  26. public void testRowFilter() throws IOException {
  27. HTable table = new HTable(config, tableName);
  28. Scan scan = new Scan();
  29. System.out.println("小于等于row010的行");
  30. Filter filter1 = new RowFilter(CompareFilter.CompareOp.LESS_OR_EQUAL,
  31. new BinaryComparator("row010".getBytes()));
  32. scan.setFilter(filter1);
  33. ResultScanner scanner1 = table.getScanner(scan);
  34. for (Result res : scanner1) {
  35. System.out.println(res);
  36. }
  37. scanner1.close();
  38. System.out.println("正则获取结尾为5的行");
  39. Filter filter2 = new RowFilter(CompareFilter.CompareOp.EQUAL,
  40. new RegexStringComparator(".*5[        DISCUZ_CODE_0        ]quot;));
  41. scan.setFilter(filter2);
  42. ResultScanner scanner2 = table.getScanner(scan);
  43. for (Result res : scanner2) {
  44. System.out.println(res);
  45. }
  46. scanner2.close();
  47. System.out.println("包含有5的行");
  48. Filter filter3 = new RowFilter(CompareFilter.CompareOp.EQUAL,
  49. new SubstringComparator("5"));
  50. scan.setFilter(filter3);
  51. ResultScanner scanner3 = table.getScanner(scan);
  52. for (Result res : scanner3) {
  53. System.out.println(res);
  54. }
  55. scanner3.close();
  56. System.out.println("开头是row01的");
  57. Filter filter4 = new RowFilter(CompareFilter.CompareOp.EQUAL,
  58. new BinaryPrefixComparator("row01".getBytes()));
  59. scan.setFilter(filter4);
  60. ResultScanner scanner4 = table.getScanner(scan);
  61. for (Result res : scanner4) {
  62. System.out.println(res);
  63. }
  64. scanner3.close();
  65. }
  66. /**
  67. * 初始化数据
  68. */
  69. public void init() {
  70. // 创建表和初始化数据
  71. try {
  72. HBaseAdmin admin = new HBaseAdmin(config);
  73. if (!admin.tableExists(tableName)) {
  74. HTableDescriptor htd = new HTableDescriptor(tableName);
  75. HColumnDescriptor hcd1 = new HColumnDescriptor("data");
  76. htd.addFamily(hcd1);
  77. HColumnDescriptor hcd2 = new HColumnDescriptor("url");
  78. htd.addFamily(hcd2);
  79. admin.createTable(htd);
  80. }
  81. HTable table = new HTable(config, tableName);
  82. table.setAutoFlush(false);
  83. int count = 50;
  84. for (int i = 1; i <= count; ++i) {
  85. Put p = new Put(String.format("row%03d", i).getBytes());
  86. p.add("data".getBytes(), String.format("col%01d", i % 10)
  87. .getBytes(), String.format("data%03d", i).getBytes());
  88. p.add("url".getBytes(), String.format("col%01d", i % 10)
  89. .getBytes(), String.format("url%03d", i).getBytes());
  90. table.put(p);
  91. }
  92. table.close();
  93. } catch (IOException e) {
  94. e.printStackTrace();
  95. }
  96. }
  97. /**
  98. * @param args
  99. * @throws IOException
  100. */
  101. public static void main(String[] args) throws IOException {
  102. TestHbaseRowFilter test = new TestHbaseRowFilter();
  103. test.init();
  104. test.testRowFilter();
  105. }
  106. }

复制代码

输出结果
  1. 小于等于row010的行
  2. keyvalues={row001/data:col1/1364133382268/Put/vlen=7, row001/url:col1/1364133382268/Put/vlen=6}
  3. keyvalues={row002/data:col2/1364133382268/Put/vlen=7, row002/url:col2/1364133382268/Put/vlen=6}
  4. keyvalues={row003/data:col3/1364133382268/Put/vlen=7, row003/url:col3/1364133382268/Put/vlen=6}
  5. keyvalues={row004/data:col4/1364133382268/Put/vlen=7, row004/url:col4/1364133382268/Put/vlen=6}
  6. keyvalues={row005/data:col5/1364133382268/Put/vlen=7, row005/url:col5/1364133382268/Put/vlen=6}
  7. keyvalues={row006/data:col6/1364133382268/Put/vlen=7, row006/url:col6/1364133382268/Put/vlen=6}
  8. keyvalues={row007/data:col7/1364133382268/Put/vlen=7, row007/url:col7/1364133382268/Put/vlen=6}
  9. keyvalues={row008/data:col8/1364133382268/Put/vlen=7, row008/url:col8/1364133382268/Put/vlen=6}
  10. keyvalues={row009/data:col9/1364133382268/Put/vlen=7, row009/url:col9/1364133382268/Put/vlen=6}
  11. keyvalues={row010/data:col0/1364133382268/Put/vlen=7, row010/url:col0/1364133382268/Put/vlen=6}
  12. 正则获取结尾为5的行
  13. keyvalues={row005/data:col5/1364133382268/Put/vlen=7, row005/url:col5/1364133382268/Put/vlen=6}
  14. keyvalues={row015/data:col5/1364133382268/Put/vlen=7, row015/url:col5/1364133382268/Put/vlen=6}
  15. keyvalues={row025/data:col5/1364133382268/Put/vlen=7, row025/url:col5/1364133382268/Put/vlen=6}
  16. keyvalues={row035/data:col5/1364133382268/Put/vlen=7, row035/url:col5/1364133382268/Put/vlen=6}
  17. keyvalues={row045/data:col5/1364133382268/Put/vlen=7, row045/url:col5/1364133382268/Put/vlen=6}
  18. 包行有5的行
  19. keyvalues={row005/data:col5/1364133382268/Put/vlen=7, row005/url:col5/1364133382268/Put/vlen=6}
  20. keyvalues={row015/data:col5/1364133382268/Put/vlen=7, row015/url:col5/1364133382268/Put/vlen=6}
  21. keyvalues={row025/data:col5/1364133382268/Put/vlen=7, row025/url:col5/1364133382268/Put/vlen=6}
  22. keyvalues={row035/data:col5/1364133382268/Put/vlen=7, row035/url:col5/1364133382268/Put/vlen=6}
  23. keyvalues={row045/data:col5/1364133382268/Put/vlen=7, row045/url:col5/1364133382268/Put/vlen=6}
  24. keyvalues={row050/data:col0/1364133382268/Put/vlen=7, row050/url:col0/1364133382268/Put/vlen=6}
  25. 开头是row01的
  26. keyvalues={row010/data:col0/1364133382268/Put/vlen=7, row010/url:col0/1364133382268/Put/vlen=6}
  27. keyvalues={row011/data:col1/1364133382268/Put/vlen=7, row011/url:col1/1364133382268/Put/vlen=6}
  28. keyvalues={row012/data:col2/1364133382268/Put/vlen=7, row012/url:col2/1364133382268/Put/vlen=6}
  29. keyvalues={row013/data:col3/1364133382268/Put/vlen=7, row013/url:col3/1364133382268/Put/vlen=6}
  30. keyvalues={row014/data:col4/1364133382268/Put/vlen=7, row014/url:col4/1364133382268/Put/vlen=6}
  31. keyvalues={row015/data:col5/1364133382268/Put/vlen=7, row015/url:col5/1364133382268/Put/vlen=6}
  32. keyvalues={row016/data:col6/1364133382268/Put/vlen=7, row016/url:col6/1364133382268/Put/vlen=6}
  33. keyvalues={row017/data:col7/1364133382268/Put/vlen=7, row017/url:col7/1364133382268/Put/vlen=6}
  34. keyvalues={row018/data:col8/1364133382268/Put/vlen=7, row018/url:col8/1364133382268/Put/vlen=6}
  35. keyvalues={row019/data:col9/1364133382268/Put/vlen=7, row019/url:col9/1364133382268/Put/vlen=6}

复制代码

RowFilter用于过滤row key
Operator Description
LESS 小于
LESS_OR_EQUAL 小于等于
[EQUAL 等于
NOT_EQUAL 不等于
GREATER_OR_EQUAL 大于等于
GREATER 大于
NO_OP 排除所有
Comparator Description
BinaryComparator 使用Bytes.compareTo()比较
BinaryPrefixComparator 和BinaryComparator差不多,从前面开始比较
NullComparator Does not compare against an actual value but whether a given one is null, or not  null.
BitComparator Performs a bitwise comparison, providing a BitwiseOp class with OR, and XORoperators.
RegexStringComparator 正则表达式
SubstringComparator 把数据当成字符串,用contains()来判断
  1. import java.io.IOException;
  2. import org.apache.hadoop.conf.Configuration;
  3. import org.apache.hadoop.hbase.HBaseConfiguration;
  4. import org.apache.hadoop.hbase.HColumnDescriptor;
  5. import org.apache.hadoop.hbase.HTableDescriptor;
  6. import org.apache.hadoop.hbase.client.HBaseAdmin;
  7. import org.apache.hadoop.hbase.client.HTable;
  8. import org.apache.hadoop.hbase.client.Put;
  9. import org.apache.hadoop.hbase.client.Result;
  10. import org.apache.hadoop.hbase.client.ResultScanner;
  11. import org.apache.hadoop.hbase.client.Scan;
  12. import org.apache.hadoop.hbase.filter.BinaryComparator;
  13. import org.apache.hadoop.hbase.filter.BinaryPrefixComparator;
  14. import org.apache.hadoop.hbase.filter.CompareFilter;
  15. import org.apache.hadoop.hbase.filter.Filter;
  16. import org.apache.hadoop.hbase.filter.RegexStringComparator;
  17. import org.apache.hadoop.hbase.filter.RowFilter;
  18. import org.apache.hadoop.hbase.filter.SubstringComparator;
  19. public class TestHbaseRowFilter {
  20. String tableName = "test_row_filter";
  21. Configuration config = HBaseConfiguration.create();
  22. /**
  23. * 部分代码来自hbase权威指南
  24. * @throws IOException
  25. */
  26. public void testRowFilter() throws IOException {
  27. HTable table = new HTable(config, tableName);
  28. Scan scan = new Scan();
  29. System.out.println("小于等于row010的行");
  30. Filter filter1 = new RowFilter(CompareFilter.CompareOp.LESS_OR_EQUAL,
  31. new BinaryComparator("row010".getBytes()));
  32. scan.setFilter(filter1);
  33. ResultScanner scanner1 = table.getScanner(scan);
  34. for (Result res : scanner1) {
  35. System.out.println(res);
  36. }
  37. scanner1.close();
  38. System.out.println("正则获取结尾为5的行");
  39. Filter filter2 = new RowFilter(CompareFilter.CompareOp.EQUAL,
  40. new RegexStringComparator(".*5[        DISCUZ_CODE_0        ]quot;));
  41. scan.setFilter(filter2);
  42. ResultScanner scanner2 = table.getScanner(scan);
  43. for (Result res : scanner2) {
  44. System.out.println(res);
  45. }
  46. scanner2.close();
  47. System.out.println("包含有5的行");
  48. Filter filter3 = new RowFilter(CompareFilter.CompareOp.EQUAL,
  49. new SubstringComparator("5"));
  50. scan.setFilter(filter3);
  51. ResultScanner scanner3 = table.getScanner(scan);
  52. for (Result res : scanner3) {
  53. System.out.println(res);
  54. }
  55. scanner3.close();
  56. System.out.println("开头是row01的");
  57. Filter filter4 = new RowFilter(CompareFilter.CompareOp.EQUAL,
  58. new BinaryPrefixComparator("row01".getBytes()));
  59. scan.setFilter(filter4);
  60. ResultScanner scanner4 = table.getScanner(scan);
  61. for (Result res : scanner4) {
  62. System.out.println(res);
  63. }
  64. scanner3.close();
  65. }
  66. /**
  67. * 初始化数据
  68. */
  69. public void init() {
  70. // 创建表和初始化数据
  71. try {
  72. HBaseAdmin admin = new HBaseAdmin(config);
  73. if (!admin.tableExists(tableName)) {
  74. HTableDescriptor htd = new HTableDescriptor(tableName);
  75. HColumnDescriptor hcd1 = new HColumnDescriptor("data");
  76. htd.addFamily(hcd1);
  77. HColumnDescriptor hcd2 = new HColumnDescriptor("url");
  78. htd.addFamily(hcd2);
  79. admin.createTable(htd);
  80. }
  81. HTable table = new HTable(config, tableName);
  82. table.setAutoFlush(false);
  83. int count = 50;
  84. for (int i = 1; i <= count; ++i) {
  85. Put p = new Put(String.format("row%03d", i).getBytes());
  86. p.add("data".getBytes(), String.format("col%01d", i % 10)
  87. .getBytes(), String.format("data%03d", i).getBytes());
  88. p.add("url".getBytes(), String.format("col%01d", i % 10)
  89. .getBytes(), String.format("url%03d", i).getBytes());
  90. table.put(p);
  91. }
  92. table.close();
  93. } catch (IOException e) {
  94. e.printStackTrace();
  95. }
  96. }
  97. /**
  98. * @param args
  99. * @throws IOException
  100. */
  101. public static void main(String[] args) throws IOException {
  102. TestHbaseRowFilter test = new TestHbaseRowFilter();
  103. test.init();
  104. test.testRowFilter();
  105. }
  106. }

复制代码

输出结果
  1. 小于等于row010的行
  2. keyvalues={row001/data:col1/1364133382268/Put/vlen=7, row001/url:col1/1364133382268/Put/vlen=6}
  3. keyvalues={row002/data:col2/1364133382268/Put/vlen=7, row002/url:col2/1364133382268/Put/vlen=6}
  4. keyvalues={row003/data:col3/1364133382268/Put/vlen=7, row003/url:col3/1364133382268/Put/vlen=6}
  5. keyvalues={row004/data:col4/1364133382268/Put/vlen=7, row004/url:col4/1364133382268/Put/vlen=6}
  6. keyvalues={row005/data:col5/1364133382268/Put/vlen=7, row005/url:col5/1364133382268/Put/vlen=6}
  7. keyvalues={row006/data:col6/1364133382268/Put/vlen=7, row006/url:col6/1364133382268/Put/vlen=6}
  8. keyvalues={row007/data:col7/1364133382268/Put/vlen=7, row007/url:col7/1364133382268/Put/vlen=6}
  9. keyvalues={row008/data:col8/1364133382268/Put/vlen=7, row008/url:col8/1364133382268/Put/vlen=6}
  10. keyvalues={row009/data:col9/1364133382268/Put/vlen=7, row009/url:col9/1364133382268/Put/vlen=6}
  11. keyvalues={row010/data:col0/1364133382268/Put/vlen=7, row010/url:col0/1364133382268/Put/vlen=6}
  12. 正则获取结尾为5的行
  13. keyvalues={row005/data:col5/1364133382268/Put/vlen=7, row005/url:col5/1364133382268/Put/vlen=6}
  14. keyvalues={row015/data:col5/1364133382268/Put/vlen=7, row015/url:col5/1364133382268/Put/vlen=6}
  15. keyvalues={row025/data:col5/1364133382268/Put/vlen=7, row025/url:col5/1364133382268/Put/vlen=6}
  16. keyvalues={row035/data:col5/1364133382268/Put/vlen=7, row035/url:col5/1364133382268/Put/vlen=6}
  17. keyvalues={row045/data:col5/1364133382268/Put/vlen=7, row045/url:col5/1364133382268/Put/vlen=6}
  18. 包行有5的行
  19. keyvalues={row005/data:col5/1364133382268/Put/vlen=7, row005/url:col5/1364133382268/Put/vlen=6}
  20. keyvalues={row015/data:col5/1364133382268/Put/vlen=7, row015/url:col5/1364133382268/Put/vlen=6}
  21. keyvalues={row025/data:col5/1364133382268/Put/vlen=7, row025/url:col5/1364133382268/Put/vlen=6}
  22. keyvalues={row035/data:col5/1364133382268/Put/vlen=7, row035/url:col5/1364133382268/Put/vlen=6}
  23. keyvalues={row045/data:col5/1364133382268/Put/vlen=7, row045/url:col5/1364133382268/Put/vlen=6}
  24. keyvalues={row050/data:col0/1364133382268/Put/vlen=7, row050/url:col0/1364133382268/Put/vlen=6}
  25. 开头是row01的
  26. keyvalues={row010/data:col0/1364133382268/Put/vlen=7, row010/url:col0/1364133382268/Put/vlen=6}
  27. keyvalues={row011/data:col1/1364133382268/Put/vlen=7, row011/url:col1/1364133382268/Put/vlen=6}
  28. keyvalues={row012/data:col2/1364133382268/Put/vlen=7, row012/url:col2/1364133382268/Put/vlen=6}
  29. keyvalues={row013/data:col3/1364133382268/Put/vlen=7, row013/url:col3/1364133382268/Put/vlen=6}
  30. keyvalues={row014/data:col4/1364133382268/Put/vlen=7, row014/url:col4/1364133382268/Put/vlen=6}
  31. keyvalues={row015/data:col5/1364133382268/Put/vlen=7, row015/url:col5/1364133382268/Put/vlen=6}
  32. keyvalues={row016/data:col6/1364133382268/Put/vlen=7, row016/url:col6/1364133382268/Put/vlen=6}
  33. keyvalues={row017/data:col7/1364133382268/Put/vlen=7, row017/url:col7/1364133382268/Put/vlen=6}
  34. keyvalues={row018/data:col8/1364133382268/Put/vlen=7, row018/url:col8/1364133382268/Put/vlen=6}
  35. keyvalues={row019/data:col9/1364133382268/Put/vlen=7, row019/url:col9/1364133382268/Put/vlen=6}

复制代码

hbase RowFilter如何根据rowkey查询以及实例实现代码 habase模糊查询【转】的更多相关文章

  1. Python 代码实现模糊查询

    Python 代码实现模糊查询 1.导语: 模糊匹配可以算是现代编辑器(如 Eclipse 等各种 IDE)的一个必备特性了,它所做的就是根据用户输入的部分内容,猜测用户想要的文件名,并提供一个推荐列 ...

  2. query_string查询支持全部的Apache Lucene查询语法 低频词划分依据 模糊查询 Disjunction Max

    3.3 基本查询3.3.1词条查询 词条查询是未经分析的,要跟索引文档中的词条完全匹配注意:在输入数据中,title字段含有Crime and Punishment,但我们使用小写开头的crime来搜 ...

  3. 10 行 Python 代码实现模糊查询/智能提示

    10 行 Python 代码实现模糊查询/智能提示   1.导语: 模糊匹配可以算是现代编辑器(如 Eclipse 等各种 IDE)的一个必备特性了,它所做的就是根据用户输入的部分内容,猜测用户想要的 ...

  4. ASP.NET MVC+EF框架+EasyUI实现权限管理系列(20)-多条件模糊查询和回收站还原的实现

    原文:ASP.NET MVC+EF框架+EasyUI实现权限管理系列(20)-多条件模糊查询和回收站还原的实现 ASP.NET MVC+EF框架+EasyUI实现权限管系列 (开篇)   (1):框架 ...

  5. stark组件的分页,模糊查询,批量删除

    1.分页组件高阶 2.整合展示数据showlist类 3.stark组件之分页 3.stark组件之search模糊查询 4.action批量处理数据 4.总结 1.分页组件高阶 1.分页的class ...

  6. 10 star组件之分页, search模糊查询, action批量处理

    1.分页组件高阶 1.分页的class形式(有bug,请看下面的) """ 自定义分页组件 """ class Pagination(obj ...

  7. ASP.NET操作ORACLE数据库之模糊查询

    ASP.NET操作ORACLE数据库之模糊查询 一.ASP.NET MVC利用OracleHelper辅助类操作ORACLE数据库 //连接Oracle数据库的连接字符串 string connect ...

  8. T-SQL---多值模糊查询的处理

    多值模糊查询的处理 所谓多值模糊查询,就是应用程序中传递过来多个参数,对这些参数做拆分,拆分之后,对拆分结果的key值分别做模糊查询处理 对于精确匹配时,不管是单个Key值还是多个Key值,都很容易处 ...

  9. JAVA 模糊查询方法

    当我们需要开发一个方法用来查询数据库的时候,往往会遇到这样一个问题:就是不知道用户到底会输入什么条件,那么怎么样处理sql语句才能让我们开发的方法不管接受到什么样的条件都可以正常工作呢?这时where ...

随机推荐

  1. EXCEL 列与列怎么交换?

    选中A列数据,按先SHIFT键的同时按住鼠标左键,向右拖动鼠标,在拖动的过程中,会出现一条虚线,当拖动到B列的右边缘时,屏幕上会出现 C:C 的提示,这时送开SHIFT键及鼠标左键,就完成了A B两列 ...

  2. H5中JavaScript常用代码片段

    /** * 批量替换方法,批量过滤特殊字符,通常用在通过后的各种编辑器添加的内容在App上编辑上使用 * james.wang 2016-11-11 * 使用方法:ReCont(Content,[&q ...

  3. 〖Linux〗联想K860/i Android 4.2及以上的Bootimg解压与打包工具

    因为自己有需要,所以花了一点时间来写了一下. 1. 解压工具 #!/bin/bash - #====================================================== ...

  4. DB2保存图片并读取动态显示图片

    博文背景: 客户要求结构化图片信息,而不是文件文档话的管理,故要求将图片信息存储于DB2里,出于技术的角度,真不喜欢将文件存储于数据库, 但客户是上帝,木有办法,故有了如下的测试. 测试环境:DB2 ...

  5. API密钥

    什么是API密钥? 答:在api调用时,用来按照指定规则对您的请求参数进行签名,服务器收到你的请求时会进行签名验证,即可以界定你的身份也可以防止其他人通过某种手段恶意篡改你的请求数据. 密钥的使用? ...

  6. 新浪微博api出现认证失败问题 (获取code字段值的问题)

    出现该提示的原因:`` - 说: (2015-10-30 18:06:14)回调地址不一致,`` - 说: (2015-10-30 18:07:38)请在编辑开发者信息中将网站地址和应用信息--高级信 ...

  7. centos7编译python3.6与原有的2.7共存

    在某些场景下我们可能需要python2.7和python3这两个版本进行共存,我在工作中也遇到过这样的问题,所以今天来总结下我的安装过程, 我的是用源码包安装的,安装的是python3.6的版本. 安 ...

  8. Javakeyword之this

    this的作用: 1) this是当前对象的一个引用.便于对当前对象參数的使用. 2)能够返回对象的自己这个类的引用.同一时候还能够在一个构造函数其中调用还有一个构造函数 this演示样例: publ ...

  9. Xshell和Xftp5配置连接阿里云服务器

    配置Xftp5 配置成功后 配置Xshell 记住用户名和密码 连接成功

  10. DirectoryEntry配置IIS7出现ADSI Error:未知错误(0x80005000) [转]

    一.错误情况 环境:win7+iis7.0 DirectoryEntry配置IIS7出现如下错误 或者是 下面一段代码在IIS6.0下运转正常,但IIS7.0下运转会出错: System.Direct ...