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


C++ DBDirectClient::count方法代码示例

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


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

示例1: run

 void run() {
     // Recreate the collection as capped, without an _id index.
     _client.dropCollection( _ns );
     BSONObj info;
     ASSERT( _client.runCommand( "unittests",
                                 BSON( "create" << "indexupdate" <<
                                       "capped" << true <<
                                       "size" << ( 10 * 1024 ) <<
                                       "autoIndexId" << false ),
                                 info ) );
     // Insert some documents.
     int32_t nDocs = 1000;
     for( int32_t i = 0; i < nDocs; ++i ) {
         _client.insert( _ns, BSON( "_id" << i ) );
     }
     // Initialize curop.
     cc().curop()->reset();
     // Request an interrupt.
     killCurrentOp.killAll();
     BSONObj indexInfo = BSON( "key" << BSON( "_id" << 1 ) <<
                               "ns" << _ns <<
                               "name" << "_id" );
     // The call is not interrupted because mayInterrupt == false.
     theDataFileMgr.insertWithObjMod( "unittests.system.indexes", indexInfo, false );
     // The new index is listed in system.indexes because the index build succeeded.
     ASSERT_EQUALS( 1U, _client.count( "unittests.system.indexes", BSON( "ns" << _ns ) ) );
 }
开发者ID:violentesc,项目名称:mongo,代码行数:27,代码来源:indexupdatetests.cpp

示例2: checkIfReplMissingFromCommandLine

 /**
  * Checks if this server was started without --replset but has a config in local.system.replset
  * (meaning that this is probably a replica set member started in stand-alone mode).
  *
  * @returns the number of documents in local.system.replset or 0 if this was started with
  *          --replset.
  */
 unsigned long long checkIfReplMissingFromCommandLine() {
     Lock::GlobalWrite lk; // this is helpful for the query below to work as you can't open files when readlocked
     if (!replSettings.usingReplSets()) {
         DBDirectClient c;
         return c.count("local.system.replset");
     }
     return 0;
 }
开发者ID:BobWeinerJr,项目名称:mongo,代码行数:15,代码来源:db.cpp

示例3: checkIfReplMissingFromCommandLine

 void checkIfReplMissingFromCommandLine() {
     Lock::GlobalWrite lk; // _openAllFiles is false at this point, so this is helpful for the query below to work as you can't open files when readlocked
     if( !cmdLine.usingReplSets() ) { 
         Client::GodScope gs;
         DBDirectClient c;
         unsigned long long x = 
             c.count("local.system.replset");
         if( x ) { 
             log() << endl;
             log() << "** warning: mongod started without --replSet yet " << x << " documents are present in local.system.replset" << endl;
             log() << "**          restart with --replSet unless you are doing maintenance and no other clients are connected" << endl;
             log() << endl;
         }
     }
 }
开发者ID:opinionaided,项目名称:mongo,代码行数:15,代码来源:db.cpp

示例4: run

        void run() {
            // RARELY shoud be once/128x
            for (int i=0; i<150; i++) {
                insert();
                updateSucceed();
            }

            DBDirectClient client;
            int count = (int) client.count(cappedNs(), BSONObj());
            verify(count > 1);

            // Just to be sure, no _id index, right?
            Client::Context ctx(cappedNs());
            NamespaceDetails *nsd = nsdetails(cappedNs().c_str());
            verify(nsd->findIdIndex() == -1);
        }
开发者ID:Desartstudio,项目名称:mongo-nonx86,代码行数:16,代码来源:replsettests.cpp

示例5: run

 void run() {
     // Insert some documents.
     int32_t nDocs = 1000;
     for( int32_t i = 0; i < nDocs; ++i ) {
         _client.insert( _ns, BSON( "a" << i ) );
     }
     // Initialize curop.
     cc().curop()->reset();
     // Request an interrupt.
     killCurrentOp.killAll();
     // The call is not interrupted.
     Helpers::ensureIndex( _ns, BSON( "a" << 1 ), false, "a_1" );
     // The new index is listed in system.indexes because the index build completed.
     ASSERT_EQUALS( 1U,
                    _client.count( "unittests.system.indexes",
                                   BSON( "ns" << _ns << "name" << "a_1" ) ) );
 }
