Hi Konstantin,

   I attempted to reproduce, but am unable to, I used this code

-module(test_cassandra_client).

-export([my_test/0]).

-include("cassandra_types.hrl").

my_test() ->
  {ok, Client0} =
    thrift_client_util:new ("127.0.0.1", 9160,
                            cassandra_thrift, [{framed,true}]),
        
  D0 = dict:new(),
  Auth =
    #authenticationRequest {
      credentials = dict:store ("dilbert","nomoovertime",D0)
    },
  {Client1, {ok,ok}} =
    thrift_client:call (Client0, login, [Auth]),
  {Client2, {ok,ok}} =
    thrift_client:call (Client1, set_keyspace, ["Keyspace1"]),
  lists:foldl ( fun (I, C0) ->
                  X = integer_to_list (I),
                  {C1, {ok,ok}} =
                    thrift_client:call (C0,
                                        insert,
                                        [ lists:append (["key",X]),
                                          #columnParent {
                                            column_family="Standard1"
                                          },
                                          #column {
                                            name = lists:append (["name",X]),
                                            value = lists:append (["val",X]),
                                            timestamp = 1
                                          },
                                          ?cassandra_ConsistencyLevel_ONE
                                        ]),
                  C1
                end,
                Client2,                
                lists:seq(1,1000) ).    

To just insert 1000 entries into the schema defined in schema-sample.txt,
and everything seems to work fine.  If you could provide a failing test
it would allow me to dig a little deeper.

Thanks,

-Anthony


On Tue, Jun 21, 2011 at 10:03:27AM -0500, Konstantin  Naryshkin wrote:
> I am new to both Thrift and Erlang but need to uses Thrift to get an Erlang 
> application to write to Cassandra. The relevant method from cassandra.thrift 
> is: 
> void insert(1:required binary key, 
> 2:required ColumnParent column_parent, 
> 3:required Column column, 
> 4:required ConsistencyLevel consistency_level=ConsistencyLevel.ONE) 
> throws (1:InvalidRequestException ire, 2:UnavailableException ue, 
> 3:TimedOutException te), 
> 
> The full cassandra.thrift can be found at: 
> https://svn.apache.org/repos/asf/cassandra/tags/cassandra-0.8.0/interface/cassandra.thrift
>  
> 
> I am trying to run the following command via the erl cli: 
> {C30,R30} =thrift_client:call( C29, 'insert', [ "keyz", ColPar1, Col4, 6]).). 
> 
> Where C29 is a #tclient returned by a previous call, ColPar1 is a 
> #columnParent, and Col4 is a #column. The call throws a badarg exception of: 
> ** exception error: bad argument 
> in function iolist_size/1 
> called as iolist_size([[[[[[[[[[[[[[[[[[[[[[[[[[[],<<128,...>>],<<0,0,...>>], 
> <<"insert">>], 
> <<0,0,0,0>>], 
> <<"\v">>], 
> <<0,1>>], 
> <<0,0,0,4>>], 
> <<"keyz">>], 
> <<"\f">>], 
> <<0,2>>], 
> <<"\v">>], 
> <<0,3>>], 
> <<0,0,0,10>>], 
> <<"ipdr_usage">>], 
> <<"\v">>], 
> <<0,4>>], 
> <<0,0,0,5>>], 
> <<"suppy">>], 
> <<0>>], 
> <<"\f">>], 
> <<0,3>>], 
> {{struct,[{1,string},{2,string},{3,i64}]}, 
> #column{name = <<"haha">>,value = <<"0_0">>, 
> timestamp = 1235234234234234234,ttl = undefined}}], 
> <<"\b">>], 
> <<0,4>>], 
> <<0,0,0,6>>], 
> <<0>>]) 
> in call from thrift_framed_transport:flush/1 
> in call from thrift_transport:flush/1 
> in call from thrift_binary_protocol:flush_transport/1 
> in call from thrift_protocol:flush_transport/1 
> in call from thrift_client:send_function_call/3 
> in call from thrift_client:call/3 
> 
> Any idea about what I may be doing wrong? Is there any information that I 
> forgot to include? 
> 
> Thanks in advance, 
> 
> Konstantin 

-- 
------------------------------------------------------------------------
Anthony Molinaro                           <[email protected]>

Reply via email to