I tried to read a "set" data type from Cassandra in 3 ways
val genValue = col.getValue("genre", new SetSerializer[String](UTF8Type.instance), new java.util.HashSet[String]()).toSet
and
val setSer = new SetSerializer[String](UTF8Type.instance) val genres = col.getColumnByName("genres") val buf = genres.getByteArrayValue val genValue = setSer.fromBytes(buf)
I found these two approaches after a lot of googling and reading the discussions on astyanax google groups and github. But both these fail with error
org.apache.cassandra.serializers.MarshalException: Unexpected extraneous bytes after set value
at org.apache.cassandra.serializers.SetSerializer.deserialize(SetSerializer.java:64)
at org.apache.cassandra.serializers.SetSerializer.deserialize(SetSerializer.java:27)
at org.apache.cassandra.db.marshal.AbstractType.compose(AbstractType.java:142)
at com.netflix.astyanax.serializers.SetSerializer.fromByteBuffer(SetSerializer.java:32)
at com.netflix.astyanax.serializers.SetSerializer.fromByteBuffer(SetSerializer.java:19)
at com.netflix.astyanax.serializers.AbstractSerializer.fromBytes(AbstractSerializer.java:42)
at com.abhi.CassandraReader$.$anonfun$new$2(CassandraReader.scala:32)
at com.abhi.CassandraReader$.$anonfun$new$2$adapted(CassandraReader.scala:24)
at scala.collection.immutable.List.foreach(List.scala:378)
at com.abhi.CassandraReader$.delayedEndpoint$com$abhi$CassandraReader$1(CassandraReader.scala:24)
at com.abhi.CassandraReader$delayedInit$body.apply(CassandraReader.scala:16)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App.$anonfun$main$1$adapted(App.scala:76)
I tried to read a "set" data type from Cassandra in 3 ways
val genValue = col.getValue("genre", new SetSerializer[String](UTF8Type.instance), new java.util.HashSet[String]()).toSet
and
val setSer = new SetSerializer[String](UTF8Type.instance) val genres = col.getColumnByName("genres") val buf = genres.getByteArrayValue val genValue = setSer.fromBytes(buf)
I found these two approaches after a lot of googling and reading the discussions on astyanax google groups and github. But both these fail with error
I have checked in my code sample here
https://github.com/abhsrivastava/AstyanaxScala