简体   繁体   中英

Cassandra . SSTableLoader Failed to decode value

Doing bulkloading by generating sSTables and then using sstableloader to load the data.

When querying the data on the loaded table, Primary Key data is failed to be decoded. I am seeing below errors.

Error on select query ( Other than primary key columns are getting rendered correctly):

Failed to decode value '\\xe4\\xedQ\\x9aX\\x8dF\\xab\\x86\\xf1\\r\\xe4]\\xc3\\x14C' (for column 'first_name') as text: 'utf8' codec can't decode byte 0xe4 in position 0: invalid continuation byte Failed to decode value '$q\\x9d\\x94P\\xb9Ni\\x9d);\\xd0\\x1d33~' (for column 'first_name') as text: 'utf8' codec can't decode byte 0x9d in position 2: invalid start byte

Code to generate SSTables:

SSTableSimpleUnsortedWriter eventWriter = new SSTableSimpleUnsortedWriter(directory, partitioner, keySpace, tableName, UTF8Type.instance,null, 64); eventWriter.addColumn(compType.builder().add(ByteBufferUtil.bytes("first_name")).build(), ByteBufferUtil.bytes(entry.firstName), timestamp); eventWriter.addColumn(compType.builder().add(ByteBufferUtil.bytes("last_name")).build(), ByteBufferUtil.bytes(entry.lastName), timestamp); eventWriter.addColumn(compType.builder().add(ByteBufferUtil.bytes("country")).build(), ByteBufferUtil.bytes(entry.countryText), timestamp);

Table definition:

CREATE TABLE test4 ( first_name varchar PRIMARY KEY, country text, last_name text, ) WITH bloom_filter_fp_chance=0.010000 AND caching='KEYS_ONLY' AND comment='' AND dclocal_read_repair_chance=0.000000 AND gc_grace_seconds=864000 AND read_repair_chance=0.100000 AND replicate_on_write='true' AND populate_io_cache_on_flush='false' AND compaction={'class': 'SizeTieredCompactionStrategy'} AND compression={'sstable_compression': 'LZ4Compressor'};

What should be done to have PrimaryKey decoded properly?

This problem is resolved.

There is no need of below statement. That means, primary key column does not need to be added separately.

eventWriter.addColumn(compType.builder().add(ByteBufferUtil.bytes("first_name")).build(), ByteBufferUtil.bytes(entry.firstName), timestamp);

It will get added when new row is created.

eventWriter.newRow(ByteBufferUtil.bytes(entry.firstName));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM