[appengine-java] Re: deleting all entries in datastore

2010-01-22 Thread Locke
It would be good to have the ability to do this from within the GUI.
Other database management tools have empty table options, so a
delete all of this Kind feature would be appropriate.


On Jan 22, 12:59 pm, John Patterson jdpatter...@gmail.com wrote:
 Here is the code I use to delete one kind at a time - it batches the  
 keys into Lists of 100 to avoid datastore exceptions.  Iterables is  
 from Google collections.

                                         Query query = new Query(kind);
                                         query.setKeysOnly();
                                         DatastoreService datastore = ...
                                         IterableEntity entityIterator =  
 datastore.prepare(query).asIterable();
                                         IterableKey keyIterator = 
 Iterables.transform(entityIterator,  
 new FunctionEntity, Key()
                                         {
                                                 public Key apply(Entity arg0)
                                                 {
                                                         return arg0.getKey();
                                                 }
                                         });

                                         IterableListKey partitioned =  
 Iterables.partition(keyIterator, 100);
                                         for (ListKey sublist : partitioned)
                                         {
                                                 datastore.delete(sublist);
                                         }

 On 22 Jan 2010, at 15:10, mete wrote:



  Suppose I have a class A and I have stored some instance of it in the
  datastore. Then I change it, but I keep the name. How I can delete all
  the previous data in the datastore, if I simply do a query and use
  deleteAll, it gives an error (I guess because I changed the name of
  some fields). Thank you.

  Mete

  --
  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-java@googlegroups.com
  .
  To unsubscribe from this group, send email to 
  google-appengine-java+unsubscr...@googlegroups.com
  .
  For more options, visit this group 
  athttp://groups.google.com/group/google-appengine-java?hl=en
  .

-- 
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: deleting all entries in datastore

2010-01-22 Thread mete
Yes it would be very nice to have GUI support for this. I will try the
code John thank you.

Mete

On Jan 22, 8:47 pm, Locke locke2...@gmail.com wrote:
 It would be good to have the ability to do this from within the GUI.
 Other database management tools have empty table options, so a
 delete all of this Kind feature would be appropriate.

 On Jan 22, 12:59 pm, John Patterson jdpatter...@gmail.com wrote:



  Here is the code I use to delete one kind at a time - it batches the  
  keys into Lists of 100 to avoid datastore exceptions.  Iterables is  
  from Google collections.

                                          Query query = new Query(kind);
                                          query.setKeysOnly();
                                          DatastoreService datastore = ...
                                          IterableEntity entityIterator =  
  datastore.prepare(query).asIterable();
                                          IterableKey keyIterator = 
  Iterables.transform(entityIterator,  
  new FunctionEntity, Key()
                                          {
                                                  public Key apply(Entity 
  arg0)
                                                  {
                                                          return 
  arg0.getKey();
                                                  }
                                          });

                                          IterableListKey partitioned =  
  Iterables.partition(keyIterator, 100);
                                          for (ListKey sublist : 
  partitioned)
                                          {
                                                  datastore.delete(sublist);
                                          }

  On 22 Jan 2010, at 15:10, mete wrote:

   Suppose I have a class A and I have stored some instance of it in the
   datastore. Then I change it, but I keep the name. How I can delete all
   the previous data in the datastore, if I simply do a query and use
   deleteAll, it gives an error (I guess because I changed the name of
   some fields). Thank you.

   Mete

   --
   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-java@googlegroups.com
   .
   To unsubscribe from this group, send email to 
   google-appengine-java+unsubscr...@googlegroups.com
   .
   For more options, visit this group 
   athttp://groups.google.com/group/google-appengine-java?hl=en
   .

-- 
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: deleting all entries in datastore

2010-01-22 Thread Larry Cable
+1 especially for large tables

