longcomparator在带有hbase api的google cloud bigtable中不起作用

0s0u357o  于 2021-06-09  发布在  Hbase
关注(0)|答案(1)|浏览(369)

我正在尝试构建一些过滤器来过滤bigtable中的数据。我在用 bigtable-hbase 驱动程序和hbase驱动程序。实际上,这是我从 pom.xml :

<dependency>
        <groupId>org.apache.hbase</groupId>
        <artifactId>hbase-common</artifactId>
        <version>${hbase.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.hbase</groupId>
        <artifactId>hbase-protocol</artifactId>
        <version>${hbase.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.hbase</groupId>
        <artifactId>hbase-client</artifactId>
        <version>${hbase.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.hbase</groupId>
        <artifactId>hbase-server</artifactId>
        <version>${hbase.version}</version>
    </dependency>

    <dependency>
        <groupId>com.google.cloud.bigtable</groupId>
        <artifactId>bigtable-hbase</artifactId>
        <version>${bigtable.version}</version>
    </dependency>

我过滤的数据如下:

Filter filterName  = new SingleColumnValueFilter(Bytes.toBytes("FName"), Bytes.toBytes("FName"),
                CompareFilter.CompareOp.EQUAL, new RegexStringComparator("JOHN"));
FilterList filters = new FilterList();

filters.addFilter(filterName);

Scan scan1 = new Scan();
scan1.setFilter(filters);

这个没问题。但我在前面的代码中添加了以下内容:

Filter filterSalary = new SingleColumnValueFilter(Bytes.toBytes("Salary"), Bytes.toBytes("Salary"),
                CompareFilter.CompareOp.GREATER_OR_EQUAL, new LongComparator(100000));
filters.addFilter(filterSalary);

它给了我一个例外:

Exception in thread "main" com.google.cloud.bigtable.hbase.adapters.filters.UnsupportedFilterException: Unsupported filters encountered: FilterSupportStatus{isSupported=false, reason='ValueFilter must have either a BinaryComparator with any compareOp or a RegexStringComparator with an EQUAL compareOp. Found (LongComparator, GREATER_OR_EQUAL)'}
at com.google.cloud.bigtable.hbase.adapters.filters.FilterAdapter.throwIfUnsupportedFilter(FilterAdapter.java:144)
at com.google.cloud.bigtable.hbase.adapters.ScanAdapter.throwIfUnsupportedScan(ScanAdapter.java:55)
at com.google.cloud.bigtable.hbase.adapters.ScanAdapter.adapt(ScanAdapter.java:91)
at com.google.cloud.bigtable.hbase.adapters.ScanAdapter.adapt(ScanAdapter.java:43)
at com.google.cloud.bigtable.hbase.BigtableTable.getScanner(BigtableTable.java:247)

所以我的问题是如何过滤长数据类型?是hbase问题还是bigtable特定的问题?
我发现这个问题:如何在hbase上使用带有singlecolumnvaluefilter的自定义比较器?但我无法将jar加载到服务器,因此它不适用于我的情况。

chy5wohz

chy5wohz1#

SingleColumnValueFilter 支持以下比较器: BinaryComparator BinaryPrefixComparator RegexStringComparator .
有关最新列表,请参见此链接:
https://cloud.google.com/bigtable/docs/hbase-differences

相关问题