コード例 #1
0
ファイル: dbdirectclient.cpp プロジェクト: DieterLutz/mongo
    unsigned long long DBDirectClient::count(const string& ns,
                                             const BSONObj& query,
                                             int options,
                                             int limit,
                                             int skip) {
        if (skip < 0) {
            warning() << "setting negative skip value: " << skip
                      << " to zero in query: " << query << endl;
            skip = 0;
        }

        Lock::DBRead lk(_txn->lockState(), ns);
        string errmsg;
        int errCode;
        long long res = runCount(_txn,
                                 ns,
                                 _countCmd(ns, query, options, limit, skip),
                                 errmsg,
                                 errCode);

        if (res == -1) {
            // namespace doesn't exist
            return 0;
        }
        massert(errCode, str::stream() << "count failed in DBDirectClient: " << errmsg , res >= 0);
        return (unsigned long long )res;
    }
コード例 #2
0
ファイル: dbclient.cpp プロジェクト: RyokoAkizuki/freshcity
 unsigned long long DBClientWithCommands::count(const string &myns, const BSONObj& query, int options, int limit, int skip ) {
     NamespaceString ns(myns);
     BSONObj cmd = _countCmd( myns , query , options , limit , skip );
     BSONObj res;
     if( !runCommand(ns.db.c_str(), cmd, res, options) )
         uasserted(11010,string("count fails:") + res.toString());
     return res["n"].numberLong();
 }
コード例 #3
0
 unsigned long long DBDirectClient::count(const string &ns, const BSONObj& query, int options, int limit, int skip ) {
     Lock::DBRead lk( ns );
     string errmsg;
     long long res = runCount( ns.c_str() , _countCmd( ns , query , options , limit , skip ) , errmsg );
     if ( res == -1 )
         return 0;
     uassert( 13637 , str::stream() << "count failed in DBDirectClient: " << errmsg , res >= 0 );
     return (unsigned long long )res;
 }
コード例 #4
0
ファイル: instance.cpp プロジェクト: JKO/mongo
 unsigned long long DBDirectClient::count(const string &ns, const BSONObj& query, int options, int limit, int skip ) {
     Lock::DBRead lk( ns );
     string errmsg;
     int errCode;
     long long res = runCount( ns.c_str() , _countCmd( ns , query , options , limit , skip ) , errmsg, errCode );
     if ( res == -1 ) {
         // namespace doesn't exist
         return 0;
     }
     massert( errCode , str::stream() << "count failed in DBDirectClient: " << errmsg , res >= 0 );
     return (unsigned long long )res;
 }
コード例 #5
0
ファイル: instance.cpp プロジェクト: nvdnkpr/mongo
    unsigned long long DBDirectClient::count(const string &ns, const BSONObj& query, int options, int limit, int skip ) {
        if ( skip < 0 ) {
            warning() << "setting negative skip value: " << skip
                << " to zero in query: " << query << endl;
            skip = 0;
        }
        string errmsg;
        int errCode;

        LOCK_REASON(lockReason, "count");
        Client::ReadContext ctx(ns, lockReason);
        Client::Transaction transaction(DB_TXN_SNAPSHOT | DB_TXN_READ_ONLY);
        long long res = runCount( ns.c_str() , _countCmd( ns , query , options , limit , skip ) , errmsg, errCode );
        if ( res == -1 ) {
            // namespace doesn't exist
            return 0;
        }
        massert( errCode , str::stream() << "count failed in DBDirectClient: " << errmsg , res >= 0 );
        transaction.commit();
        return (unsigned long long )res;
    }