views:

51

answers:

2

Hi, i'm using java to code for GAE, i've read through the GAE java low level api and can't find any answer to my question yet.

I wanna know if there's a way where i can call a method/ do a JDOPL and it returns all the different kinds of entities in my datastore.

Thanks!

+2  A: 

You could use the datastore statistics API:

http://code.google.com/appengine/docs/java/datastore/stats.html

It looks like the __Stat_Kind__ statistic will give you the info you want.

Saxon Druce
thanks! you're right, i found that link through another forum while waiting for the answer
chin
A: 

i found a working solution in: (it doesn't work in local deployment server as of jul 9 2010)

http://groups.google.com/group/google-appengine-java/browse_thread/thread/d13d268242083db6/5bb868b394d09c13?show_docid=5bb868b394d09c13&fwc=1&pli=1

DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); PreparedQuery global = datastore.prepare(new Query("Stat_Kind"));

for( Entity globalStat : global.asIterable() ) { Long totalBytes = (Long) globalStat.getProperty("bytes"); Long totalEntities = (Long) globalStat.getProperty("count"); String kindName = (String) globalStat.getProperty("kind_name"); resp.getWriter().println("[" + kindName + "] has " + totalEntities + " entities and takes up " + totalBytes + "bytes
"); }

chin