// local limit is not taken into account
gaeCtx.realPageSize = pag.pageSize;
fetchOptions.limit(gaeCtx.realPageSize);
}
QueryOptionOffset off = (QueryOptionOffset)query.option(QueryOptionOffset.ID);
// if local offset has been set, uses it
if(offset!=0){
off.activate();
off.offset = offset;
}
// if previousPage has detected there is no more data, simply returns an empty list
if(gaeCtx.noMoreDataBefore){
return new ArrayList<T>();
}
if(state.isStateless()) {
if(pag.isPaginating()){
if(off.isActive()){
gaeCtx.realOffset+=off.offset;
fetchOptions.offset(gaeCtx.realOffset);
off.passivate();
}else {
fetchOptions.offset(gaeCtx.realOffset);
}
}else {
// if stateless and not paginating, resets the realoffset to 0
gaeCtx.realOffset = 0;
if(off.isActive()){
gaeCtx.realOffset=off.offset;
fetchOptions.offset(gaeCtx.realOffset);
off.passivate();
}
}
switch(fetchType.fetchType){
case KEYS_ONLY:
{
// uses iterable as it is the only async request for prepared query for the time being
List<Entity> entities = prepareKeysOnly(query).asList(fetchOptions);
// if paginating and 0 results then no more data else resets noMoreDataAfter
if(pag.isPaginating()){
if(entities.size() == 0){
gaeCtx.noMoreDataAfter = true;
}
else {
gaeCtx.noMoreDataAfter = false;
}
}
return mapKeysOnly(query, entities);
}
case NORMAL:
default:
{
// uses iterable as it is the only async request for prepared query for the time being
List<Entity> entities = prepare(query).asList(fetchOptions);
// if paginating and 0 results then no more data else resets noMoreDataAfter
if(pag.isPaginating()){
if(entities.size() == 0){
gaeCtx.noMoreDataAfter = true;
}
else {
gaeCtx.noMoreDataAfter = false;
}
}
return map(query, entities);
}
}
}else {
if(off.isActive()){
// by default, we add the offset but it can be added with the realoffset
// in case of cursor desactivated
fetchOptions.offset(off.offset);
gaeCtx.realOffset+=off.offset;
off.passivate();
}
// manages cursor limitations for IN and != operators with offsets
if(!gaeCtx.isActive()){
// cursor not yet created