[Google Wave APIs] Re: Robot state persists
Adding to atc's info.For java appengine, one can use JDO or JPA to access appengine datastore. For JDO, first, create a JDO object by specifies the annotation. Then one can just call makePersistent() to persist the data. See http://code.google.com/appengine/docs/java/datastore/ Hope it helps. On Sun, Oct 18, 2009 at 10:32 AM, atc wrote: > > > > On Oct 18, 5:57 pm, Smola wrote: > > I need a way for information my robot gathers to persist. So, let's > > say I want to find a blip and save its ID so I can work with it in the > > future. I don't know how to do that currently. I know how to find > > the ID of a blip, but I do I save it for later use? Or, if I create > > an object in response to an event, how do I save all of the properties > > of that object as they are affected by more and more incoming blips? > > What language are you using? > > > Is the object automatically saved on the server when my robot is added > > to a wave and then stays there the rest of the time? It would seem > > that if waves are to exist forever in my archive that that would take > > up quite a bit of space down the road. > > > > The persistence probably comes from using the datastore provided by > Google App Engine. > > Provide a bit more information first and perhaps people can help. > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Google Wave API" group. To post to this group, send email to google-wave-api@googlegroups.com To unsubscribe from this group, send email to google-wave-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-wave-api?hl=en -~--~~~~--~~--~--~---
[Google Wave APIs] Re: Robot state persists
I apologize for my lack of information, though Mr. Nesting was able to help me despite my neglect. I am using the Java API so I suppose he either assumed that was what I am using or there is a similar API for Python. I have since gotten the hang of storing data using the setDataDocument method and then accessing that data with the appropriate related methods. Although I DO have a minor question. Would you or anyone else happen to know if there is a cap on the number of data documents I can store for a single wave? Or if there is a size cap? On Oct 18, 1:32 pm, atc wrote: > On Oct 18, 5:57 pm, Smola wrote: > > > I need a way for information my robot gathers to persist. So, let's > > say I want to find a blip and save its ID so I can work with it in the > > future. I don't know how to do that currently. I know how to find > > the ID of a blip, but I do I save it for later use? Or, if I create > > an object in response to an event, how do I save all of the properties > > of that object as they are affected by more and more incoming blips? > > What language are you using? > > > Is the object automatically saved on the server when my robot is added > > to a wave and then stays there the rest of the time? It would seem > > that if waves are to exist forever in my archive that that would take > > up quite a bit of space down the road. > > The persistence probably comes from using the datastore provided by > Google App Engine. > > Provide a bit more information first and perhaps people can help. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Google Wave API" group. To post to this group, send email to google-wave-api@googlegroups.com To unsubscribe from this group, send email to google-wave-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-wave-api?hl=en -~--~~~~--~~--~--~---
[Google Wave APIs] Re: Robot state persists
On Oct 18, 5:57 pm, Smola wrote: > I need a way for information my robot gathers to persist. So, let's > say I want to find a blip and save its ID so I can work with it in the > future. I don't know how to do that currently. I know how to find > the ID of a blip, but I do I save it for later use? Or, if I create > an object in response to an event, how do I save all of the properties > of that object as they are affected by more and more incoming blips? What language are you using? > Is the object automatically saved on the server when my robot is added > to a wave and then stays there the rest of the time? It would seem > that if waves are to exist forever in my archive that that would take > up quite a bit of space down the road. > The persistence probably comes from using the datastore provided by Google App Engine. Provide a bit more information first and perhaps people can help. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Google Wave API" group. To post to this group, send email to google-wave-api@googlegroups.com To unsubscribe from this group, send email to google-wave-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-wave-api?hl=en -~--~~~~--~~--~--~---
[Google Wave APIs] Re: Robot state persists
Java has built in methods to convert a class into data for storage, it works similar to the JSON that the robots receive. However, the java serialization classes I know of deal with binary data. You can probably use the json classes to serialize as a string (as they are already in your project for the robot to use), but the binary data will take up less space than textual, so it's better for the appengine data store. Here is a helper class I created to handle serialize/unserialize operations for storing in the app engine db. import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; public final class SerializeHelper { public static byte[] Serialize(Serializable obj) { ByteArrayOutputStream output = new ByteArrayOutputStream(); ObjectOutputStream objOut; try { objOut = new ObjectOutputStream(output); objOut.writeObject(obj); } catch (IOException e) { return null; } return output.toByteArray(); } public static Object Unserialize(byte[] data) { ByteArrayInputStream input = new ByteArrayInputStream(data); try { ObjectInputStream inpObj = new ObjectInputStream(input); try { return inpObj.readObject(); } catch (ClassNotFoundException e) { return null; } } catch (IOException e) { return null; } } } Any class you want to serialize must implement Serializable. Member variables and arrays will also be serialized as long as their types implement Serializable (I'm not sure what it does if they don't. I think it throws a run time error). For saving serialized classes to the appengine data store, use the Blob data type. Remember to be careful about changing the classes you want to serialize. The serializable interface does request you have public static final long serialVersionUID, but I have not looked into "updating" serialized classes if they change, nor have I had the case come up. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Google Wave API" group. To post to this group, send email to google-wave-api@googlegroups.com To unsubscribe from this group, send email to google-wave-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-wave-api?hl=en -~--~~~~--~~--~--~---
[Google Wave APIs] Re: Robot state persists
Very informative David, thank you! I just have one follow-up question: When you say, serialize, I imagine you mean to break down the object properties into key and value pairs. Would this serialization then be saved as a string? And do I use the same method as you mentioned before (setDataDocument) to store that string to the wavelet? This seems like a great solution to my problem and I appreciate any more help you can give! Smola On Oct 18, 1:39 pm, David Nesting wrote: > On Sun, Oct 18, 2009 at 9:57 AM, Smola wrote: > > I need a way for information my robot gathers to persist. So, let's > > say I want to find a blip and save its ID so I can work with it in the > > future. I don't know how to do that currently. I know how to find > > the ID of a blip, but I do I save it for later use? Or, if I create > > You can either persist your data to the wave itself (e.g. > wavelet.setDataDocument), or, since your robot is certainly implemented > using appengine, use the appengine datastore. > > an object in response to an event, how do I save all of the properties > > > of that object as they are affected by more and more incoming blips? > > Serializing the object and storing it either with the wavelet, or in a > datastore, would seem like fine solutions to that problem. > > > Is the object automatically saved on the server when my robot is added > > to a wave and then stays there the rest of the time? It would seem > > that if waves are to exist forever in my archive that that would take > > up quite a bit of space down the road. > > If you store your state with the wavelet, it stays with the wavelet and > disappears only when the wavelet disappears. Since it's not taking up space > in your own datastore, you don't have to worry about managing it. On the > other hand, if you'd rather store this in your own datastore, you'll need to > clean up your data on your own (the blip_deleted event might be useful), but > yes, I would imagine that this would grow as the number of waves your robot > participates in grows. > > David --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Google Wave API" group. To post to this group, send email to google-wave-api@googlegroups.com To unsubscribe from this group, send email to google-wave-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-wave-api?hl=en -~--~~~~--~~--~--~---
[Google Wave APIs] Re: Robot state persists
On Sun, Oct 18, 2009 at 9:57 AM, Smola wrote: > I need a way for information my robot gathers to persist. So, let's > say I want to find a blip and save its ID so I can work with it in the > future. I don't know how to do that currently. I know how to find > the ID of a blip, but I do I save it for later use? Or, if I create > You can either persist your data to the wave itself (e.g. wavelet.setDataDocument), or, since your robot is certainly implemented using appengine, use the appengine datastore. an object in response to an event, how do I save all of the properties > of that object as they are affected by more and more incoming blips? > Serializing the object and storing it either with the wavelet, or in a datastore, would seem like fine solutions to that problem. > Is the object automatically saved on the server when my robot is added > to a wave and then stays there the rest of the time? It would seem > that if waves are to exist forever in my archive that that would take > up quite a bit of space down the road. > If you store your state with the wavelet, it stays with the wavelet and disappears only when the wavelet disappears. Since it's not taking up space in your own datastore, you don't have to worry about managing it. On the other hand, if you'd rather store this in your own datastore, you'll need to clean up your data on your own (the blip_deleted event might be useful), but yes, I would imagine that this would grow as the number of waves your robot participates in grows. David --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Google Wave API" group. To post to this group, send email to google-wave-api@googlegroups.com To unsubscribe from this group, send email to google-wave-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-wave-api?hl=en -~--~~~~--~~--~--~---