Not a problem. The root cause is this code:

public RiakObject(string bucket, string key, object value)
: this(bucket, key, value.ToJson(), RiakConstants.ContentTypes.
ApplicationJson)

When you create without a content type, we make the assumption that you're
saving JSON (rather foolishly, it turns out). CorrugatedIron runs down the
path of converting your object to JSON and then, once you modify the
content type, does the wrong thing.

Internally, there's no object state stored in a RiakObject - we immediately
convert your object to a byte array for saving to Riak. This could probably
solved in a better way by having a RiakObject<T>, and be less confusing for
you in the long run.

In the mean time, you can do one of a few things:

var ro = new RiakObject(bucket, key, testObj, RiakConstants.ContentTypes.
ProtocolBuffers);

*/* or */*
var ro = new RiakObject(bucket, key);
ro.ContentType = RiakConstants.ContentTypes.ProtocolBuffers;
ro.SetObject(testObj);

*/* or */*
var ro = new RiakObject(bucket, key);
ro.SetObject(testObj, RiakConstants.ContentTypes.ProtocolBuffers);



---
Jeremiah Peschka - Founder, Brent Ozar Unlimited
MCITP: SQL Server 2008, MVP
Cloudera Certified Developer for Apache Hadoop


On Wed, Sep 11, 2013 at 12:19 PM, Alex Rice <a...@mindlube.com> wrote:

> Thanks again Jeremiah! And thanks for writing corrugatediron so far
> it's a real pleasure to work with this Riak client lib!
>
> On Wed, Sep 11, 2013 at 1:02 PM, Jeremiah Peschka
> <jeremiah.pesc...@gmail.com> wrote:
> > Howdy Alex,
> >
> > That shouldn't be happening. I've created an issue and I'll check into
> it as
> > soon as I get a chance. You can track the issue here
> > https://github.com/DistributedNonsense/CorrugatedIron/issues/171
> >
> > ---
> > Jeremiah Peschka - Founder, Brent Ozar Unlimited
> > MCITP: SQL Server 2008, MVP
> > Cloudera Certified Developer for Apache Hadoop
> >
> >
> > On Wed, Sep 11, 2013 at 11:53 AM, Alex Rice <a...@mindlube.com> wrote:
> >>
> >> Is there a way to trick corrugatediron into serializing a protobuf
> >> class for me? I know I can serialize it to byte[] myself and Put that.
> >> But I thought setting the ContentType might do the trick, but it looks
> >> like it's getting saved as JSON instead. This might be a convenient
> >> feature to add.
> >>
> >> // create a proto-contract class
> >> (https://code.google.com/p/protobuf-net/wiki/GettingStarted)
> >> var testObj = new Person() {
> >>                     Id = 42,
> >>                     Name = "alex",
> >>                     Address =  new Address() {
> >>                         Line1 = "16 dusty road",
> >>                         Line2 = "santa fe, nm 87508"
> >> }};
> >> var riakObj = new RiakObject("test", "key", testObj);
> >> riakObj.ContentType = RiakConstants.ContentTypes.ProtocolBuffers;
> >> db.Put( riakObj );
> >>
> >> _______________________________________________
> >> riak-users mailing list
> >> riak-users@lists.basho.com
> >> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
> >
> >
> >
> > _______________________________________________
> > riak-users mailing list
> > riak-users@lists.basho.com
> > http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
> >
>
> _______________________________________________
> riak-users mailing list
> riak-users@lists.basho.com
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>
_______________________________________________
riak-users mailing list
riak-users@lists.basho.com
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to