Cassandra java驱动程序UDT映射

Cassandra java驱动程序UDT映射,java,cassandra,Java,Cassandra,所以我在Cassandra数据库中有一个UDT: CREATE TYPE cs4224.OrderLine ( OL_I_ID int, OL_DELIVERY_D timestamp, OL_AMOUNT float, OL_SUPPLY_W_ID int, OL_QUANTITY int, OL_DIST_INFO varchar ); 当我查询这个时,我可以得到UDTValue,但我不确定如何映射到UDTClass,因为我使用的是Cassa

所以我在Cassandra数据库中有一个UDT:

CREATE TYPE cs4224.OrderLine (
    OL_I_ID int,
    OL_DELIVERY_D timestamp,
    OL_AMOUNT float,
    OL_SUPPLY_W_ID int,
    OL_QUANTITY int,
    OL_DIST_INFO varchar
);
当我查询这个时,我可以得到UDTValue,但我不确定如何映射到UDTClass,因为我使用的是CassandraJava驱动程序2.2.0rc3

在2.1中,有一些类似的指令。但在2.2.0中,这个(UDTMapper)似乎已被删除或尚未添加。如何做同样的事情或仅仅为了达到同样的效果


非常感谢。

事实证明,在2.2.0rc3中,我根本不需要使用UDTMapper。基本上有一个UDTValue类,我可以利用它通过使用getInt或类似的方法获得我想要的任何值。下面是一个代码示例:

Map<Integer, UDTValue> ols = row.getMap("o_ols", Integer.class, UDTValue.class);
for (Integer key: ols.keySet()) {
     UDTValue ol = ols.get(key);
     olIId = ol.getInt("ol_i_id");
     olQuantity = ol.getInt("ol_quantity");
     olDistInfo = ol.getString("ol_dist_info");
     olSupplyWId = ol.getInt("ol_supply_w_id");
     olAmount = ol.getFloat("ol_amount");
     olSum += olAmount;
     newOrderLine = orderLineType.newValue()
         .setInt("OL_I_ID", olIId)
         .setTimestamp("ol_delivery_d", new Timestamp(now.getTime()))
         .setFloat("ol_amount", olAmount)
         .setInt("ol_supply_w_id", olSupplyWId)
         .setInt("ol_quantity", olQuantity)
         .setString("ol_dist_info", olDistInfo);
     orderLines.put(key, newOrderLine);
 }
Map ols=row.getMap(“o_ols”,Integer.class,UDTValue.class);
for(整数键:ols.keySet()){
UDTValue ol=ols.get(键);
olIId=ol.getInt(“ol_i_id”);
olQuantity=ol.getInt(“ol_数量”);
olDistInfo=ol.getString(“ol_dist_info”);
olSupplyWId=ol.getInt(“ol_supply_w_id”);
olAmount=ol.getFloat(“ol_金额”);
olSum+=olAmount;
newOrderLine=orderLineType.newValue()
.setInt(“OL_I_ID”,olIId)
.setTimestamp(“ol_delivery_d”,新的时间戳(now.getTime())
.setFloat(“ol_金额”,olAmount)
.setInt(“ol_supply_w_id”,olSupplyWId)
.setInt(“olu数量”,olQuantity)
.setString(“ol_dist_info”,olDistInfo);
orderLines.put(key,newOrderLine);
}
希望这对其他人也有帮助