java - LongComparator 不适用于具有 HBase API 的 Google Cloud Bigtable

标签 java hbase google-cloud-bigtable

我正在尝试构建一些过滤器来过滤来自 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):

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 特定问题?

我找到了这个How do you use a custom comparator with SingleColumnValueFilter on HBase?但我无法将我的 jar 加载到服务器,因此它不适用于我的情况。

最佳答案

SingleColumnValueFilter 支持以下比较器:

  • 二进制比较器
  • BinaryPrefixComparator
  • RegexStringComparator

请参阅此链接以获取最新列表:

https://cloud.google.com/bigtable/docs/hbase-differences

关于java - LongComparator 不适用于具有 HBase API 的 Google Cloud Bigtable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30754510/

相关文章:

python - 使用 Python SDK 按前缀扫描 Bigtable

google-cloud-dataflow - 如何集成测试写入 Bigtable 的 Dataflow 管道?

java - 将两个字符串从一个 Activity 传递到另一个 Activity

hadoop - Ganglia 无法与 Apache HBase 通信

python - 如何删除 BigTable GCP 中的过滤行

mysql - 将具有组合键的大型且频繁更新的 MySQL 表移动到 HDFS

java - HBase表上普通Java程序和MapReduce java程序的区别

java - 闹钟不会停止响 - 取消按钮不起作用

javascript - YUIcompressor 指令前缺少分号

java - 我应该在 JOOQ 上禁用 UInteger 类型吗?