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


C++ intrusive_ptr::manageDependencies方法代码示例

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


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

示例1: run

    bool Pipeline::run(BSONObjBuilder &result, string &errmsg,
                       const intrusive_ptr<DocumentSource> &pInputSource) {
        /*
          Analyze dependency information.

          This pushes dependencies from the end of the pipeline back to the
          front of it, and finally passes that to the input source before we
          execute the pipeline.
        */
        intrusive_ptr<DependencyTracker> pTracker(new DependencyTracker());
        for(SourceVector::reverse_iterator iter(sourceVector.rbegin()),
                listBeg(sourceVector.rend()); iter != listBeg; ++iter) {
            intrusive_ptr<DocumentSource> pTemp(*iter);
            pTemp->manageDependencies(pTracker);
        }

        pInputSource->manageDependencies(pTracker);
        
        /* chain together the sources we found */
        DocumentSource *pSource = pInputSource.get();
        for(SourceVector::iterator iter(sourceVector.begin()),
                listEnd(sourceVector.end()); iter != listEnd; ++iter) {
            intrusive_ptr<DocumentSource> pTemp(*iter);
            pTemp->setSource(pSource);
            pSource = pTemp.get();
        }
        /* pSource is left pointing at the last source in the chain */

        /*
          Iterate through the resulting documents, and add them to the result.
          We do this even if we're doing an explain, in order to capture
          the document counts and other stats.  However, we don't capture
          the result documents for explain.

          We wrap all the BSONObjBuilder calls with a try/catch in case the
          objects get too large and cause an exception.
        */
        try {
            if (explain) {
                if (!pCtx->getInRouter())
                    writeExplainShard(result, pInputSource);
                else {
                    writeExplainMongos(result, pInputSource);
                }
            }
            else
            {
                BSONArrayBuilder resultArray; // where we'll stash the results
                for(bool hasDocument = !pSource->eof(); hasDocument;
                    hasDocument = pSource->advance()) {
                    intrusive_ptr<Document> pDocument(pSource->getCurrent());

                    /* add the document to the result set */
                    BSONObjBuilder documentBuilder;
                    pDocument->toBson(&documentBuilder);
                    resultArray.append(documentBuilder.done());
                }

                result.appendArray("result", resultArray.arr());
            }
         } catch(AssertionException &ae) {
            /* 
               If its not the "object too large" error, rethrow.
               At time of writing, that error code comes from
               mongo/src/mongo/bson/util/builder.h
            */
            if (ae.getCode() != 13548)
                throw;

            /* throw the nicer human-readable error */
            uassert(16029, str::stream() <<
                    "aggregation result exceeds maximum document size limit ("
                    << (BSONObjMaxUserSize / (1024 * 1024)) << "MB)",
                    false);
         }

        return true;
    }
开发者ID:JeremyOT,项目名称:mongo,代码行数:78,代码来源:pipeline.cpp


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