Escalation insert Cassandra

I'm currently trying to wrap my head around Cassandra / frugality using Erlang ...

I have a column family named "mq" (as in the message queue) ...

I would like to have a row per user (with user_id), each message will be a new column with a timestamp for the name and a message as a value.

Here in Cassandra-cli what I do:

create keyspace my_keyspace;
use my_keyspace;
create column family mq with comparator=UTF8Type and key_validation_class=UTF8Type;

%% Adding to user_id (00000001) the message "Hello World!" 
set mq['00000001']['1336499385041308'] = 'Hello Wold';

Everything works great with Cassandra-cli

However, when I try to paste from Erlang, I have a problem:

1>rr(cassandra_types).
2>{ok, C}=thrift_client_util:new("localhost", 9160, cassandra_thrift,[{framed, true}]).
3>thrift_client:call(C, 'set_keyspace', ["peeem"]).
4>thrift_client:call(C,'insert',["00000001",
                     #columnPath{column_family="mq"},
                     #column{name="1336499385041308", value="Hello World!"},
                     1
                     ]
                   ).

Here's the error:

{error,{bad_args,insert,
              ["00000001",
               #columnPath{column_family = "mq",super_column = undefined,
                           column = undefined},
               #column{name = "1336499385041308",value = "Hello World!",
                       timestamp = undefined,ttl = undefined},1]}}}

Any help would be appreciated ...

EDIT 1:

I figured out what it should be (how it works for someone else):

thrift_client:call(C,'insert', ["00000001", #columnParent{column_family="mq"}, #column{name="123456",value="Hello World!"}, 2]).

Here is the corresponding error message:

** exception error: no match of right hand side value {{protocol,thrift_binary_protocol,
                                                                 {binary_protocol,{transport,thrift_framed_transport,
                                                                                             {framed_transport,{transport,thrift_socket_transport,
                                                                                                                          {data,#Port<0.730>,infinity}},
                                                                                                               [],[]}},
                                                                                  true,true}},
                                                       {error,closed}}
     in function  thrift_client:send_function_call/3 (src/thrift_client.erl, line 83)
     in call from thrift_client:call/3 (src/thrift_client.erl, line 40)
+5
source share
2 answers

, , , ...

...

rr(cassandra_types).
{ok, C}=thrift_client_util:new("localhost", 9160, cassandra_thrift,[{framed, true}]).
{C1, _} = thrift_client:call(C, 'set_keyspace', ["my_keyspace"]).
thrift_client:call(C1,'insert', ["00000001", #columnParent{column_family="mq"}, #column{name="1234567",value="Hello World !", timestamp=0}, 2]).

trift_client, 'set_keyspace'... , , thrift_client .

, columnParent columnPath ( , ). #column ...

, - .

+1

All Articles