Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Type mismatch Astyanax KeySerializer in Scala #269

Closed
chiappone opened this Issue · 0 comments

1 participant

@chiappone

I am trying to do the following but for some reason my code won't compile due to a type mismatch from the KeySerializer.

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 =>
    logger.warn("Unable to insert past model", e)
    None
}

}
The compile error is as follows"

error: type mismatch; found

: com.netflix.astyanax.model.ColumnFamily[Long,String] 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] 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.
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)
batch.withRow(CF_PAST, rk)

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?

@chiappone chiappone closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.