Note that there are some explanatory texts on larger screens.

plurals
  1. POType mismatch Astyanax KeySerializer in Scala
    text
    copied!<p>I am trying to do the following but for some reason my code won't compile due to a type mismatch from the KeySerializer. </p> <pre><code>implicit val keyspace = ConnectionPool.bigdataKeyspace implicit val CF_PAST = ColumnFamily.newColumnFamily(CF, LongSerializer.get, StringSerializer.get) def update(model: M) = { val batch = keyspace.prepareMutationBatch().setConsistencyLevel(ConnectionPool.CL_WRITE) val rk = model.rowkey try { batch.withRow(CF_PAST, rk) .putColumnIfNotNull(model.epoch, model.value, model.ttl) batch.execute Option(model) } catch { case e: Exception =&gt; logger.warn("Unable to insert past model", e) None } } </code></pre> <p>The compile error is as follows"</p> <pre><code>error: type mismatch; found : com.netflix.astyanax.model.ColumnFamily[Long,String] required: com.netflix.astyanax.model.ColumnFamily[Comparable[_ &gt;: String with Long &lt;: Comparable[_ &gt;: String with Long &lt;: Comparable[_ &gt;: String with Long &lt;: java.io.Serializable] with java.io.Serializable] with java.io.Serializable] with java.io.Serializable,String] Note: Long &lt;: Comparable[_ &gt;: String with Long &lt;: Comparable[_ &gt;: String with Long &lt;: Comparable[_ &gt;: String with Long &lt;: 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. You may wish to investigate a wildcard type such as `_ &lt;: Comparable[_ &gt;: String with Long &lt;: Comparable[_ &gt;: String with Long &lt;: Comparable[_ &gt;: String with Long &lt;: java.io.Serializable] with java.io.Serializable] with java.io.Serializable] with java.io.Serializable`. (SLS 3.2.10) batch.withRow(CF_PAST, rk) </code></pre> <p>This only seems to happen in Scala with KeySerializers that are not a String, ColumnSerializers as other types seem to work fine? Is there a work around for this?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload