diff --git a/hbase-lesson/src/main/java/date_20250411/task_DML_select.java b/hbase-lesson/src/main/java/date_20250411/task_DML_select.java index d101b39..402a25d 100644 --- a/hbase-lesson/src/main/java/date_20250411/task_DML_select.java +++ b/hbase-lesson/src/main/java/date_20250411/task_DML_select.java @@ -29,9 +29,8 @@ public class task_DML_select { // scanRows(table); - // getKeyValue(table,"000000"); - +// scanRowsWithFilter(table); getFamily(table); // 关闭连接 @@ -45,7 +44,7 @@ public class task_DML_select { * * @param table */ - public static void getKeyValue(Table table,String rowKey) throws IOException { + public static void getKeyValue(Table table, String rowKey) throws IOException { // String rowKey = "000010"; @@ -122,7 +121,7 @@ public class task_DML_select { //scan.withStopRow(Bytes.toBytes(stopMd5),false); // 设置总共要扫描的行数 - scan.setLimit(100000); + scan.setLimit(10000); ResultScanner scanner = table.getScanner(scan); // 扫描时的 行 迭代器 @@ -142,13 +141,17 @@ public class task_DML_select { Scan scan = new Scan(); scan.withStartRow(Bytes.toBytes("000001"), true); - scan.setLimit(10); + scan.setLimit(2); // 行键前缀过滤器 - Filter filter1 = new PrefixFilter(Bytes.toBytes("cd")); // 行键前缀过滤器 + Filter filter1 = new PrefixFilter(Bytes.toBytes("00")); // 行键前缀过滤器 // 列值过滤器(匹配到条件的行,整行数据都将返回) - SingleColumnValueFilter filter2 = new SingleColumnValueFilter(Bytes.toBytes("extra_info"), Bytes.toBytes("city"), CompareOperator.EQUAL, Bytes.toBytes("南京")); + SingleColumnValueFilter filter2 = + new SingleColumnValueFilter(Bytes.toBytes("extra_info"), + Bytes.toBytes("city"), + CompareOperator.EQUAL, + Bytes.toBytes("南京")); ArrayList filterList = new ArrayList(); filterList.add(filter1); @@ -158,11 +161,9 @@ public class task_DML_select { FilterList filters = new FilterList(FilterList.Operator.MUST_PASS_ALL, filterList); //FilterListWithAND filters = new FilterListWithAND(filterList); - // 给scan参数设置过滤器条件 scan.setFilter(filters); - ResultScanner scanner = table.getScanner(scan); Iterator iterator = scanner.iterator(); // 拿到行迭代器