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


C++ BatchedCommandResponse::isSingleUpsertedSet方法代码示例

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


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

示例1: areResponsesEqual

    static bool areResponsesEqual( const BatchedCommandResponse& responseA,
                                   const BatchedCommandResponse& responseB ) {

        // TODO: Better reporting of why not equal
        if ( responseA.getOk() != responseB.getOk() )
            return false;
        if ( responseA.getN() != responseB.getN() )
            return false;
        if ( responseA.isSingleUpsertedSet() != responseB.isSingleUpsertedSet() )
            return false;
        if ( responseA.isUpsertDetailsSet() != responseB.isUpsertDetailsSet() )
            return false;

        if ( responseA.isSingleUpsertedSet() ) {
            BSONObj upsertA = responseA.getSingleUpserted();
            BSONObj upsertB = responseB.getSingleUpserted();
            if ( upsertA.woCompare( upsertB ) != 0 )
                return false;
        }

        if ( responseA.isUpsertDetailsSet() ) {
            // TODO:
        }

        if ( responseA.getOk() )
            return true;

        // TODO: Compare errors here

        return true;
    }
开发者ID:davipeterlini,项目名称:mongo,代码行数:31,代码来源:config_coordinator.cpp

示例2: batchErrorToLastError

    void batchErrorToLastError( const BatchedCommandRequest& request,
                                const BatchedCommandResponse& response,
                                LastError* error ) {

        scoped_ptr<BatchedErrorDetail> topLevelError;
        BatchedErrorDetail* lastBatchError = NULL;

        if ( !response.getOk() ) {

            int code = response.getErrCode();

            // Check for batch error
            // We don't care about write concern errors, these happen in legacy mode in GLE
            if ( code != ErrorCodes::WriteConcernFailed && !response.isErrDetailsSet() ) {
                // Top-level error, all writes failed
                topLevelError.reset( new BatchedErrorDetail );
                buildErrorFromResponse( response, topLevelError.get() );
                lastBatchError = topLevelError.get();
            }
            else if ( response.isErrDetailsSet() ) {
                // The last error in the batch is always reported - this matches expected COE
                // semantics for insert batches and works for single writes
                lastBatchError = response.getErrDetails().back();
            }
        }

        // Record an error if one exists
        if ( lastBatchError ) {
            error->raiseError( lastBatchError->getErrCode(),
                               lastBatchError->getErrMessage().c_str() );
            return;
        }

        // Record write stats otherwise
        // NOTE: For multi-write batches, our semantics change a little because we don't have
        // un-aggregated "n" stats.
        if ( request.getBatchType() == BatchedCommandRequest::BatchType_Update ) {

            BSONObj upsertedId;
            if ( response.isSingleUpsertedSet() ) upsertedId = response.getSingleUpserted();
            else if( response.isUpsertDetailsSet() ) {
                // Only report the very last item's upserted id if applicable
                if ( response.getUpsertDetails().back()->getIndex() + 1
                     == static_cast<int>( request.sizeWriteOps() ) ) {
                    upsertedId = response.getUpsertDetails().back()->getUpsertedID();
                }
            }

            int numUpserted = 0;
            if ( response.isSingleUpsertedSet() )
                ++numUpserted;
            else if ( response.isUpsertDetailsSet() )
                numUpserted += response.sizeUpsertDetails();

            int numUpdated = response.getN() - numUpserted;
            dassert( numUpdated >= 0 );
            error->recordUpdate( numUpdated > 0, response.getN(), upsertedId );
        }
        else if ( request.getBatchType() == BatchedCommandRequest::BatchType_Delete ) {
            error->recordDelete( response.getN() );
        }
    }
开发者ID:Convey-Compliance,项目名称:mongo,代码行数:62,代码来源:batch_upconvert.cpp


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