如何通过行键从Bigtable获取所有值?

时间:2019-06-18 10:57:46

标签: java google-cloud-platform hbase bigtable google-cloud-bigtable

我无法通过行键从BigTable中获取所有值,

我的表看起来像这样,我只能得到3个,具有相同限定符的同一列族只能得到一个,例如hash:md5仅得到“ emialmd5test”

xy001uuuyyyy
  hashes:md5                               @ 2019/06/17-16:57:10.173000
    "emialmd5test"
  hashes:md5                               @ 2019/06/17-10:58:39.711000
    "emialmd5"
  hashes:sha1                              @ 2019/06/17-16:57:10.173000
    "emailsha1test"
  hashes:sha1                              @ 2019/06/17-10:58:39.711000
    "emailsha1"
  hashes:sha256                            @ 2019/06/17-16:57:10.172000
    "emailsha256test"
  hashes:sha256                            @ 2019/06/17-10:58:39.711000
    "emailsha256"

这是我的代码

Connection connection = BigtableConfiguration.connect(WholeSaleHelper.WHOOLE_SALE_CONFIG.toHBaseConfig());
    Scan scan = new Scan()
        .setRowPrefixFilter(cookieAndPel.getValue().getBytes());

    Table table = connection.getTable(TableName.valueOf(WholeSaleHelper.WHOOLE_SALE_CONFIG.getTableId()));
    byte[] md5Bytes = null, sha1Bytes = null, sha256Bytes = null;

    for (Result result : table.getScanner(scan)) {

      md5Bytes = result.getValue(WholeSaleHelper.WHOLE_SALE_COLUMN_FAMILY.getBytes(), WholeSaleHelper.WHOLE_SALE_MD5.getBytes());
      sha1Bytes = result.getValue(WholeSaleHelper.WHOLE_SALE_COLUMN_FAMILY.getBytes(), WholeSaleHelper.WHOLE_SALE_SHA1.getBytes());
      sha256Bytes = result.getValue(WholeSaleHelper.WHOLE_SALE_COLUMN_FAMILY.getBytes(), WholeSaleHelper.WHOLE_SALE_SHA256.getBytes());
    }

还是可以使用其他方式获取值?只需通过roe键进行搜索即可获取所有值。不在乎列族和限定符

1 个答案:

答案 0 :(得分:1)

您可以将其添加到扫描中以获取所有版本:scan.setMaxVersions();