Cassandra 3.x Triigger:获取“群集键及其值”

问题描述 投票:0回答:1

我需要找到一种方法,不仅可以获取分区密钥,而且还可以通过Partition对象获得聚类密钥。我知道如何从对象中获取实际的分区键及其值,而不是“群集键”

这是到目前为止我尝试过的:我尝试过使用“ unfilteredIterator”,但是它仅返回常规列(不返回聚类键/值)

我的C *表如下所示>>

CREATE TABLE user.foo (
ac_id timeuuid,
mapping_id timeuuid,
country text,
state text,
PRIMARY KEY (ac_id, mapping_id) ) WITH CLUSTERING ORDER BY (mapping_id DESC) ...

到目前为止,我的代码:

public static String getKeyText(Partition update) {
    List<Map<String, String>> listOfMaps = new ArrayList<Map<String, String>>();
    CFMetaData cfm = update.metadata();
    Map<String, String> map = new HashMap<String, String>();
    try {
      UnfilteredRowIterator it = update.unfilteredIterator();
      while (it.hasNext()) {
          Unfiltered un = it.next();
          Clustering clt = (Clustering) un.clustering();
          Iterator<Cell> cells = update.getRow(clt).cells().iterator();
          Iterator<ColumnDefinition> columnss = update.getRow(clt).columns().iterator();
          while(columnss.hasNext()){
              ColumnDefinition columnDef = columnss.next();
              Cell cell = cells.next();
          }
      }
  } catch (Exception e) {

  }
}

目标是获取ac_id和mapping_id列名和值

感谢您的任何帮助

我需要找到一种方法,不仅可以获取分区密钥,而且还可以通过Partition对象获得聚类密钥。我知道如何从对象中获取实际的分区键及其值,但不能从“群集...

cassandra cassandra-3.0 scylla
1个回答
0
投票

我已经通过以下方法解决了它:

© www.soinside.com 2019 - 2024. All rights reserved.