You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by pradeep w <hp...@gmail.com> on 2010/12/05 08:59:33 UTC

facing problem while using Erlang for Cassandra

Hi
 I'm new to Erlang and Cassandra. I just tried to do a simple insert and i'm
getting below error. I'm using Cassandra 0.6.8 . I took the erlang library
code from,http://svn.apache.org/viewvc/thrift/trunk/lib/erl . And generated
thrift interfaces from the cassandra.thrift available with cassandra.
Where am i going wrong? Is there any document available mapping the
cassandra interface parameter types  to Erlang structures?
Details are : Windows XP, Cassandra0.6.8, Erlang5.8.1 [R14], Java 1.6.0_17.

I face no problems when I try the code in Java with Hector. So i guess i'm
doing wrong mapping for erlang.

The code is as follows:

> timestamp() ->

{MegaSecs, Secs, Microsec} = now(),

MegaSecs*1000000000000 + Secs*1000000 + Microsec.


> insert(N)->

Ts = timestamp(),

COL_PATH = #columnPath{column_family = "OBJ",

                       column = #column{name = "OBJID", value =
> term_to_binary(N), timestamp = Ts}

                       },

ARGS = ["TEST",integer_to_list(N),COL_PATH,term_to_binary(N),Ts,1],

{ok, C} = thrift_client_util:new("localhost", 9090, cassandra_thrift, []),

{C2,ok} = thrift_client:call(C, 'insert', ARGS).


i tried giving column value as N and also as term_to_binary(N) but the
result is same as error below.
The error i get is following:

> =ERROR REPORT==== 4-Dec-2010::22:18:56 ===

Bad value on output port 'tcp_inet'


> ** exception error: no match of right hand side value

                    {{protocol,thrift_binary_protocol,

                      {binary_protocol,

                       {transport,thrift_buffered_transport,

                        {buffered_transport,

                         {transport,thrift_socket_transport,

                          {data,#Port<0.2193>,infinity}},

                         []}},

                       true,true}},

                     {error,einval}}

     in function  thrift_client:send_function_call/3

     in call from thrift_client:call/3



I get the same error when i try to use the "batch_mutate" as follows:

> Mutation = #mutation{

column_or_supercolumn = #columnOrSuperColumn{

column = #column{name = "OBJID", value = N, timestamp = timestamp()}

}

},

Args = ["TEST",

dict:store(N,

dict:store("OBJ", [Mutation], dict:new()),

dict:new()),

?cassandra_ONE],

Response = thrift_client:call(State#state.connection, 'batch_mutate', Args),


thanks
pradeep