riak-erlang-client serverside clarification

Sean Cribbs sean at basho.com
Thu Mar 1 11:53:33 EST 2012


Hi Senthilkumar,

Because the PB client is connecting to a language-agnostic interface, it
makes sense that it will only store binary data as the value.  In general,
it's better not to rely on the fact that your value is Erlang terms, but to
assume Riak will treat the value opaquely, as a binary.  Calling
binary_to_term in your MapReduce (of course, making a guard or check for
existing values that are terms) should not be too onerous. e.g.

ensure_terms(Bin) when is_binary(Bin) ->
  binary_to_term(Bin);
ensure_terms(T) -> T.

Then as the first part of each map function you could do

Value = ensure_terms(riak_object:get_value(Obj)),

I hope that helps!

On Wed, Feb 29, 2012 at 11:23 PM, Senthilkumar Peelikkampatti <
senthilkumar.peelikkampatti at gmail.com> wrote:

> I am using currently erlang native client and it is working beautifully so
> far. I wanted to move it to pb client due to
> 1. it is kind of pain to update relevant binaries
> 2. bidirectional network connection with riak  nodes and my application
> nodes and associated load etc to the system
> 3. dependency of config like erl riak cookie etc
>
> But In my preliminary study, found that,
>
> a) PB client always sends value as binary
> b) PB server always stores the value as such no matter what kind of
> content type set ex. "application/x-erlang-term"
>
> And item (b) is problem for me because my entire app has may MR queries
> and other object retrieval which directly consumes erlang terms. So I need
> to go everywhere (though, It is just one DB module and another module with
> many M-R functions) to change the binary to term or should I tweek
> riakc_pb:erlify_rpbcontent to convert binary to term and store it -- may be
> based on Content-Type?  This sounds ugly but I just need to change it only
> once without affecting my entire code base. If I do so, wherever I get the
> object from Riak, I no need to convert it, it saves unnecessary decoding
> also.
>
> PB binaries stored in riak also affect the riak:local client retrieval
> where we can get the object and see it in plain without doing
> binary_to_term.
>
>
> My app is webmachine erlang web app.
>
> Thoughts?
>
> Thanks,
> --Senthilkumar Peelikkampatti.
>
>
>
>
> _______________________________________________
> riak-users mailing list
> riak-users at lists.basho.com
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>
>


-- 
Sean Cribbs <sean at basho.com>
Software Engineer
Basho Technologies, Inc.
http://basho.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20120301/beaa6d06/attachment.html>


More information about the riak-users mailing list