【问题标题】:LongComparator does not work in Google Cloud Bigtable with HBase APILongComparator 在带有 HBase API 的 Google Cloud Bigtable 中不起作用
【发布时间】:2015-06-10 11:07:06
【问题描述】:

我正在尝试构建一些过滤器来过滤 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 问题?

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

【问题讨论】:

    标签: java hbase google-cloud-bigtable


    【解决方案1】:

    SingleColumnValueFilter 支持以下比较器:

    • BinaryComparator
    • BinaryPrefixComparator
    • RegexStringComparator。

    查看此链接以获取最新列表:

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

    【讨论】:

      猜你喜欢
      • 2016-06-13
      • 2019-08-20
      • 2017-01-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多