loading erlang terms

Charles Blair chas at uchicago.edu
Wed Oct 27 18:03:20 EDT 2010


Thanks, all. 

I think my issues at this time boil down to a difference between how I
can interact with a running riak system using the shell in riak-admin
attach, and using another shell to contact the running system. So, for
example, following the README file, this works fine (shell prompts
omitted):

RiakNode = 'riak at 123.456.78.90'.
{ok, C} = riak:client_connect(RiakNode).
{ok, Terms} = file:consult("/path/to/file").
Term = hd(Terms).  
Object = riak_object:new(<<"oai_test">>, <<"AEP-WYS97">>, Term).
C:put(Object,1).   
{ok, O} = C:get(<<"oai_test">>, <<"AEP-WYS97">>, 1).
V = riak_object:get_value(O).  
V.
{oai_dc,"AEP-WYS97",
        {{2004,10,28},{17,21,25}},
        ["aep"],
        "/storage/aep2003/metadata/oai_dc/oai_dc-AEP-WYS97.xml"}
element(2, V).
"AEP-WYS97"

The above proves that I can put and get an erlang term.

Now let's try this:

erl -pa /usr/local/riak-0.13.0/rel/riak/lib/riak_core-0.13.0/ebin /usr/local/riak-0.13.0/rel/riak/lib/riak_kv-0.13.0/ebin /usr/local/riak-0.13.0/rel/riak/lib/riakc-1.0.1/ebin /usr/local/riak-0.13.0/rel/riak/lib/protobuffs-0.5.0/ebin

1> {ok,Pid} = riakc_pb_socket:start_link("128.135.53.253", 8087).
{ok,<0.33.0>}
2> {ok, C} = riakc_pb_socket:get(Pid, <<"people">>, <<"chas">>).
{ok,{riakc_obj,<<"people">>,<<"chas">>,
               <<107,206,97,96,96,96,204,96,202,5,82,44,236,70,107,239,
                 100,48,37,50,230,177,50,...>>,
               [{{dict,3,16,16,8,80,48,
                       {[],[],[],[],[],[],[],[],[],[],[],[],...},
                       {{[],[],[],[],[],[],[],[],[],[],...}}},
                 <<"Charles Blair">>}],
               undefined,undefined}}
3> {ok, C} = riakc_pb_socket:get(Pid, <<"oai_test">>,
<<"AEP-WYS97">>).

=ERROR REPORT==== 27-Oct-2010::16:34:48 ===
** Generic server <0.33.0> terminating
** Last message in was {tcp_closed,#Port<0.913>}
** When Server state ==
{state,"128.135.53.253",8087,false,false,undefined,
                               undefined,
                               {[],[]},
                               1,[],100}
** Reason for termination ==
** disconnected
** exception exit: disconnected
4> 

In step 2 I can retrieve a key whose value is a string. In step 3, I
fail to retrieve the value. But this is the value that I successfully
put and fetched up above. I have failed to put this value from a script.

The record types returned by the riak-attached shell, and a remote
shell are not the same.

C:get(<<"people">>, <<"chas">>, 1).       
{ok,{r_object,<<"people">>,<<"chas">>,
              [{r_content,{dict,5,16,16,8,80,48,
                                {[],[],[],[],[],[],[],[],[],[],[],[],...},
                                {{[],[],[[<<"Links">>]],[],[],[],[],[],[],[],...}}},
                          <<"Charles Blair">>}],
              [{<<7,50,173,220>>,{1,63455400780}}],
              {dict,1,16,16,8,80,48,
                    {[],[],[],[],[],[],[],[],[],[],[],[],[],...},
                    {{[],[],[],[],[],[],[],[],[],[],[],...}}},
              undefined}}


riakc_pb_socket:get(Pid, <<"people">>, <<"chas">>).
{ok,{riakc_obj,<<"people">>,<<"chas">>,
               <<107,206,97,96,96,96,204,96,202,5,82,44,236,70,107,239,
                 100,48,37,50,230,177,50,...>>,
               [{{dict,3,16,16,8,80,48,
                       {[],[],[],[],[],[],[],[],[],[],[],[],...},
                       {{[],[],[],[],[],[],[],[],[],[],...}}},
                 <<"Charles Blair">>}],
               undefined,undefined}}




More information about the riak-users mailing list