开发者ID:dstorch,项目名称:mongo,代码行数:17,代码来源:indexupdatetests.cpp

示例6: run

 void run() {
     // Insert some documents.
     int32_t nDocs = 1000;
     for( int32_t i = 0; i < nDocs; ++i ) {
         _client.insert( _ns, BSON( "a" << i ) );
     }
     // Initialize curop.
     cc().curop()->reset();
     // Request an interrupt.  killAll() rather than kill() is required because the direct
     // client will build the index using a new opid.
     killCurrentOp.killAll();
     // The call is not interrupted.
     _client.ensureIndex( _ns, BSON( "a" << 1 ) );
     // only want to interrupt the index build
     killCurrentOp.reset();
     // The new index is listed in system.indexes because the index build completed.
     ASSERT_EQUALS( 1U,
                    _client.count( "unittests.system.indexes",
                                   BSON( "ns" << _ns << "name" << "a_1" ) ) );
 }
开发者ID:Albert-B-P,项目名称:mongo,代码行数:20,代码来源:indexupdatetests.cpp

示例7: conn

    ReplSetConfig::ReplSetConfig(const HostAndPort& h) {
        clear();
        int level = 2;
        DEV level = 0;

        BSONObj cfg;
        int v = -5;
        try {
            if( h.isSelf() ) {
                ;
            }
            else {
                /* first, make sure other node is configured to be a replset. just to be safe. */
                string setname = cmdLine.ourSetName();
                BSONObj cmd = BSON( "replSetHeartbeat" << setname );
                int theirVersion;
                BSONObj info;
                log() << "trying to contact " << h.toString() << rsLog;
                bool ok = requestHeartbeat(setname, "", h.toString(), info, -2, theirVersion);
                if( info["rs"].trueValue() ) {
                    // yes, it is a replicate set, although perhaps not yet initialized
                }
                else {
                    if( !ok ) {
                        log() << "replSet TEMP !ok heartbeating " << h.toString() << " on cfg load" << rsLog;
                        if( !info.isEmpty() )
                            log() << "replSet info " << h.toString() << " : " << info.toString() << rsLog;
                        return;
                    }
                    {
                        stringstream ss;
                        ss << "replSet error: member " << h.toString() << " is not in --replSet mode";
                        msgassertedNoTrace(13260, ss.str().c_str()); // not caught as not a user exception - we want it not caught
                        //for python err# checker: uassert(13260, "", false);
                    }
                }
            }

            v = -4;
            unsigned long long count = 0;
            try {
                ScopedConn conn(h.toString());
                v = -3;
                cfg = conn.findOne(rsConfigNs, Query()).getOwned();
                count = conn.count(rsConfigNs);
            }
            catch ( DBException& ) {
                if ( !h.isSelf() ) {
                    throw;
                }

                // on startup, socket is not listening yet
                DBDirectClient cli;
                cfg = cli.findOne( rsConfigNs, Query() ).getOwned();
                count = cli.count(rsConfigNs);
            }

            if( count > 1 )
                uasserted(13109, str::stream() << "multiple rows in " << rsConfigNs << " not supported host: " << h.toString());

            if( cfg.isEmpty() ) {
                version = EMPTYCONFIG;
                return;
            }
            version = -1;
        }
        catch( DBException& e) {
            version = v;
            log(level) << "replSet load config couldn't get from " << h.toString() << ' ' << e.what() << rsLog;
            return;
        }

        from(cfg);
        checkRsConfig();
        _ok = true;
        log(level) << "replSet load config ok from " << (h.isSelf() ? "self" : h.toString()) << rsLog;
    }
开发者ID:CoolCloud,项目名称:mongo,代码行数:77,代码来源:rs_config.cpp


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