use of org.apache.hadoop.hbase.filter.LongComparator in project hbase by apache.
the class TestFromClientSide method testFilterWithLongCompartor.
@Test
public void testFilterWithLongCompartor() throws Exception {
final TableName tableName = TableName.valueOf(name.getMethodName());
Table ht = TEST_UTIL.createTable(tableName, FAMILY);
byte[][] ROWS = makeN(ROW, 10);
byte[][] values = new byte[10][];
for (int i = 0; i < 10; i++) {
values[i] = Bytes.toBytes(100L * i);
}
for (int i = 0; i < 10; i++) {
Put put = new Put(ROWS[i]);
put.setDurability(Durability.SKIP_WAL);
put.addColumn(FAMILY, QUALIFIER, values[i]);
ht.put(put);
}
Scan scan = new Scan();
scan.addFamily(FAMILY);
Filter filter = new SingleColumnValueFilter(FAMILY, QUALIFIER, CompareOp.GREATER, new LongComparator(500));
scan.setFilter(filter);
ResultScanner scanner = ht.getScanner(scan);
int expectedIndex = 0;
for (Result result : ht.getScanner(scan)) {
assertEquals(result.size(), 1);
assertTrue(Bytes.toLong(result.getValue(FAMILY, QUALIFIER)) > 500);
expectedIndex++;
}
assertEquals(expectedIndex, 4);
scanner.close();
}
Aggregations