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


C++ StringData::toString方法代码示例

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


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

示例1: _firstStep

    StatusWith<bool> SaslSCRAMSHA1ServerConversation::step(const StringData& inputData,
                                                           std::string* outputData) {

        std::vector<std::string> input = StringSplitter::split(inputData.toString(), ",");
        _step++;

        if (_step > 3 || _step <= 0) {
            return StatusWith<bool>(ErrorCodes::AuthenticationFailed,
                mongoutils::str::stream() << "Invalid SCRAM-SHA-1 authentication step: " << _step);
        }
        if (_step == 1) {
            return _firstStep(input, outputData);
        }
        if (_step == 2) {
            return _secondStep(input, outputData);
        }

        *outputData = "";

        return StatusWith<bool>(true);
    }
开发者ID:ANTco,项目名称:mongo,代码行数:21,代码来源:sasl_scramsha1_server_conversation.cpp

示例2: createRecordStore

Status MobileKVEngine::createRecordStore(OperationContext* opCtx,
                                         StringData ns,
                                         StringData ident,
                                         const CollectionOptions& options) {
    // TODO: eventually will support file renaming but otherwise do not use collection options.

    // Mobile SE doesn't support creating an oplog
    if (NamespaceString::oplog(ns)) {
        return Status(ErrorCodes::InvalidOptions,
                      "Replication is not supported by the mobile storage engine");
    }

    // Mobile doesn't support capped collections
    if (options.capped) {
        return Status(ErrorCodes::InvalidOptions,
                      "Capped collections are not supported by the mobile storage engine");
    }

    MobileRecordStore::create(opCtx, ident.toString());
    return Status::OK();
}
开发者ID:RyanBard,项目名称:mongo,代码行数:21,代码来源:mobile_kv_engine.cpp

示例3: _checkIdentPath

void WiredTigerKVEngine::_checkIdentPath(StringData ident) {
    size_t start = 0;
    size_t idx;
    while ((idx = ident.find('/', start)) != string::npos) {
        StringData dir = ident.substr(0, idx);

        boost::filesystem::path subdir = _path;
        subdir /= dir.toString();
        if (!boost::filesystem::exists(subdir)) {
            LOG(1) << "creating subdirectory: " << dir;
            try {
                boost::filesystem::create_directory(subdir);
            } catch (const std::exception& e) {
                error() << "error creating path " << subdir.string() << ' ' << e.what();
                throw;
            }
        }

        start = idx + 1;
    }
}
开发者ID:jianjunliu,项目名称:mongo,代码行数:21,代码来源:wiredtiger_kv_engine.cpp

示例4: dropDatabase

    //
    // delete all collections, their metadata, then the database
    //
    Status BLTreeEngine::dropDatabase(
        OperationContext* ctx,
        const StringData& db )
    {
        const string prefix = db.toString() + ".";
        boost::mutex::scoped_lock lk( _entryMapMutex );
        vector<string> toDrop;

        for (EntryMap::const_iterator i = _entryMap.begin(); i != _entryMap.end(); ++i ) {
            const StringData& ns = i->first;
            if ( ns.startsWith( prefix ) ) {
                toDrop.push_back( ns.toString() );
            }
        }

        for (vector<string>::const_iterator j = toDrop.begin(); j != toDrop.end(); ++j ) {
            _dropCollection_inlock( ctx, *j );
        }

        return closeDatabase( ctx, db );
    }
开发者ID:PLW,项目名称:blink-tree-logic,代码行数:24,代码来源:bltree_engine.cpp

示例5: readReplyMetadata

