2013-12-17 170 views
0

通过生成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?

回答

0

此问题已解决。

不需要下面的说明。这意味着,主键列不需要单独添加。 ()),构造(),ByteBufferUtil.bytes(entry.firstName),timestamp);构造方法如下:public void setOfByte()

当新行被创建时它会被添加。

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