本文介绍了App Engine Java API pageSize的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么Google决定忽略 pageSize
参数以及为什么在使用不同页面大小时收集项目的总体大小不同?这里是一个例子:
Appsactivity.Activities.List request = service.activities().list()
。 setDriveAncestorId(ancestorId)
.setGroupingStrategy(driveUi)
.setSource(drive.google.com)
.setUserId(me)
.setPageSize(pageSize) ;
列表<活动> list = new LinkedList<>();
ListActivitiesResponse response = null;
do {
response = request.execute();
列表<活动> fetched = response.getActivities();
System.out.println(页面项目:+ fetched.size());
list.addAll(fetched);
request.setPageToken(response.getNextPageToken()); (request.getPageToken()!= null&&&& request.getPageToken()。length()> 0);
}
System.out.println(all items:+ list.size())
当我将 pageSize
设置为100时,我会得到720个项目(64,71,60,60,76,92,87,74,62,56 ,18),但是当我将 pageSize
设置为5时,结果集包含810个项目。我错过了一些东西,或者它是一个API错误?
编辑
我只是使用事件时间作为关键字来检查singleEvents计数。很少有事件被复制,但是当使用不同的pageSize时,事件count之间的显着差异仍然存在。
另一个像这样的问题 解决方案
根据以下链接,它似乎是错误:
结果集可能包含重复项在某些情况下
Why has google decided to ignore pageSize
parameter and why the overall size of the collected items differs when using different page size? Here is an example:
Appsactivity.Activities.List request = service.activities().list()
.setDriveAncestorId(ancestorId)
.setGroupingStrategy("driveUi")
.setSource("drive.google.com")
.setUserId("me")
.setPageSize(pageSize);
List<Activity> list = new LinkedList<>();
ListActivitiesResponse response = null;
do {
response = request.execute();
List<Activity> fetched = response.getActivities();
System.out.println("page items: " + fetched.size());
list.addAll(fetched);
request.setPageToken(response.getNextPageToken());
} while (request.getPageToken() != null && request.getPageToken().length() > 0);
System.out.println("all items: " + list.size())
When I set pageSize
to 100, I will get 720 items (64, 71, 60, 60, 76, 92, 87, 74, 62, 56, 18), however when I set pageSize
to 5 the result set contains 810 items. Am I missing something or it's an API bug?
EDIT
I've just checked singleEvents counts by using event time as key. Few events were duplicated, however the significant difference between events count is still present, when using different pageSize.
Another question like this google-api-java-client-pagesize
解决方案
It seems that it is a bug according to the following links:
Result set can probably contain duplicates in some cases is-paging-broken-in-drive
The following link contains explanation of the page size oscilation.drive-api-search-results
这篇关于App Engine Java API pageSize的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!