[google-appengine] Re: Datastore update without read

2011-10-12 Thread Tomas
Thanks guys, it really helps!

I didn't know about protobuf - thought that u have massive key/value
map (so it would be possible to just touch one key). Now it all make
sense :)

On Oct 12, 1:22 pm, Ikai Lan (Google) ika...@google.com wrote:
 Thanks Murph. That explanation was dead-on and I couldn't have written a
 better one myself!

 You can't just update one column. You're still thinking in RDBMS mode.
 There is no concept of a column, since to update a property, we need to read
 the entire entity, deserialize it (it's serialized as protobuf; at its
 lowest layer BigTable is a key-value store), change the property,
 reserialize the entire entity and write it.

 --
 Ikai Lan
 Developer Programs Engineer, Google App Engine
 plus.ikailan.com | twitter.com/ikai







 On Tue, Oct 11, 2011 at 2:38 PM, Murph paul.j.mu...@googlemail.com wrote:
  You can't update just a single property/attribute of an entity unless you
  already know the values for all of the others.  If it's frequently updated,
  careful use of memcache may allow you to avoid the db.get, but otherwise you
  have to read it first.

  An alternative, if you just have say 1 property/attribute which changes
  often would be to split the entity into two separate entity models, one with
  the relatively static data, and the other with the frequently changing
  data.  The downside there, of course, is that you're going to have 2 db.get
  operations when you need all of it, instead of 1.

  Internally, the datastore is entirely composed of (key, value) pairs, with
  a single (key,value) per entity (not counting indices, metadata, etc), and
  the SDK encodes/decodes those values into your entity models for you.  They
  are actually encoded as protobufs, but there's nothing in the datastore's
  API to modify that data without reading it first.

   --
  You received this message because you are subscribed to the Google Groups
  Google App Engine group.
  To view this discussion on the web visit
 https://groups.google.com/d/msg/google-appengine/-/e6JrqffTES4J.

  To post to this group, send email to google-appengine@googlegroups.com.
  To unsubscribe from this group, send email to
  google-appengine+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/google-appengine?hl=en.

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



[google-appengine] Re: Datastore update without read

2011-10-11 Thread Gerald Tan
You don't even have to do a key fetch beforehand, you can simply persist a 
new entity with the same key and it will overwrite the existing entity in 
the datastore.

-- 
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-appengine/-/1PmldOgotYYJ.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.



[google-appengine] Re: Datastore update without read

2011-10-11 Thread Tomas
Yeah, but I need to UPDATE one attribute of existing entity (not
overwrite the whole entity).

On Oct 12, 9:55 am, Gerald Tan woefulwab...@gmail.com wrote:
 You don't even have to do a key fetch beforehand, you can simply persist a
 new entity with the same key and it will overwrite the existing entity in
 the datastore.

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



[google-appengine] Re: Datastore update without read

2011-10-11 Thread Murph
You can't update just a single property/attribute of an entity unless you 
already know the values for all of the others.  If it's frequently updated, 
careful use of memcache may allow you to avoid the db.get, but otherwise you 
have to read it first.

An alternative, if you just have say 1 property/attribute which changes 
often would be to split the entity into two separate entity models, one with 
the relatively static data, and the other with the frequently changing 
data.  The downside there, of course, is that you're going to have 2 db.get 
operations when you need all of it, instead of 1.

Internally, the datastore is entirely composed of (key, value) pairs, with a 
single (key,value) per entity (not counting indices, metadata, etc), and the 
SDK encodes/decodes those values into your entity models for you.  They are 
actually encoded as protobufs, but there's nothing in the datastore's API to 
modify that data without reading it first.

-- 
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-appengine/-/e6JrqffTES4J.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.



Re: [google-appengine] Re: Datastore update without read

2011-10-11 Thread Ikai Lan (Google)
Thanks Murph. That explanation was dead-on and I couldn't have written a
better one myself!

You can't just update one column. You're still thinking in RDBMS mode.
There is no concept of a column, since to update a property, we need to read
the entire entity, deserialize it (it's serialized as protobuf; at its
lowest layer BigTable is a key-value store), change the property,
reserialize the entire entity and write it.

--
Ikai Lan
Developer Programs Engineer, Google App Engine
plus.ikailan.com | twitter.com/ikai



On Tue, Oct 11, 2011 at 2:38 PM, Murph paul.j.mu...@googlemail.com wrote:

 You can't update just a single property/attribute of an entity unless you
 already know the values for all of the others.  If it's frequently updated,
 careful use of memcache may allow you to avoid the db.get, but otherwise you
 have to read it first.

 An alternative, if you just have say 1 property/attribute which changes
 often would be to split the entity into two separate entity models, one with
 the relatively static data, and the other with the frequently changing
 data.  The downside there, of course, is that you're going to have 2 db.get
 operations when you need all of it, instead of 1.

 Internally, the datastore is entirely composed of (key, value) pairs, with
 a single (key,value) per entity (not counting indices, metadata, etc), and
 the SDK encodes/decodes those values into your entity models for you.  They
 are actually encoded as protobufs, but there's nothing in the datastore's
 API to modify that data without reading it first.

  --
 You received this message because you are subscribed to the Google Groups
 Google App Engine group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/google-appengine/-/e6JrqffTES4J.

 To post to this group, send email to google-appengine@googlegroups.com.
 To unsubscribe from this group, send email to
 google-appengine+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/google-appengine?hl=en.


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