Using App Engine Datastore Low Level API with Java

孤者浪人 提交于 2019-12-11 20:06:54

问题


How to find the total number of entries in an entity type in App Engine Datastore using Low Level API?

I there a function or filter to query for this purpose?

I am using Java to implement this.


回答1:


App Engine has an API for getting datastore statistics programmatically:

DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
Entity globalStat = datastore.prepare(new Query("__Stat_Total__")).asSingleEntity();
Long totalBytes = (Long) globalStat.getProperty("bytes");
Long totalEntities = (Long) globalStat.getProperty("count")

See the documentation: https://cloud.google.com/appengine/docs/java/datastore/stats

You can get entities of a kind using __Stat_Kind__



来源:https://stackoverflow.com/questions/27573330/using-app-engine-datastore-low-level-api-with-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!