Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
可区分的获取大小[JAVA]_Java_Mongodb_Size - Fatal编程技术网

可区分的获取大小[JAVA]

可区分的获取大小[JAVA],java,mongodb,size,Java,Mongodb,Size,如何以更具表现力的方式返回可区分项的记录数量。 我试过了 subscriber.subscribe()。getCollection(“MyClass”,AmAccountTradeEvent.class).distinct(“globalId”,MyClass.class).filter(bson).into(newarraylist())。大小() 但我有一个错误:error-readStartDocument只能在currentbontype为DOCUMENT时调用,而不能在currentb

如何以更具表现力的方式返回可区分项的记录数量。 我试过了

subscriber.subscribe()。getCollection(“MyClass”,AmAccountTradeEvent.class).distinct(“globalId”,MyClass.class).filter(bson).into(newarraylist())。大小()

但我有一个错误:error-readStartDocument只能在currentbontype为DOCUMENT时调用,而不能在currentbontype为STRING时调用

while (find.cursor (). hasNext ()) {
list.add (find.iterator (). next ());
}

return list.size ();

而对于while,只需300条记录就需要很长时间:

Resolvi da senguinte forma:distributterable find=subscriber.subscribe().getCollection(“MyClass”,MyClass.class).distinct(globald),String.class).filter(bson);System.out.println(Iterables.size(find));return Iterables.size(find);