2013-05-01 53 views
0
val CF_USER_STATS = new ColumnFamily[java.lang.Long, String]("Standard2", LongSerializer.get, StringSerializer.get) 

val m: MutationBatch = keyspace.prepareMutationBatch() 

m.withRow(CF_USER_STATS, "acct1234").incrementCounterColumn("CounterColumn1", 1) 

m.execute() 

以上是創建一個列家族,旨在用作Cassandra中的計數器。無論出於何種原因,編譯未能與以下:使用astyanax客戶端編譯scala代碼時遇到的問題

type mismatch; 
[error] found : com.netflix.astyanax.model.ColumnFamily[Long,String] 
[error] required: com.netflix.astyanax.model.ColumnFamily[Comparable[_ >: String with Long <: Comparable[_ >: String with Long <: Comparable[_ >: String with Long <: java.io.Serializable] with java.io.Serializable] with java.io.Serializable] with java.io.Serializable,String] 
[error] Note: Long <: Comparable[_ >: String with Long <: Comparable[_ >: String with Long <: Comparable[_ >: String with Long <: java.io.Serializable] with java.io.Serializable] with java.io.Serializable] with java.io.Serializable, but Java-defined class ColumnFamily is invariant in type K. 
[error] You may wish to investigate a wildcard type such as `_ <: Comparable[_ >: String with Long <: Comparable[_ >: String with Long <: Comparable[_ >: String with Long <: java.io.Serializable] with java.io.Serializable] with java.io.Serializable] with java.io.Serializable`. (SLS 3.2.10) 
[error] m.withRow(CF_USER_STATS, "acct1234") 

回答

0

Astyanax的ColumnFamily語法與描述

ColumnFamily<String, String> CF = 
    new ColumnFamily<String, String>(
    "Standard1",    // Column Family Name 
    StringSerializer.get(), // Key Serializer 
    StringSerializer.get()); // Column Serializer 

現在你的情況,你提到你的rowkey爲長型和列作爲字符串和同時更新您正在使用鍵的計數器作爲您的字符串,這就是爲什麼這個類型不匹配

相關問題