driver-legacy/src/main/com/mongodb/DBCollection.java
public long count(@Nullable final DBObject query, final ReadPreference readPreference) {
        return getCount(query, null, readPreference);
    }
public long count(@Nullable final DBObject query, final ReadPreference readPreference) {
        return getCount(query, null, readPreference);
    }
Get the count of documents in collection that would match a criteria.

@param query          specifies the selection criteria
@param readPreference {@link ReadPreference} to be used for this operation
@return the number of documents that matches selection criteria
@throws MongoException if the operation failed
@mongodb.driver.manual reference/command/count/ Count