本文整理汇总了Java中org.mongodb.morphia.query.Query.getOffset方法的典型用法代码示例。如果您正苦于以下问题:Java Query.getOffset方法的具体用法?Java Query.getOffset怎么用?Java Query.getOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mongodb.morphia.query.Query
的用法示例。
在下文中一共展示了Query.getOffset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTotalItemsCnt
import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
private Long getTotalItemsCnt(Query<V> q, ServiceQuery<?> serviceQuery, List<V> results) {
if (!serviceQuery.isCountTotalItems()) {
return null;
}
if (results.size() > q.getLimit()) {
throw new RestDslException("Implementation error: results size must be not greater than limit, was " +
results.size() + " but limit was: " + q.getLimit());
}
if (serviceQuery.getCountOnly()) {
return q.countAll();
}
// if getLimit == 0 then we need to count anyway
if (results.size() == 0 && q.getOffset() == 0 && q.getLimit() > 0) {
return 0L;
}
// if size is equal 0 it could be that offset is too big, or we just have 0 elements in total - must count
if (results.size() != 0 && results.size() < q.getLimit()) {
return (long) (q.getOffset() + results.size());
} else {
return q.countAll();
}
}
示例2: delete
import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
@Override
public <T> WriteResult delete(final Query<T> query, final DeleteOptions options) {
DBCollection dbColl = query.getCollection();
// TODO remove this after testing.
if (dbColl == null) {
dbColl = getCollection(query.getEntityClass());
}
if (query.getSortObject() != null || query.getOffset() != 0 || query.getLimit() > 0) {
throw new QueryException("Delete does not allow sort/offset/limit query options.");
}
return dbColl.remove(query.getQueryObject(), enforceWriteConcern(options, query.getEntityClass()).getOptions());
}
示例3: mapReduce
import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
@Override
@Deprecated
public <T> MapreduceResults<T> mapReduce(final MapreduceType type, final Query query, final Class<T> outputType,
final MapReduceCommand baseCommand) {
Assert.parametersNotNull("map", baseCommand.getMap());
Assert.parameterNotEmpty("map", baseCommand.getMap());
Assert.parametersNotNull("reduce", baseCommand.getReduce());
Assert.parameterNotEmpty("reduce", baseCommand.getReduce());
if (query.getOffset() != 0 || query.getFieldsObject() != null) {
throw new QueryException("mapReduce does not allow the offset/retrievedFields query options.");
}
final OutputType outType = type.toOutputType();
final DBCollection dbColl = query.getCollection();
final MapReduceCommand cmd = new MapReduceCommand(dbColl, baseCommand.getMap(), baseCommand.getReduce(),
baseCommand.getOutputTarget(), outType, query.getQueryObject());
cmd.setFinalize(baseCommand.getFinalize());
cmd.setScope(baseCommand.getScope());
if (query.getLimit() > 0) {
cmd.setLimit(query.getLimit());
}
if (query.getSortObject() != null) {
cmd.setSort(query.getSortObject());
}
if (LOG.isTraceEnabled()) {
LOG.info("Executing " + cmd.toString());
}
final EntityCache cache = createCache();
MapreduceResults<T> results = new MapreduceResults<T>(dbColl.mapReduce(baseCommand));
results.setType(type);
if (MapreduceType.INLINE.equals(type)) {
results.setInlineRequiredOptions(this, outputType, getMapper(), cache);
} else {
results.setQuery(newQuery(outputType, getDB().getCollection(results.getOutputCollectionName())));
}
return results;
}