Return-Path: Delivered-To: apmail-cassandra-user-archive@www.apache.org Received: (qmail 40459 invoked from network); 6 May 2010 13:35:27 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 6 May 2010 13:35:27 -0000 Received: (qmail 57670 invoked by uid 500); 6 May 2010 13:35:27 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 57597 invoked by uid 500); 6 May 2010 13:35:26 -0000 Mailing-List: contact user-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cassandra.apache.org Delivered-To: mailing list user@cassandra.apache.org Received: (qmail 57589 invoked by uid 99); 6 May 2010 13:35:26 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 May 2010 13:35:26 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of bogghed@codemate.se designates 209.85.161.44 as permitted sender) Received: from [209.85.161.44] (HELO mail-fx0-f44.google.com) (209.85.161.44) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 May 2010 13:35:17 +0000 Received: by fxm4 with SMTP id 4so5569315fxm.31 for ; Thu, 06 May 2010 06:34:56 -0700 (PDT) Received: by 10.223.56.206 with SMTP id z14mr6726286fag.97.1273152896185; Thu, 06 May 2010 06:34:56 -0700 (PDT) Received: from [10.0.20.31] ([212.112.180.50]) by mx.google.com with ESMTPS id h2sm2037052fkh.55.2010.05.06.06.34.54 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 06 May 2010 06:34:55 -0700 (PDT) From: Erik Bogghed Mime-Version: 1.0 (Apple Message framework v1078) Content-Type: multipart/alternative; boundary=Apple-Mail-18-640433477 Subject: Re: Batch mutate doesn't work Date: Thu, 6 May 2010 15:34:53 +0200 In-Reply-To: To: user@cassandra.apache.org References: Message-Id: <1A9FF2EF-8476-48E4-A30F-FBF22A744F44@codemate.se> X-Mailer: Apple Mail (2.1078) X-Virus-Checked: Checked by ClamAV on apache.org --Apple-Mail-18-640433477 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii 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}]}}} --Apple-Mail-18-640433477 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii MutationMap =3D dict:store(Key,
dict:store("KeyValue",
= [
#mutation = {column_or_supercolumn =3D 
= #columnOrSuperColumn {column =3D 
= #column {name =3D "property", value=3D"value", timestamp =3D 2}}}
= ], dict:new()),
dict:new()),



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} =3D = thrift_client:start_link("127.0.0.1",9160, cassandra_thrift),

= Key =3D "Key1",

%
% set first property
%
= thrift_client:call( C,
=             &n= bsp;    'insert',
=             &n= bsp;    [ "Keyspace1",
=             &n= bsp;      Key,
=             &n= bsp;      #columnPath{column_family=3D"KeyVa= lue", column=3D"value"},
=             &n= bsp;      "value1",
=             &n= bsp;      1,
=             &n= bsp;      1
=             &n= bsp;      ] ),

%
% set second = property ( fails! - why? )
%
MutationMap =3D
{
=   Key,
  {
=     <<"KeyValue">>,
=     [
=       #mutation{
=         column_or_supercolumn =3D = #column{ name =3D "property" , value =3D
"value" , timestamp =3D 2 = }
      }
=     ]
  }
},
= thrift_client:call( C,
  'batch_mutate',
  [ = "Keyspace1",
     MutationMap,
=      1
  ] )

: The error = returned is :

** exception exit: = {bad_return_value,{error,{function_clause,[{dict,size,
=             &n= bsp;           &nbs= p;            =             &n= bsp;           &nbs= p;    [{"Key1",

{<<"KeyValue">>,
[{mutation,{column,"property","value",2},undefined}]}}]},

{thr= ift_protocol,write,2},

{thrift_protocol,struct_write_loop,3},
{thrift_protocol,write,2},

{thrift_client,send_function_call,3},<= br>
{thrift_client,'-handle_call/3-fun-0-',3},

{thrift_client,ca= tch_function_exceptions,2},

{thrift_client,handle_call,3}]}}}
7&= gt;
=3DERROR REPORT=3D=3D=3D=3D 30-Apr-2010::15:13:42 =3D=3D=3D
** = Generic server <0.55.0> terminating
** Last message in was = {call,batch_mutate,
=             &n= bsp;           &nbs= p;["Keyspace1",
=             &n= bsp;           &nbs= p; {"Key1",
=             &n= bsp;           &nbs= p;  {<<"KeyValue">>,
=             &n= bsp;           &nbs= p;   [{mutation,
=             &n= bsp;           &nbs= p;        {column,"property","valu= e",2},
=             &n= bsp;           &nbs= p;        undefined}]}},
=             &n= bsp;           &nbs= p; 1]}
** When Server state =3D=3D {state,cassandra_thrift,
=             &n= bsp;          {protocol,= thrift_binary_protocol,
=             &n= bsp;           {bin= ary_protocol,
=             &n= bsp;           &nbs= p;{transport,thrift_buffered_transport,<0.58.0>},
=             &n= bsp;           &nbs= p;true,true}},
=             &n= bsp;          0}
** = Reason for termination =3D=3D
** {bad_return_value,
=      {error,
=          {function_clause, =             &n= bsp;[{dict,size,
=             &n= bsp;     [{"Key1",
=             &n= bsp;       {<<"KeyValue">>,=
=             &n= bsp;        [{mutation,
=             &n= bsp;           &nbs= p; {column,"property","value",2},
=             &n= bsp;           &nbs= p; undefined}]}}]},
=             &n= bsp; {thrift_protocol,write,2},
=             &n= bsp; {thrift_protocol,struct_write_loop,3},
=             &n= bsp; {thrift_protocol,write,2},
=             &n= bsp; {thrift_client,send_function_call,3},
=             &n= bsp; {thrift_client,'-handle_call/3-fun-0-',3},
=             &n= bsp; {thrift_client,catch_function_exceptions,2},
=             &n= bsp; {thrift_client,handle_call,3}]}}}
= --Apple-Mail-18-640433477--