[appengine-java] Re: protobuf storage with JDO

2010-10-15 Thread l.denardo
Hello, I think it's not so common.

In my project I use protobufs for objects I want to store as
serialized fields or in bynary form.
That is, I encapsulate protocol buffer building in a wrapper, then
store such wrapper in an annotated field of JDO.

@Persistent(Serialized = "true")
private MyProtobufWrapper wrapper;

MyProtobufWrapper uses protocol buffer Builder in its writeObject /
readObject methods and is of course Serializable.

OR

@Persistent
Blob serializedObject;

and use a class MyProtobufAdapter which has two methods byte[]
convertToSerialized(MyObjet o) and MyObject deserialize(byte[] bytes).

I think this is useful if you want to convert data you share with your
client code, or if you hit limitations in datastore modeling that you
can't work around. And obviously if you don't need to index such data
for queries.
Otherwise I'll go with regular datastore fields.

Regards
Lorenzo


On Oct 15, 12:29 am, "Guillaume B." 
wrote:
> Hello,
>
> I make a basic application that store simple java object using objectify
>
> I also make a spring service that create and return protobuf object
>
> as the protobuf object is nearly the same that the object that I store
> in "big table"
> I wonder if there was a standard way to store protobuf object in the
> datastore
>
> as objectify and JDO use annotation and that I will not anoted
> generated protobuf object
> perhaps someone as a sample / tutorial of the AddressBook protobuf in
> appengine that store object in the datastore

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Re: protobuf storage with JDO

2010-10-18 Thread l.denardo
I agree.
Using protocol buffers directly is not necessary (btw datastore should
use them internally, as Nick Johnson explains here:
http://blog.notdot.net/2010/09/Under-the-hood-with-App-Engine-APIs).

Use them only if usual datastore APIs don't satisfy your needs and you
have to resort to serialized objects. In that case protocol buffers
give you a maintainable data structure, otherwise using datastore APIs
is certainly the best way to go.

Regards
Lorenzo

On Oct 16, 7:39 pm, Jeff Schnitzer  wrote:
> On Fri, Oct 15, 2010 at 11:44 PM, Guillaume B.
>
>  wrote:
>
> > perhaps this is an useless question and the best way to do would take me a
> > lot of time for just a small performance gain
>
> I think this is your answer right here.  Don't optimize prematurely -
> build your app as quickly as possible and then find out where the real
> bottlenecks are with appstats.
>
> Jeff

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.