Try this. You need to use the dict module. MutationMap = dict:store(Key, dict:store("KeyValue", [ #mutation {column_or_supercolumn = #columnOrSuperColumn {column = #column {name = "property", value="value", timestamp = 2}}} ], dict:new()), dict:new()),
Erik On 30 apr 2010, at 15.58, Zubair Quraishi wrote: > I have the following code in Erlang to set a value and then add a > property. The first set works but the mutate fails. Can anyone > enlighten me? > Thanks > > {ok, C} = thrift_client:start_link("127.0.0.1",9160, cassandra_thrift), > > Key = "Key1", > > % > % set first property > % > thrift_client:call( C, > 'insert', > [ "Keyspace1", > Key, > #columnPath{column_family="KeyValue", column="value"}, > "value1", > 1, > 1 > ] ), > > % > % set second property ( fails! - why? ) > % > MutationMap = > { > Key, > { > <<"KeyValue">>, > [ > #mutation{ > column_or_supercolumn = #column{ name = "property" , value = > "value" , timestamp = 2 } > } > ] > } > }, > thrift_client:call( C, > 'batch_mutate', > [ "Keyspace1", > MutationMap, > 1 > ] ) > > : The error returned is : > > ** exception exit: {bad_return_value,{error,{function_clause,[{dict,size, > [{"Key1", > > {<<"KeyValue">>, > > [{mutation,{column,"property","value",2},undefined}]}}]}, > > {thrift_protocol,write,2}, > > {thrift_protocol,struct_write_loop,3}, > > {thrift_protocol,write,2}, > > {thrift_client,send_function_call,3}, > > {thrift_client,'-handle_call/3-fun-0-',3}, > > {thrift_client,catch_function_exceptions,2}, > > {thrift_client,handle_call,3}]}}} > 7> > =ERROR REPORT==== 30-Apr-2010::15:13:42 === > ** Generic server <0.55.0> terminating > ** Last message in was {call,batch_mutate, > ["Keyspace1", > {"Key1", > {<<"KeyValue">>, > [{mutation, > {column,"property","value",2}, > undefined}]}}, > 1]} > ** When Server state == {state,cassandra_thrift, > {protocol,thrift_binary_protocol, > {binary_protocol, > {transport,thrift_buffered_transport,<0.58.0>}, > true,true}}, > 0} > ** Reason for termination == > ** {bad_return_value, > {error, > {function_clause, > [{dict,size, > [{"Key1", > {<<"KeyValue">>, > [{mutation, > {column,"property","value",2}, > undefined}]}}]}, > {thrift_protocol,write,2}, > {thrift_protocol,struct_write_loop,3}, > {thrift_protocol,write,2}, > {thrift_client,send_function_call,3}, > {thrift_client,'-handle_call/3-fun-0-',3}, > {thrift_client,catch_function_exceptions,2}, > {thrift_client,handle_call,3}]}}}