当前位置: 首页>>代码示例>>Java>>正文


Java Query.getLimit方法代码示例

本文整理汇总了Java中org.mongodb.morphia.query.Query.getLimit方法的典型用法代码示例。如果您正苦于以下问题:Java Query.getLimit方法的具体用法?Java Query.getLimit怎么用?Java Query.getLimit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.mongodb.morphia.query.Query的用法示例。


在下文中一共展示了Query.getLimit方法的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();
    }
}
 
开发者ID:researchgate,项目名称:restler,代码行数:27,代码来源:MongoServiceDao.java

示例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());
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:16,代码来源:DatastoreImpl.java

示例3: mapReduce

import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
@Override
@Deprecated
public <T> MapreduceResults<T> mapReduce(final MapreduceType type, final Query query, final String map, final String reduce,
                                         final String finalize, final Map<String, Object> scopeFields, final Class<T> outputType) {

    final DBCollection dbColl = query.getCollection();

    final String outColl = mapper.getCollectionName(outputType);

    final MapReduceCommand cmd = new MapReduceCommand(dbColl, map, reduce, outColl, type.toOutputType(), query.getQueryObject());

    if (query.getLimit() > 0) {
        cmd.setLimit(query.getLimit());
    }
    if (query.getSortObject() != null) {
        cmd.setSort(query.getSortObject());
    }

    if (finalize != null && finalize.length() != 0) {
        cmd.setFinalize(finalize);
    }

    if (scopeFields != null && !scopeFields.isEmpty()) {
        cmd.setScope(scopeFields);
    }

    return mapReduce(type, query, outputType, cmd);
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:29,代码来源:DatastoreImpl.java


注:本文中的org.mongodb.morphia.query.Query.getLimit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。