Status CommittedOpTimeMetadataHook::readReplyMetadata(OperationContext* opCtx,
                                                      StringData replySource,
                                                      const BSONObj& metadataObj) {
    auto lastCommittedOpTimeField = metadataObj[kLastCommittedOpTimeFieldName];
    if (lastCommittedOpTimeField.eoo()) {
        return Status::OK();
    }

    invariant(lastCommittedOpTimeField.type() == BSONType::bsonTimestamp);

    // replySource is the HostAndPort of a single server, except when this hook is triggered
    // through DBClientReplicaSet, when it will be a replica set connection string. The
    // shardRegistry stores connection strings and hosts in its lookup table, in addition to shard
    // ids, so replySource can be correctly passed on to ShardRegistry::getShardNoReload.
    auto shard = Grid::get(_service)->shardRegistry()->getShardNoReload(replySource.toString());
    if (shard) {
        shard->updateLastCommittedOpTime(LogicalTime(lastCommittedOpTimeField.timestamp()));
    }

    return Status::OK();
}
开发者ID:ShaneHarvey,项目名称:mongo,代码行数:21,代码来源:committed_optime_metadata_hook.cpp

示例6: kill_ns

void NamespaceIndex::kill_ns(OperationContext* txn, StringData ns) {
    const NamespaceString nss(ns.toString());
    invariant(txn->lockState()->isDbLockedForMode(nss.db(), MODE_X));

    const Namespace n(ns);
    _ht->kill(txn, n);

    if (ns.size() <= Namespace::MaxNsColletionLen) {
        // Larger namespace names don't have room for $extras so they can't exist. The code
        // below would cause an "$extra: ns too large" error and stacktrace to be printed to the
        // log even though everything is fine.
        for (int i = 0; i <= 1; i++) {
            try {
                Namespace extra(n.extraName(i));
                _ht->kill(txn, extra);
            } catch (DBException&) {
                LOG(3) << "caught exception in kill_ns" << endl;
            }
        }
    }
}
开发者ID:AlexOreshkevich,项目名称:mongo,代码行数:21,代码来源:namespace_index.cpp

示例7: prepare

    Status ModifierCurrentDate::prepare(mutablebson::Element root,
                                const StringData& matchedField,
                                ExecInfo* execInfo) {

        _preparedState.reset(new PreparedState(root.getDocument()));

        // If we have a $-positional field, it is time to bind it to an actual field part.
        if (_pathReplacementPosition) {
            if (matchedField.empty()) {
                return Status(ErrorCodes::BadValue, "matched field not provided");
            }
            _preparedState->pathReplacementString = matchedField.toString();
            _updatePath.setPart(_pathReplacementPosition, _preparedState->pathReplacementString);
        }

        // Locate the field name in 'root'. Note that we may not have all the parts in the path
        // in the doc -- which is fine. Our goal now is merely to reason about whether this mod
        // apply is a noOp or whether is can be in place. The remaining path, if missing, will
        // be created during the apply.
        Status status = pathsupport::findLongestPrefix(_updatePath,
                                                root,
                                                &_preparedState->idxFound,
                                                &_preparedState->elemFound);

        // FindLongestPrefix may say the path does not exist at all, which is fine here, or
        // that the path was not viable or otherwise wrong, in which case, the mod cannot
        // proceed.
        if (status.code() == ErrorCodes::NonExistentPath) {
            _preparedState->elemFound = root.getDocument().end();
        }
        else if (!status.isOK()) {
            return status;
        }

        // We register interest in the field name. The driver needs this info to sort out if
        // there is any conflict among mods.
        execInfo->fieldRef[0] = &_updatePath;

        return Status::OK();
    }
开发者ID:Cassie90,项目名称:mongo,代码行数:40,代码来源:modifier_current_date.cpp

示例8: validateDBName

Database::Database(OperationContext* txn, StringData name, DatabaseCatalogEntry* dbEntry)
    : _name(name.toString()),
      _dbEntry(dbEntry),
      _profileName(_name + ".system.profile"),
      _indexesName(_name + ".system.indexes"),
      _viewsName(_name + ".system.views"),
      _views(txn, this) {
    Status status = validateDBName(_name);
    if (!status.isOK()) {
        warning() << "tried to open invalid db: " << _name << endl;
        uasserted(10028, status.toString());
    }

    _profile = serverGlobalParams.defaultProfile;

    list<string> collections;
    _dbEntry->getCollectionNamespaces(&collections);
    for (list<string>::const_iterator it = collections.begin(); it != collections.end(); ++it) {
        const string ns = *it;
        _collections[ns] = _getOrCreateCollectionInstance(txn, ns);
    }
}
开发者ID:CaffeineForCode,项目名称:mongo,代码行数:22,代码来源:database.cpp

