use of org.apache.hadoop.hbase.filter.SingleColumnValueFilter in project java-bigtable-hbase by googleapis.
the class AbstractTestFilters method testWhileMatchFilter_withUpdate.
@Test
public void testWhileMatchFilter_withUpdate() throws IOException {
String rowKeyPrefix = dataHelper.randomString("wmf-wu-");
byte[] qualA = dataHelper.randomData("qualA");
Table table = addDataForTesting(rowKeyPrefix, qualA);
table.put(new Put(Bytes.toBytes(rowKeyPrefix + "14")).addColumn(COLUMN_FAMILY, qualA, Bytes.toBytes(String.valueOf(2))));
ByteArrayComparable valueComparable = new BinaryComparator(String.valueOf(2).getBytes());
SingleColumnValueFilter valueFilter = new SingleColumnValueFilter(COLUMN_FAMILY, qualA, CompareOp.NOT_EQUAL, valueComparable);
Scan scan = new Scan().setFilter(new WhileMatchFilter(valueFilter));
int[] expected = { 0, 1, 10, 11, 12, 13 };
assertWhileMatchFilterResult(qualA, table, scan, expected);
}
use of org.apache.hadoop.hbase.filter.SingleColumnValueFilter in project java-bigtable-hbase by googleapis.
the class TestSingleColumnValueFilter method testSup.
@Test
public void testSup() throws IOException {
SingleColumnValueFilter filter = new SingleColumnValueFilter(COLUMN_FAMILY, QUALIFIER, CompareOp.GREATER_OR_EQUAL, Bytes.toBytes(5L));
filter.setFilterIfMissing(true);
Map<String, Long> rowKeys = getResult(filter);
Assert.assertEquals(5, rowKeys.size());
for (Entry<String, Long> entry : rowKeys.entrySet()) {
checkKey(entry.getKey());
Long v = entry.getValue();
Assert.assertTrue(String.format("%d < 5", v), v >= 5);
}
}
use of org.apache.hadoop.hbase.filter.SingleColumnValueFilter in project java-bigtable-hbase by googleapis.
the class TestSingleColumnValueFilter method testStrictInf.
@Test
public void testStrictInf() throws IOException {
SingleColumnValueFilter filter = new SingleColumnValueFilter(COLUMN_FAMILY, QUALIFIER, CompareOp.LESS, Bytes.toBytes(4L));
filter.setFilterIfMissing(true);
Map<String, Long> rowKeys = getResult(filter);
Assert.assertEquals(4, rowKeys.size());
for (Entry<String, Long> entry : rowKeys.entrySet()) {
checkKey(entry.getKey());
Long v = entry.getValue();
Assert.assertTrue(String.format("%d >= 4", v), v < 4);
}
}
use of org.apache.hadoop.hbase.filter.SingleColumnValueFilter in project java-bigtable-hbase by googleapis.
the class TestSingleColumnValueFilter method testStrictSup.
@Test
public void testStrictSup() throws IOException {
SingleColumnValueFilter filter = new SingleColumnValueFilter(COLUMN_FAMILY, QUALIFIER, CompareOp.GREATER, Bytes.toBytes(4L));
filter.setFilterIfMissing(true);
Map<String, Long> rowKeys = getResult(filter);
Assert.assertEquals(5, rowKeys.size());
for (Entry<String, Long> entry : rowKeys.entrySet()) {
checkKey(entry.getKey());
Long v = entry.getValue();
Assert.assertTrue(String.format("%d <= 4", v), v > 4);
}
}
use of org.apache.hadoop.hbase.filter.SingleColumnValueFilter in project java-bigtable-hbase by googleapis.
the class TestSingleColumnValueFilterAdapter method filterIfMissingIsApplied.
@Test
public void filterIfMissingIsApplied() throws IOException {
String valueStr = "foobar";
byte[] filterValue = Bytes.toBytes(valueStr);
byte[] qualifier = Bytes.toBytes("someColumn");
byte[] family = Bytes.toBytes("f");
SingleColumnValueFilter filter = new SingleColumnValueFilter(family, qualifier, CompareFilter.CompareOp.EQUAL, new BinaryComparator(filterValue));
filter.setFilterIfMissing(true);
filter.setLatestVersionOnly(false);
Filters.Filter adaptedFilter = UNDER_TEST.adapt(new FilterAdapterContext(new Scan(), null), filter);
assertColumnSpecification(family, qualifier, false, adaptedFilter.toProto().getCondition().getPredicateFilter());
Assert.assertEquals(createValueRangeFilter(valueStr), getValueRangeFilter(adaptedFilter.toProto().getCondition().getPredicateFilter().getChain()));
Assert.assertEquals(FILTERS.pass().toProto(), adaptedFilter.toProto().getCondition().getTrueFilter());
}
Aggregations