()
| 1279 | } |
| 1280 | |
| 1281 | @Test |
| 1282 | public void compareFilters() throws Exception { |
| 1283 | client.setFlushInterval(FAST_FLUSH); |
| 1284 | final PutRequest put1 = new PutRequest(table, "cf1", family, "a", "v1"); |
| 1285 | final PutRequest put2 = new PutRequest(table, "cf2", family, "b", "v2"); |
| 1286 | final PutRequest put3 = new PutRequest( |
| 1287 | Bytes.UTF8(table), |
| 1288 | Bytes.UTF8("cf3"), |
| 1289 | Bytes.UTF8(family), |
| 1290 | Bytes.UTF8("c"), |
| 1291 | Bytes.UTF8("v3"), |
| 1292 | 42); |
| 1293 | final PutRequest put4 = new PutRequest( |
| 1294 | Bytes.UTF8(table), |
| 1295 | Bytes.UTF8("cf3"), |
| 1296 | Bytes.UTF8(family), |
| 1297 | Bytes.UTF8("dep"), |
| 1298 | Bytes.UTF8("v4"), |
| 1299 | 42); |
| 1300 | Deferred.group( |
| 1301 | Deferred.group(client.put(put1), client.put(put2)), |
| 1302 | Deferred.group(client.put(put3), client.put(put4))).join(); |
| 1303 | |
| 1304 | final Scanner row_scanner = client.newScanner(table); |
| 1305 | row_scanner.setStartKey("cf1"); |
| 1306 | row_scanner.setStopKey("cf4"); |
| 1307 | row_scanner.setFilter( |
| 1308 | new RowFilter(CompareOp.NOT_EQUAL, new BinaryComparator(Bytes.UTF8("cf2")))); |
| 1309 | final ArrayList<ArrayList<KeyValue>> row_rows = |
| 1310 | row_scanner.nextRows().join(); |
| 1311 | row_scanner.close().join(); |
| 1312 | assertSizeIs(2, row_rows); |
| 1313 | assertSizeIs(1, row_rows.get(0)); |
| 1314 | assertEq("v1", row_rows.get(0).get(0).value()); |
| 1315 | assertSizeIs(2, row_rows.get(1)); |
| 1316 | assertEq("v3", row_rows.get(1).get(0).value()); |
| 1317 | assertEq("v4", row_rows.get(1).get(1).value()); |
| 1318 | |
| 1319 | final Scanner family_scanner = client.newScanner(table); |
| 1320 | family_scanner.setFilter( |
| 1321 | new FamilyFilter(CompareOp.LESS_OR_EQUAL, |
| 1322 | new BinaryComparator(Bytes.UTF8("aSomeOtherFamily")))); |
| 1323 | final ArrayList<ArrayList<KeyValue>> family_rows = |
| 1324 | family_scanner.nextRows().join(); |
| 1325 | family_scanner.close().join(); |
| 1326 | assertNull(family_rows); |
| 1327 | |
| 1328 | final Scanner qualifier_scanner = client.newScanner(table); |
| 1329 | qualifier_scanner.setStartKey("cf1"); |
| 1330 | qualifier_scanner.setStopKey("cf4"); |
| 1331 | qualifier_scanner.setFilter( |
| 1332 | new QualifierFilter(CompareOp.GREATER, |
| 1333 | new BinaryComparator(Bytes.UTF8("b")))); |
| 1334 | final ArrayList<ArrayList<KeyValue>> qualifier_rows = |
| 1335 | qualifier_scanner.nextRows().join(); |
| 1336 | qualifier_scanner.close().join(); |
| 1337 | assertSizeIs(1, qualifier_rows); |
| 1338 | assertSizeIs(2, qualifier_rows.get(0)); |
nothing calls this directly
no test coverage detected