示例9: tryAcquireAuthzUpdateLock

    bool AuthzManagerExternalStateMongos::tryAcquireAuthzUpdateLock(const StringData& why) {
        boost::lock_guard<boost::mutex> lkLocal(_distLockGuard);
        if (_authzDataUpdateLock.get()) {
            return false;
        }

        // Temporarily put into an auto_ptr just in case there is an exception thrown during
        // lock acquisition.
        std::auto_ptr<ScopedDistributedLock> lockHolder(new ScopedDistributedLock(
                configServer.getConnectionString(), "authorizationData"));
        lockHolder->setLockMessage(why.toString());

        std::string errmsg;
        if (!lockHolder->acquire(_authzUpdateLockAcquisitionTimeoutMillis, &errmsg)) {
            warning() <<
                    "Error while attempting to acquire distributed lock for user modification: " <<
                    errmsg << endl;
            return false;
        }
        _authzDataUpdateLock.reset(lockHolder.release());
        return true;
    }
开发者ID:AndrewCEmil,项目名称:mongo,代码行数:22,代码来源:authz_manager_external_state_s.cpp

示例10: runCommandWithMetadata

rpc::UniqueReply MockRemoteDBServer::runCommandWithMetadata(MockRemoteDBServer::InstanceID id,
                                                            StringData database,
                                                            StringData commandName,
                                                            const BSONObj& metadata,
                                                            const BSONObj& commandArgs) {
    checkIfUp(id);
    std::string cmdName = commandName.toString();

    BSONObj reply;
    {
        scoped_spinlock lk(_lock);

        uassert(ErrorCodes::IllegalOperation,
                str::stream() << "no reply for command: " << commandName,
                _cmdMap.count(cmdName));

        reply = _cmdMap[cmdName]->next();
    }

    if (_delayMilliSec > 0) {
        mongo::sleepmillis(_delayMilliSec);
    }

    checkIfUp(id);

    {
        scoped_spinlock lk(_lock);
        _cmdCount++;
    }

    // We need to construct a reply message - it will always be read through a view so it
    // doesn't matter whether we use CommandReplBuilder or LegacyReplyBuilder
    auto message = rpc::CommandReplyBuilder{}
                       .setMetadata(rpc::makeEmptyMetadata())
                       .setCommandReply(reply)
                       .done();
    auto replyView = stdx::make_unique<rpc::CommandReply>(message.get());
    return rpc::UniqueReply(std::move(message), std::move(replyView));
}
开发者ID:Andiry,项目名称:mongo,代码行数:39,代码来源:mock_remote_db_server.cpp

示例11: checkUniqueIndexConstraints

        static Status checkUniqueIndexConstraints(OperationContext* txn,
                                                  const StringData& ns,
                                                  const BSONObj& newIdxKey) {
            txn->lockState()->assertWriteLocked( ns );

            if ( shardingState.enabled() ) {
                CollectionMetadataPtr metadata(
                        shardingState.getCollectionMetadata( ns.toString() ));

                if ( metadata ) {
                    ShardKeyPattern shardKeyPattern(metadata->getKeyPattern());
                    if (!shardKeyPattern.isUniqueIndexCompatible(newIdxKey)) {
                        return Status(ErrorCodes::CannotCreateIndex,
                            str::stream() << "cannot create unique index over " << newIdxKey
                                          << " with shard key pattern "
                                          << shardKeyPattern.toBSON());
                    }
                }
            }

            return Status::OK();
        }
开发者ID:Aaron20141021,项目名称:mongo,代码行数:22,代码来源:create_indexes.cpp

示例12: curwrap

