| | 1 | 开发的时候发现HBASE使用的一个问题 |
| | 2 | |
| | 3 | |
| | 4 | {{{ |
| | 5 | byte[][] qualifiers = new byte[][]{Bytes.toBytes("apns"), Bytes.toBytes("receive_type"), Bytes.toBytes("receiv |
| | 6 | e_time")}; |
| | 7 | Scan scan = new Scan(); |
| | 8 | scan.setCaching(100); |
| | 9 | scan.setMaxVersions(1); |
| | 10 | FilterList filters = new FilterList(); |
| | 11 | |
| | 12 | RowFilter rowfilter = new RowFilter(CompareOp.EQUAL, new BinaryPrefixComparator(new String(3 + "_").getBytes() |
| | 13 | )); |
| | 14 | filters.addFilter(rowfilter); |
| | 15 | |
| | 16 | SingleColumnValueFilter filter = new SingleColumnValueFilter( |
| | 17 | Bytes.toBytes("base"), |
| | 18 | "app_ver_int".getBytes(), |
| | 19 | CompareOp.EQUAL, |
| | 20 | Bytes.toBytes(3020000)); |
| | 21 | filters.addFilter(filter); |
| | 22 | |
| | 23 | for (int i = 0; i < qualifiers.length; i++) { |
| | 24 | scan.addColumn(Bytes.toBytes("base"), qualifiers[i]); |
| | 25 | } |
| | 26 | // filters.addFilter(new FirstKeyOnlyFilter()); |
| | 27 | |
| | 28 | scan.setFilter(filters); |
| | 29 | ResultScanner scanner = hTable.getScanner(scan); |
| | 30 | |
| | 31 | }}} |
| | 32 | |
| | 33 | 出现问题,由于filter里面的字段在addColumn的时候是没用的,filter就失效了 |