mongoDB Java的aggregate查询结果的遍历不停向mongoDB发送命令
来源:互联网 发布:大连海事大学网络下线 编辑:程序博客网 时间:2024/05/21 10:15
不断重复的日志为:
2016-01-28 10:41:24,284 http-bio-8088-exec-8 DEBUG- Sending command {aggregate : BsonString{value='ad_batch'}} to database kzhuoAd on connection [connectionId{localValue:12, serverValue:2269}] to server 10.0.0.241:27017
2016-01-28 10:41:24,284 http-bio-8088-exec-3 DEBUG- Sending command {aggregate : BsonString{value='ad_batch'}} to database kzhuoAd on connection [connectionId{localValue:3, serverValue:2259}] to server 10.0.0.241:27017
2016-01-28 10:41:24,284 http-bio-8088-exec-5 DEBUG- Sending command {aggregate : BsonString{value='ad_batch'}} to database kzhuoAd on connection [connectionId{localValue:6, serverValue:2262}] to server 10.0.0.241:27017
2016-01-28 10:41:24,284 http-bio-8088-exec-23 DEBUG- Sending command {aggregate : BsonString{value='ad_batch'}} to database kzhuoAd on connection [connectionId{localValue:8, serverValue:2264}] to server 10.0.0.241:27017
2016-01-28 10:41:24,285 http-bio-8088-exec-4 DEBUG- Command execution completed
原因:
错误写法:
AggregateIterable<Document> iterableshow=MongodbDao.queryByAggregate("kzhuoAd", "ad_batch", clickList);
int clickCount=0;
while(iterableshow.iterator().hasNext()){//这样写是有问题的会不停的向mongoDB请求命令,并且每次next都是同一个
// Document
Document document=iterableshow.iterator().next();
clickCount=clickCount+document.getInteger("count");
}
正确写法:
AggregateIterable<Document> iterableshow=MongodbDao.queryByAggregate("kzhuoAd", "ad_batch", showList);
MongoCursor<Document> iterator=iterableshow.iterator();
int showCount=0;
while(iterator.hasNext()){
Document document=iterator.next();
showCount=showCount+document.getInteger("count");
}
0 0
- mongoDB Java的aggregate查询结果的遍历不停向mongoDB发送命令
- Java中使用mongodb的aggregate聚合查询
- MongoDB aggregate,mapreduce,聚合命令的区别
- mongodb的aggregate 用法
- MongoDB的聚合(aggregate)
- 使用java 操作mongodb的aggregate
- mongodb aggregate 级联查询
- MongoDB的聚合函数 Aggregate
- MongoDB的聚合函数 Aggregate
- mongodb的aggregate实例1
- java mongodb aggregate用法
- java mongodb aggregate用法
- java mongodb aggregate用法
- mongodb的java命令
- mongodb mapreduce, aggregate, group 的类似功能
- MongoDB aggregate聚合函数的使用
- MongoDB中聚合(aggregate)的使用
- mongoDB中管道的使用,aggregate
- Zernike矩之边缘检测(附源码)
- 数据库建表类型
- svn创建分支和合并
- 关于密码的安全性问题
- EndNote导出文献为Excel文件
- mongoDB Java的aggregate查询结果的遍历不停向mongoDB发送命令
- ES6学习——生成器(Generators):生成器+迭代器
- Endnote 导出文献到Excel
- 面试必备:String,StringBuffer,StringBuilder区别
- 模运算性质及应用
- poj 1459 最大流增广路算法
- Linux:hping高级主机扫描
- sql的循环,判断,跳转语句
- Spring Boot的启动器Starter详解