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


Java Query.countAll方法代码示例

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


在下文中一共展示了Query.countAll方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: get

import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
@Override
public EntityResult<V> get(ServiceQuery<K> serviceQuery) throws RestDslException {
    Query<V> morphiaQuery = convertToMorphiaQuery(serviceQuery);

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug(morphiaQuery.toString());
    }

    String groupBy = serviceQuery.getGroupBy();
    try (StatsTimingWrapper ignored = getQueryShapeWrapper(serviceQuery)) {
        if (groupBy == null) {
            List<V> results = Collections.emptyList();
            if (!serviceQuery.getCountOnly()) {
                results = morphiaDao.find(morphiaQuery).asList();
            }
            return new EntityResult<>(results, getTotalItemsCnt(morphiaQuery, serviceQuery, results));
        } else {
            // warning: in-place criteria editing
            Collection<Object> criteriaForGrouping = Lists.newArrayList(serviceQuery.getCriteria().get(groupBy));

            Map<Object, EntityList<V>> groupedResult = new HashMap<>();
            for (Object k : criteriaForGrouping) {
                serviceQuery.getCriteria().removeAll(groupBy);
                serviceQuery.getCriteria().put(groupBy, k);
                Query<V> q = convertToMorphiaQuery(serviceQuery);
                List<V> resultPerKey = Collections.emptyList();
                if (!serviceQuery.getCountOnly()) {
                    resultPerKey = morphiaDao.find(q).asList();
                }

                EntityList<V> entityList = new EntityList<>(resultPerKey, getTotalItemsCnt(q, serviceQuery, resultPerKey));
                groupedResult.put(k, entityList);
            }
            return new EntityResult<>(new EntityMultimap<>(groupedResult, serviceQuery.isCountTotalItems() ? morphiaQuery.countAll() : null));
        }
    }
}
 
开发者ID:researchgate,项目名称:restler,代码行数:38,代码来源:MongoServiceDao.java

示例3: queryCount

import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
/**
 * 查询日志通用接口,查询多个对象的总数
 * @param filter	条件字符串组
 * @param value		参数组
 * @throws SQLException
 */
public Long queryCount(String[] filter, Object[] value) throws SQLException
{
	if(filter == null || value == null)
		return new Long(0);
	Query<T> query = getDao().createQuery().disableValidation();
	queryAnalasis(query, filter, value);
	return query.countAll();
}
 
开发者ID:liyang-bsy,项目名称:LYLab,代码行数:15,代码来源:MongoDBService.java

示例4: getPageByTitle

import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
public Optional<Page> getPageByTitle(final String title) {
    // by-title?
    Query<Page> q = datastore.find(Page.class, "title", title);
    if (q.countAll() > 0) {
        return Optional.of(q.get());
    } else {
        return Optional.absent();
    }
}
 
开发者ID:ageldama,项目名称:glados-wiki,代码行数:10,代码来源:PageService.java

示例5: listPages

import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
public ImmutablePair<Long, List<Page>> listPages(Optional<String> searchTerm, final int offset, final int limit) {
    Query<Page> q = datastore.createQuery(Page.class);
    if (searchTerm.isPresent()) {
        final String s = searchTerm.get();
        final Pattern p = Pattern.compile(searchTerm.get(), Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
        //
        //List<PageContent> pageContents = datastore.createQuery(PageContent.class).filter("content", p).asList();
        q.or(q.criteria("title").containsIgnoreCase(s), q.criteria("tags").containsIgnoreCase(s)/*, q.criteria("current").hasAnyOf(pageContents)*/);
    }
    //LOG.debug(q.toString());
    return new ImmutablePair<Long, List<Page>>(q.countAll(),
            q.offset(offset).limit(limit).order("title").asList());
}
 
开发者ID:ageldama,项目名称:glados-wiki,代码行数:14,代码来源:PageService.java

示例6: count

import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
public long count(final Optional<String> searchTerm,
                  final Optional<String> groupName) {
    //
    Query<User> q = datastore.createQuery(User.class);
    queryApplySearch(searchTerm, groupName, q);
    return q.countAll();
}
 
开发者ID:ageldama,项目名称:glados-wiki,代码行数:8,代码来源:UserService.java

示例7: count

import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
public long count(final Optional<String> searchTerm) {
    Query<Group> q = datastore.createQuery(Group.class);
    queryApplySearchTerm(searchTerm, q);
    return q.countAll();
}
 
开发者ID:ageldama,项目名称:glados-wiki,代码行数:6,代码来源:GroupService.java

示例8: countVersions

import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
public long countVersions(Page page) {
    Query<PageContent> q = datastore.createQuery(PageContent.class);
    q.field("page").equal(page);
    return q.countAll();
}
 
开发者ID:ageldama,项目名称:glados-wiki,代码行数:6,代码来源:PageContentService.java

示例9: listRecents

import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
public Pair<Long, List<PageContent>> listRecents(final int offset, final int limit) {
    Query<PageContent> q = datastore.createQuery(PageContent.class)
            .offset(offset).limit(limit)
            .order("-ctime");
    return new ImmutablePair<Long, List<PageContent>>(q.countAll(), q.asList());
}
 
开发者ID:ageldama,项目名称:glados-wiki,代码行数:7,代码来源:PageContentService.java

示例10: countByEmail

import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
public long countByEmail(final String email) {
    Query<User> q = datastore.createQuery(User.class);
    q.criteria("email").equal(email);
    return q.countAll();
}
 
开发者ID:ageldama,项目名称:glados-wiki,代码行数:6,代码来源:UserService.java


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