Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,10 @@ public Scan setMaxResultSize(long maxResultSize) {

@Override
public Scan setFilter(Filter filter) {
if (filter != null && filter.hasFilterRow() && this.batch > 0) {
throw new IncompatibleFilterException(
"Cannot set a filter that returns true for filter.hasFilterRow on a scan with batch set");
}
super.setFilter(filter);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.fail;

import java.io.IOException;
Expand All @@ -29,6 +30,8 @@
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.client.Scan.ReadType;
import org.apache.hadoop.hbase.filter.FilterList;
import org.apache.hadoop.hbase.filter.IncompatibleFilterException;
import org.apache.hadoop.hbase.filter.PageFilter;
import org.apache.hadoop.hbase.security.access.Permission;
import org.apache.hadoop.hbase.security.visibility.Authorizations;
import org.apache.hadoop.hbase.testclassification.ClientTests;
Expand Down Expand Up @@ -254,6 +257,36 @@ public void testScanCopyConstructor() throws Exception {
"Make sure copy constructor adds all the fields in the copied object");
}

@Test
public void testSetFilterWithBatchThrows() {
Scan scan = new Scan();
scan.setBatch(5);
assertThrows(IncompatibleFilterException.class, () -> scan.setFilter(new PageFilter(10)));
}

@Test
public void testSetFilterWithoutBatchDoesNotThrow() {
Scan scan = new Scan();
scan.setFilter(new PageFilter(10));
// no exception expected
}

@Test
public void testSetFilterWithBatchAndNonFilterRowFilter() {
Scan scan = new Scan();
scan.setBatch(5);
scan.setFilter(new FilterList());
// FilterList.hasFilterRow() returns false, so no exception expected
}

@Test
public void testSetFilterWithBatchAndNullFilter() {
Scan scan = new Scan();
scan.setBatch(5);
scan.setFilter(null);
// null filter should not throw
}

@Test
public void testScanReadType() throws Exception {
Scan scan = new Scan();
Expand Down
Loading