通過生成sSTables然後使用sstableloader加載數據來執行批量加載。卡桑德拉。 SSTableLoader無法解碼值
查詢加載表上的數據時,主鍵數據無法解碼。我看到下面的錯誤。
錯誤上選擇查詢(除主鍵列得到正確呈現):
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
代碼,以生成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);
表定義:
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'};
應該如何正確解碼PrimaryKey?