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


Java DBCollection.count方法代码示例

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


在下文中一共展示了DBCollection.count方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: snapshotCount

import com.mongodb.DBCollection; //导入方法依赖的package包/类
@Override
public <T extends Model> Long snapshotCount(Class<T> modelClass, Map<String, Object> filter) {
    if (modelClass == null)
        throw new DaoException("Model class cannot be null");

    if (filter == null)
        filter = EMPTY_FILTER;

    DBObject dbObject = buildQueryFilter(modelClass, filter, null);

    DBCollection col = collection(modelClass, true);

    Long count = col.count(dbObject);

    if (count != null) {
        app.setQueryMetadata(QueryMetadata.builder().count(count).build());
    }

    return count;
}
 
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:21,代码来源:AbstractMongoDao.java

示例2: count

import com.mongodb.DBCollection; //导入方法依赖的package包/类
/**
   * 分页查询,count
   * @param dbName
   * @param collName
   * @param query
   * @return
   */
  public static long count(String dbName, String collName, DBObject query) {
  	DBCollection collection = getCollection(dbName, collName);
  	if (collection != null) {
	return collection.count(query);
}
      return -1;
  }
 
开发者ID:xuxueli,项目名称:xxl-incubator,代码行数:15,代码来源:MongoDBUtil.java

示例3: getQueryCount

import com.mongodb.DBCollection; //导入方法依赖的package包/类
private long getQueryCount(DBCollection collection) {
	DBObject query = getQuery();
	if (null == query) {
		return collection.count();
	} else {
		return collection.count(query);
	}
}
 
开发者ID:xsonorg,项目名称:tangyuan2,代码行数:9,代码来源:SelectVo.java

示例4: readPatternsFromMongo

import com.mongodb.DBCollection; //导入方法依赖的package包/类
private List<PatternReference> readPatternsFromMongo() {
	// TODO: Ideally this would do something in a more streaming manner, as there are likely to
	// be lots of examples

	DBCollection collection = mongo.getDB().getCollection(patternCollection);

	List<PatternReference> patterns = new ArrayList<>((int) collection.count());

	DBCursor cursor = collection.find();
	while (cursor.hasNext()) {
		DBObject o = cursor.next();
		// TODO: We don't currently use types (entity source target) but we could do
		// at least to output something to the relationship type filter

		BasicDBList list = (BasicDBList) o.get("words");
		List<Word> tokens = list.stream().map(l -> {
			BasicDBObject dbo = (BasicDBObject) l;
			String pos = dbo.getString("pos");
			String lemma = dbo.getString("lemma");

			// Fall back to actual text if no lemma
			if (lemma == null) {
				lemma = dbo.getString("text");
			}

			return new Word(lemma.trim().toLowerCase(), WordNetUtils.toPos(pos));
		}).filter(w -> w.getPos() != null)
				.collect(Collectors.toList());

		patterns.add(new PatternReference(o.get("_id").toString(), tokens));
	}

	return patterns;

}
 
开发者ID:tenode,项目名称:baleen-extras,代码行数:36,代码来源:IdentifyInteractions.java

示例5: onRootAccess

import com.mongodb.DBCollection; //导入方法依赖的package包/类
@RequestMapping(method = RequestMethod.GET)
public @ResponseBody Result onRootAccess() {

    DBCollection collection = mongoTemplate.getCollection("test");
    long count = collection.getCount();
    log.info("Object count in 'test' collection before insert: " + count + "<br/> Inserting one object.<br/>");

    BasicDBObject dBObject = new BasicDBObject();
    dBObject.put("hello", "world");
    collection.insert(dBObject);
    count = collection.count();
    log.info("Object count in test collection after insert:" + count);

    Result result = new Result();
    List<DBObject> dbObjects = new ArrayList<DBObject>();
    DBCursor cursor = collection.find();
    while (cursor.hasNext()) {
        com.mongodb.DBObject obj = cursor.next();
        final String value = (String) obj.get("hello");
        DBObject object = new DBObject();
        object.setKey("hello");
        object.setValue(value);
        dbObjects.add(object);
    }
    result.setDbObjects(dbObjects);
    result.setStatus(
            "Successfully accessed Mongodb service. Retrieving the data object inserted in test collection.");
    collection.drop();
    return result;
}
 
开发者ID:SAP,项目名称:hcp-cloud-foundry-tutorials,代码行数:31,代码来源:RootController.java

示例6: get

import com.mongodb.DBCollection; //导入方法依赖的package包/类
@Override
public Object get(String key) throws PageException {
	DBCollection coll = db.getCollection(key);
	if(coll.count()!=0 || containsKey(key)) return toCFML(coll);
	throw exp.createExpressionException("key ["+key+"] doesn't exist ");
}
 
开发者ID:lucee,项目名称:extension-mongodb,代码行数:7,代码来源:DBImpl.java

示例7: count

import com.mongodb.DBCollection; //导入方法依赖的package包/类
private static long count(DBObject query) {
  DBCollection collection = MongoFactory.getDB().getCollection(collectionName);
  return collection.count(query);
}
 
开发者ID:telefonicaid,项目名称:fiware-sinfonier,代码行数:5,代码来源:Module.java

示例8: count

import com.mongodb.DBCollection; //导入方法依赖的package包/类
private static long count(DBObject query) {
  DBCollection collection = MongoFactory.getDB().getCollection(getCollectionName());
  return collection.count(query);
}
 
开发者ID:telefonicaid,项目名称:fiware-sinfonier,代码行数:5,代码来源:Topology.java


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