StatusWith<std::string> WiredTigerUtil::getMetadata(OperationContext* opCtx, StringData uri) {
    invariant(opCtx);
    WiredTigerCursor curwrap("metadata:create", WiredTigerSession::kMetadataTableId, false, opCtx);
    WT_CURSOR* cursor = curwrap.get();
    invariant(cursor);
    std::string strUri = uri.toString();
    cursor->set_key(cursor, strUri.c_str());
    int ret = cursor->search(cursor);
    if (ret == WT_NOTFOUND) {
        return StatusWith<std::string>(ErrorCodes::NoSuchKey,
                                       str::stream() << "Unable to find metadata for " << uri);
    } else if (ret != 0) {
        return StatusWith<std::string>(wtRCToStatus(ret));
    }
    const char* metadata = NULL;
    ret = cursor->get_value(cursor, &metadata);
    if (ret != 0) {
        return StatusWith<std::string>(wtRCToStatus(ret));
    }
    invariant(metadata);
    return StatusWith<std::string>(metadata);
}
开发者ID:ChineseDr,项目名称:mongo,代码行数:22,代码来源:wiredtiger_util.cpp

示例13: _createIdentPrefix

    // non public api
    Status RocksEngine::_createIdentPrefix(StringData ident) {
        uint32_t prefix = 0;
        {
            boost::mutex::scoped_lock lk(_identPrefixMapMutex);
            if (_identPrefixMap.find(ident) != _identPrefixMap.end()) {
                // already exists
                return Status::OK();
            }

            prefix = ++_maxPrefix;
            _identPrefixMap[ident] = prefix;
        }

        BSONObjBuilder builder;
        builder.append("prefix", static_cast<int32_t>(prefix));
        BSONObj config = builder.obj();

        auto s = _db->Put(rocksdb::WriteOptions(), kMetadataPrefix + ident.toString(),
                          rocksdb::Slice(config.objdata(), config.objsize()));

        return toMongoStatus(s);
    }
开发者ID:rueckstiess,项目名称:mongo,代码行数:23,代码来源:rocks_engine.cpp

示例14: dropCollection

Status KVCatalog::dropCollection(OperationContext* opCtx, StringData ns) {
    invariant(opCtx->lockState() == NULL ||
              opCtx->lockState()->isDbLockedForMode(nsToDatabaseSubstring(ns), MODE_X));
    std::unique_ptr<Lock::ResourceLock> rLk;
    if (!_isRsThreadSafe && opCtx->lockState()) {
        rLk.reset(new Lock::ResourceLock(opCtx->lockState(), resourceIdCatalogMetadata, MODE_X));
    }

    stdx::lock_guard<stdx::mutex> lk(_identsLock);
    const NSToIdentMap::iterator it = _idents.find(ns.toString());
    if (it == _idents.end()) {
        return Status(ErrorCodes::NamespaceNotFound, "collection not found");
    }

    opCtx->recoveryUnit()->registerChange(new RemoveIdentChange(this, ns, it->second));

    LOG(1) << "deleting metadata for " << ns << " @ " << it->second.storedLoc;
    _rs->deleteRecord(opCtx, it->second.storedLoc);
    _idents.erase(it);

    return Status::OK();
}
开发者ID:Andiry,项目名称:mongo,代码行数:22,代码来源:kv_catalog.cpp

示例15:

std::unique_ptr<mongo::RecordStore> KVEngine::getRecordStore(OperationContext* opCtx,
                                                             StringData ns,
                                                             StringData ident,
                                                             const CollectionOptions& options) {
    std::unique_ptr<mongo::RecordStore> recordStore;
    if (options.capped) {
        if (NamespaceString::oplog(ns))
            _visibilityManager = std::make_unique<VisibilityManager>();
        recordStore = std::make_unique<RecordStore>(
            ns,
            ident,
            options.capped,
            options.cappedSize ? options.cappedSize : kDefaultCappedSizeBytes,
            options.cappedMaxDocs ? options.cappedMaxDocs : -1,
            /*cappedCallback*/ nullptr,
            _visibilityManager.get());
    } else {
        recordStore = std::make_unique<RecordStore>(ns, ident, options.capped);
    }
    _idents[ident.toString()] = true;
    return recordStore;
}
开发者ID:visualzhou,项目名称:mongo,代码行数:22,代码来源:biggie_kv_engine.cpp


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