5

I am trying to read a column of type Set from cassandra using the following astyanax code.

val genres = col.getColumnByName("genres")
val genValue = genres.getValue(new SetSerializer[String](UTF8Type.instance))

I found similar code in Astyanax documentation as well

https://github.com/Netflix/astyanax/wiki/Collections

but I get 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)

My table definition is

CREATE TABLE movielens_small.movies (
    id uuid PRIMARY KEY,
    avg_rating float,
    genres set<text>,
    name text,
    release_date date,
    url text,
    video_release_date date
) WITH bloom_filter_fp_chance = 0.01

I can easily to a select query in cqlsh. so I don't think there is some problem with db.

Edit:: I also tried

val myset = ListType.getInstance(UTF8Type.instance)
val genValue = myset.compose(genres.getByteBufferValue) 

But it throws the same error that there are unexpected extraneous bytes.

Edit2:: I also tried

val genValue = new String(genres.getByteBufferValue.array(), "UTF-8")

This doesn't throw an error, and I can see data... but its like gibberish.

enter image description here

Edit3:: I also tried

val setSer = new SetSerializer[String](UTF8Type.instance)
val buf = genres.getByteBufferValue
val genValue = setSer.fromByteBuffer(buf)
println(s"${name.getStringValue} rating: ${avgRating.getFloatValue} genres: ${genValue}")

But again the same problem of org.apache.cassandra.serializers.MarshalException: Unexpected extraneous bytes after set value

My cassandra table definition is

CREATE TABLE movielens_small.movies (
    id uuid PRIMARY KEY,
    avg_rating float,
    genres set<text>,
    name text,
    release_date date,
    url text,
    video_release_date date
) WITH bloom_filter_fp_chance = 0.01
    AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
    AND comment = ''
    AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
    AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
    AND crc_check_chance = 1.0
    AND dclocal_read_repair_chance = 0.1
    AND default_time_to_live = 0
    AND gc_grace_seconds = 864000
    AND max_index_interval = 2048
    AND memtable_flush_period_in_ms = 0
    AND min_index_interval = 128
    AND read_repair_chance = 0.0
    AND speculative_retry = '99PERCENTILE';
Knows Not Much
  • 30,395
  • 60
  • 197
  • 373
  • What is the code you have to put the values into the db? What are the cassandra db / library versions? – Ivan Nov 10 '16 at 16:34
  • I added the table definition to my question. My code is located here https://github.com/abhsrivastava/AstyanaxScala. you can look at my build.sbt file for all libraries and versions. – Knows Not Much Nov 11 '16 at 02:25

0 Answers0