PageFilterAdapter extends TypedFilterAdapterBase<PageFilter> { @Override public Filter adapt(FilterAdapterContext context, PageFilter filter) throws IOException { final long pageSize = filter.getPageSize(); context .getReadHooks() .composePreSendHook( new Function<Query, Query>() { @Override public Query apply(Query query) { return query.limit(pageSize); } }); return null; }  @Override Filter adapt(FilterAdapterContext context, PageFilter filter); @Override FilterSupportStatus isFilterSupported(FilterAdapterContext context, PageFilter filter);  }
@Test public void pageFilterIsAppliedToReadRowsRequest() throws IOException { final String TABLE_ID = "tableId"; final RequestContext requestContext = RequestContext.create("ProjectId", "InstanceId", "AppProfile"); ReadHooks hooks = new DefaultReadHooks(); FilterAdapterContext context = new FilterAdapterContext(new Scan(), hooks); PageFilter pageFilter = new PageFilter(20); Filters.Filter adaptedFilter = pageFilterAdapter.adapt(context, pageFilter); Assert.assertNull("PageFilterAdapter should not return a Filters.Filter.", adaptedFilter); Query query = Query.create(TABLE_ID).limit(100); hooks.applyPreSendHook(query); Assert.assertEquals(20, query.toProto(requestContext).getRowsLimit()); }