Note that there are some explanatory texts on larger screens.

plurals
  1. POType mismatch when using Astyanax (Cassandra client) via Scala
    primarykey
    data
    text
    <p>I'm trying to use the Java Cassandra client Astyanax via Scala, but receiving this compile error:</p> <pre><code>[error] /massrel/metrics-batcher/src/main/scala/com/massrel/batcher/MetricsWriter.scala:35: type mismatch; [error] found : com.netflix.astyanax.model.ColumnFamily[java.nio.ByteBuffer,java.lang.Long] [error] required: com.netflix.astyanax.model.ColumnFamily[java.lang.Comparable[_ &gt;: java.lang.String with java.nio.ByteBuffer &lt;: java.lang.Comparable[_ &gt;: java.lang.String with java.nio.ByteBuffer &lt;: java.lang.Object]],java.lang.Long] [error] Note: java.nio.ByteBuffer &lt;: java.lang.Comparable[_ &gt;: java.lang.String with java.nio.ByteBuffer &lt;: java.lang.Comparable[_ &gt;: java.lang.String with java.nio.ByteBuffer &lt;: java.lang.Object]], but Java-defined class ColumnFamily is invariant in type K. [error] You may wish to investigate a wildcard type such as `_ &lt;: java.lang.Comparable[_ &gt;: java.lang.String with java.nio.ByteBuffer &lt;: java.lang.Comparable[_ &gt;: java.lang.String with java.nio.ByteBuffer &lt;: java.lang.Object]]`. (SLS 3.2.10) [error] m.withRow(CF_M, "foo").incrementCounterColumn(0, 1) [error] ^ [error] /massrel/metrics-batcher/src/main/scala/com/massrel/batcher/MetricsWriter.scala:36: type mismatch; [error] found : com.netflix.astyanax.model.ColumnFamily[java.nio.ByteBuffer,java.lang.Long] [error] required: com.netflix.astyanax.model.ColumnFamily[java.lang.Comparable[_ &gt;: java.lang.String with java.nio.ByteBuffer &lt;: java.lang.Comparable[_ &gt;: java.lang.String with java.nio.ByteBuffer &lt;: java.lang.Object]],java.lang.Long] [error] Note: java.nio.ByteBuffer &lt;: java.lang.Comparable[_ &gt;: java.lang.String with java.nio.ByteBuffer &lt;: java.lang.Comparable[_ &gt;: java.lang.String with java.nio.ByteBuffer &lt;: java.lang.Object]], but Java-defined class ColumnFamily is invariant in type K. [error] You may wish to investigate a wildcard type such as `_ &lt;: java.lang.Comparable[_ &gt;: java.lang.String with java.nio.ByteBuffer &lt;: java.lang.Comparable[_ &gt;: java.lang.String with java.nio.ByteBuffer &lt;: java.lang.Object]]`. (SLS 3.2.10) [error] m.withRow(CF_M, "bar").incrementCounterColumn(0, 1) [error] ^ </code></pre> <p>Here's the code in question:</p> <pre><code>package com.massrel.batcher import java.nio.ByteBuffer import scala.collection.mutable.{Map =&gt; MMap} import com.netflix.astyanax._ import com.netflix.astyanax.impl._ import com.netflix.astyanax.connectionpool._ import com.netflix.astyanax.connectionpool.impl._ import com.netflix.astyanax.thrift._ import com.netflix.astyanax.model._ import com.netflix.astyanax.serializers._ class MetricsWriter { val context: AstyanaxContext[Keyspace] = new AstyanaxContext.Builder() .forCluster("cluster1") .forKeyspace("dev1") .withAstyanaxConfiguration(new AstyanaxConfigurationImpl() .setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE) .setConnectionPoolType(ConnectionPoolType.TOKEN_AWARE) ) .withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("connectionpool1") .setPort(9160) .setMaxConnsPerHost(1) .setSeeds("127.0.0.1:9160") ) .withConnectionPoolMonitor(new CountingConnectionPoolMonitor()) .buildKeyspace(ThriftFamilyFactory.getInstance()); context.start() val keyspace = context.getEntity() val CF_M = new ColumnFamily[ByteBuffer, java.lang.Long]("M", ByteBufferSerializer.get(), LongSerializer.get()) def writeTest() { val m = keyspace.prepareMutationBatch() m.withRow(CF_M, "foo").incrementCounterColumn(0, 1) m.withRow(CF_M, "bar").incrementCounterColumn(0, 1) m.execute() } } </code></pre> <p>What can I do in my code to get around the issue?</p> <p>If it helps, you can view the Astyanax code here: <a href="https://github.com/Netflix/astyanax" rel="nofollow">https://github.com/Netflix/astyanax</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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