开发者

Cassandra - How to insert an UUID

开发者 https://www.devze.com 2023-01-19 22:22 出处:网络
I\'m using Cassandra0.6.4 and I\'m trying to insert an UUID for a column and I get an exception of: InvalidRequestException(why:UUIDs must be exactly 16 bytes). What is the correct way to insert an UU

I'm using Cassandra 0.6.4 and I'm trying to insert an UUID for a column and I get an exception of: InvalidRequestException(why:UUIDs must be exactly 16 bytes). What is the correct way to insert an UUID? Thanks!

My column family is defined as:

<ColumnFamily CompareWith="TimeUUIDType" Name="Comments"/>

Code Snippet:

        try {
            ColumnPath colPathname = new ColumnPath(COLUMN_FAMILY);
            colPathname.setColumn(colName.getBytes(ENCODING));
            client.insert(KEYSPACE, rowKey, colPathname, colValue,开发者_运维知识库 System.currentTimeMillis(), ConsistencyLevel.ONE);

        } catch (Exception exception) {
            ..
        }
    }


Same problems as this. Same solution :)

(short version: you are confusing row key with column name/key)

0

精彩评论

暂无评论...
验证码 换一张
取 消