相同代码, 使用 hbase-client 连接自建hbase正常, 使用 alihbase-client 2.0.8 连接 hbase serverless 查询报错.
Caused by: java.io.IOException: TIOError(message:Unsupport filter org.apache.hadoop.hbase.filter.PageFilter)
at com.alibaba.hbase.client.AliHBaseAPIProxyThriftImpl$Scanner.next(AliHBaseAPIProxyThriftImpl.java:637)
at org.apache.hadoop.hbase.client.ResultScanner$1.hasNext(ResultScanner.java:53)
... 25 more
Caused by: TIOError(message:Unsupport filter org.apache.hadoop.hbase.filter.PageFilter)
at com.alibaba.hbase.thrift2.generated.THBaseService$getScannerResults_result$getScannerResults_resultStandardScheme.read(THBaseService.java:25413)
at com.alibaba.hbase.thrift2.generated.THBaseService$getScannerResults_result$getScannerResults_resultStandardScheme.read(THBaseService.java:25380)
at com.alibaba.hbase.thrift2.generated.THBaseService$getScannerResults_result.read(THBaseService.java:25322)
at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:88)
at com.alibaba.hbase.thrift2.generated.THBaseService$Client.recv_getScannerResults(THBaseService.java:1057)
at com.alibaba.hbase.thrift2.generated.THBaseService$Client.getScannerResults(THBaseService.java:1042)
at com.alibaba.hbase.client.AliHBaseAPIProxyThriftImpl$Scanner.next(AliHBaseAPIProxyThriftImpl.java:617)
... 26 more
PageFilter的实现逻辑。
public class PageFilter extends FilterBase {
private long pageSize = Long.MAX_VALUE;
private int rowsAccepted = 0;
/**
* Constructor that takes a maximum page size.
*
* @param pageSize Maximum result size.
*/
public PageFilter(final long pageSize) {
Preconditions.checkArgument(pageSize >= 0, "must be positive %s", pageSize);
this.pageSize = pageSize;
}
public long getPageSize() {
return pageSize;
}
@Override
public ReturnCode filterKeyValue(Cell ignored) throws IOException {
return ReturnCode.INCLUDE;
}
public boolean filterAllRemaining() {
return this.rowsAccepted >= this.pageSize;
}
public boolean filterRow() {
this.rowsAccepted++;
return this.rowsAccepted > this.pageSize;
}
}
其实很简单,内部有一个计数器,每次调用filterRow的时候,计数器都会+1,如果计数器值大于pageSize,filterrow就会返回true,那之后的行就会被过滤掉。
版本问题了、。
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。