Skip to content

Commit 84bf4ca

Browse files
authored
fix: filter out results on no-op filters (#3456)
1 parent 44e96a9 commit 84bf4ca

4 files changed

Lines changed: 15 additions & 10 deletions

File tree

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ again.
4040

4141
There are also tests that perform compatibility tests against an HBase Minicluster, which can be invoked with the following commands for HBase 1 and HBase 2 respectively:
4242
```sh
43-
mvn clean verify -PhbaseLocalMiniClusterTest
43+
mvn clean verify -Penable-integration-tests -PhbaseLocalMiniClusterTest
4444
```
4545
```sh
46-
mvn clean verify -PhbaseLocalMiniClusterTestH2
46+
mvn clean verify -Penable-integration-tests -PhbaseLocalMiniClusterTestH2
4747
```
4848

4949
You can run those commands at the top of the project, or you can run them at the appropriate integration-tests project.

bigtable-client-core-parent/bigtable-hbase-integration-tests-common/src/test/java/com/google/cloud/bigtable/hbase/AbstractTestFilters.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1969,7 +1969,7 @@ public void testQualifierBinaryComparatorFilter() throws IOException {
19691969
Filter noOpFilter = new QualifierFilter(CompareOp.NO_OP, binaryComparator);
19701970
Get noOpGet = new Get(rowKey).setFilter(noOpFilter).addFamily(COLUMN_FAMILY);
19711971
Result noOpResult = table.get(noOpGet);
1972-
Assert.assertEquals(10, noOpResult.size());
1972+
Assert.assertEquals(0, noOpResult.size());
19731973

19741974
table.close();
19751975
}

bigtable-client-core-parent/bigtable-hbase/src/main/java/com/google/cloud/bigtable/hbase/adapters/filters/QualifierFilterAdapter.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,10 @@ private Filter adaptBinaryComparator(
100100
.rangeWithinFamily(FilterAdapterHelper.getSingleFamilyName(context))
101101
.startOpen(value);
102102
case NO_OP:
103-
// No-op always passes. Instead of attempting to return null or default instance,
104-
// include an always-match filter.
105-
return FILTERS.pass();
103+
// No-ops are always filtered out.
104+
// See:
105+
// https://github.com/apache/hbase/blob/master/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnValueFilter.java#L127-L138
106+
return FILTERS.block();
106107
default:
107108
throw new IllegalStateException(
108109
String.format("Cannot handle unknown compare op %s", compareOp));

bigtable-client-core-parent/bigtable-hbase/src/main/java/com/google/cloud/bigtable/hbase/adapters/filters/ValueFilterAdapter.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,10 @@ private Filter adaptBinaryComparator(CompareOp compareOp, BinaryComparator compa
9898
case GREATER:
9999
return range().startOpen(value);
100100
case NO_OP:
101-
// No-op always passes. Instead of attempting to return null or default instance,
102-
// include an always-match filter.
103-
return FILTERS.pass();
101+
// No-ops are always filtered out.
102+
// See:
103+
// https://github.com/apache/hbase/blob/master/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnValueFilter.java#L127-L138
104+
return FILTERS.block();
104105
default:
105106
throw new IllegalStateException(
106107
String.format("Cannot handle unknown compare op %s", compareOp));
@@ -116,8 +117,11 @@ private Filter adaptRegexStringComparator(CompareOp compareOp, RegexStringCompar
116117
switch (compareOp) {
117118
case EQUAL:
118119
return FILTERS.value().regex(pattern);
120+
// No-ops are always filtered out.
121+
// See:
122+
// https://github.com/apache/hbase/blob/master/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnValueFilter.java#L127-L138
119123
case NO_OP:
120-
return FILTERS.pass();
124+
return FILTERS.block();
121125
case LESS:
122126
case LESS_OR_EQUAL:
123127
case NOT_EQUAL:

0 commit comments

Comments
 (0)