Skip to content

Commit

Permalink
HBASE-28518 Allow specifying a filter for the REST multiget endpoint …
Browse files Browse the repository at this point in the history
…(addendum: revert SCAN_FILTER constant name)
  • Loading branch information
stoty committed Apr 25, 2024
1 parent 6c6e776 commit 944d4c1
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public interface Constants {
String SCAN_BATCH_SIZE = "batchsize";
String SCAN_LIMIT = "limit";
String SCAN_FETCH_SIZE = "hbase.rest.scan.fetchsize";
String FILTER = "filter";
String SCAN_FILTER = "filter";
String FILTER_B64 = "filter_b64";
String SCAN_REVERSED = "reversed";
String SCAN_CACHE_BLOCKS = "cacheblocks";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public MultiRowResource(TableResource tableResource, String versions, String col
public Response get(final @Context UriInfo uriInfo,
final @HeaderParam("Encoding") String keyEncodingHeader,
@QueryParam(Constants.FILTER_B64) @Encoded String paramFilterB64,
@QueryParam(Constants.FILTER) String paramFilter) {
@QueryParam(Constants.SCAN_FILTER) String paramFilter) {
MultivaluedMap<String, String> params = uriInfo.getQueryParameters();
String keyEncoding = (keyEncodingHeader != null)
? keyEncodingHeader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public TableScanResource getScanResource(final @PathParam("scanspec") String sca
@DefaultValue(Long.MAX_VALUE + "") @QueryParam(Constants.SCAN_END_TIME) long endTime,
@DefaultValue("true") @QueryParam(Constants.SCAN_CACHE_BLOCKS) boolean cacheBlocks,
@DefaultValue("false") @QueryParam(Constants.SCAN_REVERSED) boolean reversed,
@QueryParam(Constants.FILTER) String paramFilter,
@QueryParam(Constants.SCAN_FILTER) String paramFilter,
@QueryParam(Constants.FILTER_B64) @Encoded String paramFilterB64) {
try {
Filter prefixFilter = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ public void testMultiCellGetFilterJSON() throws IOException {
checkMultiCellGetJSON(response);

// Same with non binary clean param
positivePath = path.toString() + ("&" + Constants.FILTER + "="
positivePath = path.toString() + ("&" + Constants.SCAN_FILTER + "="
+ URLEncoder.encode("PrefixFilter('testrow')", StandardCharsets.UTF_8.name()));
response = client.get(positivePath, Constants.MIMETYPE_JSON);
checkMultiCellGetJSON(response);
Expand All @@ -381,7 +381,7 @@ public void testMultiCellGetFilterJSON() throws IOException {
assertEquals(404, response.getCode());

// Same with non binary clean param
negativePath = path.toString() + ("&" + Constants.FILTER + "="
negativePath = path.toString() + ("&" + Constants.SCAN_FILTER + "="
+ URLEncoder.encode("PrefixFilter('notfound')", StandardCharsets.UTF_8.name()));
response = client.get(negativePath, Constants.MIMETYPE_JSON);
assertEquals(404, response.getCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ public void testSimpleFilter() throws IOException, JAXBException {
builder.append("&");
builder.append(Constants.SCAN_END_ROW + "=aay");
builder.append("&");
builder.append(Constants.FILTER + "=" + URLEncoder.encode("PrefixFilter('aab')", "UTF-8"));
builder.append(Constants.SCAN_FILTER + "=" + URLEncoder.encode("PrefixFilter('aab')", "UTF-8"));
Response response = client.get("/" + TABLE + builder.toString(), Constants.MIMETYPE_XML);
assertEquals(200, response.getCode());
JAXBContext ctx = JAXBContext.newInstance(CellSetModel.class);
Expand Down Expand Up @@ -494,7 +494,7 @@ public void testQualifierAndPrefixFilters() throws IOException, JAXBException {
builder.append("/abc*");
builder.append("?");
builder
.append(Constants.FILTER + "=" + URLEncoder.encode("QualifierFilter(=,'binary:1')", "UTF-8"));
.append(Constants.SCAN_FILTER + "=" + URLEncoder.encode("QualifierFilter(=,'binary:1')", "UTF-8"));
Response response = client.get("/" + TABLE + builder.toString(), Constants.MIMETYPE_XML);
assertEquals(200, response.getCode());
JAXBContext ctx = JAXBContext.newInstance(CellSetModel.class);
Expand All @@ -511,7 +511,7 @@ public void testCompoundFilter() throws IOException, JAXBException {
StringBuilder builder = new StringBuilder();
builder.append("/*");
builder.append("?");
builder.append(Constants.FILTER + "="
builder.append(Constants.SCAN_FILTER + "="
+ URLEncoder.encode("PrefixFilter('abc') AND QualifierFilter(=,'binary:1')", "UTF-8"));
Response response = client.get("/" + TABLE + builder.toString(), Constants.MIMETYPE_XML);
assertEquals(200, response.getCode());
Expand All @@ -531,7 +531,7 @@ public void testCustomFilter() throws IOException, JAXBException {
builder.append("?");
builder.append(Constants.SCAN_COLUMN + "=" + COLUMN_1);
builder.append("&");
builder.append(Constants.FILTER + "=" + URLEncoder.encode("CustomFilter('abc')", "UTF-8"));
builder.append(Constants.SCAN_FILTER + "=" + URLEncoder.encode("CustomFilter('abc')", "UTF-8"));
Response response = client.get("/" + TABLE + builder.toString(), Constants.MIMETYPE_XML);
assertEquals(200, response.getCode());
JAXBContext ctx = JAXBContext.newInstance(CellSetModel.class);
Expand All @@ -550,7 +550,7 @@ public void testNegativeCustomFilter() throws IOException, JAXBException {
builder.append("?");
builder.append(Constants.SCAN_COLUMN + "=" + COLUMN_1);
builder.append("&");
builder.append(Constants.FILTER + "=" + URLEncoder.encode("CustomFilter('abc')", "UTF-8"));
builder.append(Constants.SCAN_FILTER + "=" + URLEncoder.encode("CustomFilter('abc')", "UTF-8"));
Response response = client.get("/" + TABLE + builder.toString(), Constants.MIMETYPE_XML);
assertEquals(200, response.getCode());
JAXBContext ctx = JAXBContext.newInstance(CellSetModel.class);
Expand Down

0 comments on commit 944d4c1

Please sign in to comment.