For Google App Engine (java), how do I set and use chunk size in FetchOptions?

前端 未结 3 1773
梦毁少年i
梦毁少年i 2021-02-08 12:59

Im running a query and it is currently returning 1400 results and because of this I am getting the following warning in the log file:

com.google.appengine

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-08 13:41

    If you are using the dataStore directly, without JDO, then you would do something like the following to set the chunk-size when you are iterating through the data:

    Query query = new Query("entityname");
    PreparedQuery preparedQuery = dataStore.prepare(query);
    // the 200 should be less than 1000
    FetchOptions options = FetchOptions.Builder.withChunkSize(200);
    for (Entity result : preparedQuery.asIterable(options)) {
        ...
    }
    

提交回复
热议问题