TheDeveloper
TheDeveloper

Reputation: 422

Cassandra: Using LongType

I'm trying to insert data into a ColumnFamily with "CompareWith" attribute "LongType". However, when trying to insert data under numerical keys, I get a thrift error.

When attempting the same operation with the cassandra-cli program, I get the error "A long is exactly 8 bytes". How can I resolve this? Should I use a different comparison type?

Thanks

Upvotes: 4

Views: 1672

Answers (3)

libjack
libjack

Reputation: 6443

The cassandra-cli program supports functions for the set command. (details from "help set;" in the cli)

With the following schema:

create column family Data 
 with key_validation_class = LongType
 and comparator = LongType
 and default_validation_class = LongType;

I can do the following in the cli

set Data[long(2)][long(22)]=long(1022);

Upvotes: 0

TheDeveloper
TheDeveloper

Reputation: 422

Looks like I need to use https://www.php.net/manual/en/function.pack.php to pack the key into an 8-byte binary string

Upvotes: 1

jbellis
jbellis

Reputation: 19377

the cli can't insert binary data.

there are examples in test/system/test_server.py of inserting Long data in python.

Upvotes: 1

Related Questions