riak-erlang-client serverside clarification
senthilkumar.peelikkampatti at gmail.com
Thu Mar 1 14:29:11 EST 2012
Thanks for the response. I considered below option before coming to
this forum but my question is only riak put needs conversion from binary to
term and other places in my application, app consumes pure erlang term
including MR. It is going to be huge benefit for my app to stay consuming
term directly out of riak.
I understand the issue with PB server as it needs to cater to various
different client but Content-Type meta data would make this conversion
seamless. If riak has no plan to introduce conversion layer (though it is
not big deal as already relevant information available in hand for riak pb)
into riak in funture,
1. is it good to introduce precommit hook to convert object? Or
2. does Riak support "overlay" (similar to MR funtions) to drop
converter module into riak?
3. Is it good to touch PB layer to modify as per my need? -- this seems
very invasive as I need to propagate this changes to every environment and
every dev systems
On Thu, Mar 1, 2012 at 10:53 AM, Sean Cribbs <sean at basho.com> wrote:
> 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) ->
> 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
>> 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
>> My app is webmachine erlang web app.
>> --Senthilkumar Peelikkampatti.
>> riak-users mailing list
>> riak-users at lists.basho.com
> Sean Cribbs <sean at basho.com>
> Software Engineer
> Basho Technologies, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the riak-users