On Jan 22, 10:47 am, Locke locke2...@gmail.com wrote:
 It would be good to have the ability to do this from within the GUI.
 Other database management tools have empty table options, so a
 delete all of this Kind feature would be appropriate.

 On Jan 22, 12:59 pm, John Patterson jdpatter...@gmail.com wrote:



  Here is the code I use to delete one kind at a time - it batches the  
  keys into Lists of 100 to avoid datastore exceptions.  Iterables is  
  from Google collections.

                                          Query query = new Query(kind);
                                          query.setKeysOnly();
                                          DatastoreService datastore = ...
                                          IterableEntity entityIterator =  
  datastore.prepare(query).asIterable();
                                          IterableKey keyIterator = 
  Iterables.transform(entityIterator,  
  new FunctionEntity, Key()
                                          {
                                                  public Key apply(Entity 
  arg0)
                                                  {
                                                          return 
  arg0.getKey();
                                                  }
                                          });

                                          IterableListKey partitioned =  
  Iterables.partition(keyIterator, 100);
                                          for (ListKey sublist : 
  partitioned)
                                          {
                                                  datastore.delete(sublist);
                                          }

  On 22 Jan 2010, at 15:10, mete wrote:

   Suppose I have a class A and I have stored some instance of it in the
   datastore. Then I change it, but I keep the name. How I can delete all
   the previous data in the datastore, if I simply do a query and use
   deleteAll, it gives an error (I guess because I changed the name of
   some fields). Thank you.

   Mete

   --
   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-java@googlegroups.com
   .
   To unsubscribe from this group, send email to 
   google-appengine-java+unsubscr...@googlegroups.com
   .
   For more options, visit this group 
   athttp://groups.google.com/group/google-appengine-java?hl=en
   .- Hide quoted text -

 - Show quoted text -

-- 
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.



Re: [appengine-java] Re: deleting all entries in datastore

2010-01-22 Thread John Patterson
I have found deleting to be the most CPU hungry activity - more than  
putting the data in the first place.  Using code similar to below I  
have used over an hour of CPU time in one 30 second request!


So I wonder if that is why this option doesn't exist in the GUI...  
people would be gutted to hit their quota just from deleting a kind.   
But if it did not count towards the quota that would be fantastic.  In  
the same way that creating indexes is free CPU time as long as you do  
it after entering your data.


On 23 Jan 2010, at 03:30, Larry Cable wrote:


+1 especially for large tables

On Jan 22, 10:47 am, Locke locke2...@gmail.com wrote:

It would be good to have the ability to do this from within the GUI.
Other database management tools have empty table options, so a
delete all of this Kind feature would be appropriate.

On Jan 22, 12:59 pm, John Patterson jdpatter...@gmail.com wrote:




Here is the code I use to delete one kind at a time - it batches the
keys into Lists of 100 to avoid datastore exceptions.  Iterables is
from Google collections.


Query query = new  
Query(kind);

query.setKeysOnly();
DatastoreService datastore  
= ...
IterableEntity  
entityIterator =

datastore.prepare(query).asIterable();
IterableKey keyIterator  
= Iterables.transform(entityIterator,

new FunctionEntity, Key()
{
public Key  
apply(Entity arg0)

{
return  
arg0.getKey();

}
});


IterableListKey  
partitioned =

Iterables.partition(keyIterator, 100);
for (ListKey sublist :  
partitioned)

{
 
datastore.delete(sublist);

}



On 22 Jan 2010, at 15:10, mete wrote:


Suppose I have a class A and I have stored some instance of it in  
the
datastore. Then I change it, but I keep the name. How I can  
delete all

the previous data in the datastore, if I simply do a query and use
deleteAll, it gives an error (I guess because I changed the name of
some fields). Thank you.



Mete



--
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-java@googlegroups.com
.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com
.
For more options, visit this group 
athttp://groups.google.com/group/google-appengine-java?hl=en
.- Hide quoted text -


- Show quoted text -


--
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-java@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 
.




--
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.