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


C++ BoxController_sptr::getDiskBuffer方法代码示例

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


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

示例1: slice

  void SliceMD::slice(typename MDEventWorkspace<MDE, nd>::sptr ws)
  {
    // Create the ouput workspace
    typename MDEventWorkspace<OMDE, ond>::sptr outWS(new MDEventWorkspace<OMDE, ond>());
    for (size_t od=0; od < m_binDimensions.size(); od++)
      outWS->addDimension(m_binDimensions[od]);
    outWS->initialize();
    // Copy settings from the original box controller
    BoxController_sptr bc = ws->getBoxController();

    // store wrute buffer size for the future 
    uint64_t writeBufSize = bc->getDiskBuffer().getWriteBufferSize();
    // and disable write buffer (if any) for input MD Events for this algorithm purposes;
    //bc->setCacheParameters(1,0);

    BoxController_sptr obc = outWS->getBoxController();
    // Use the "number of bins" as the "split into" parameter
    for (size_t od=0; od < m_binDimensions.size(); od++)
      obc->setSplitInto(od, m_binDimensions[od]->getNBins());
    obc->setSplitThreshold(bc->getSplitThreshold());

    bool bTakeDepthFromInputWorkspace = getProperty("TakeMaxRecursionDepthFromInput");
    int tempDepth =  getProperty("MaxRecursionDepth");
    size_t maxDepth = bTakeDepthFromInputWorkspace? bc->getMaxDepth() : size_t(tempDepth);
    obc->setMaxDepth(maxDepth);
    // the buffer size for resulting workspace; reasonable size is at least 10 data chunk sizes (nice to verify)
    size_t outputSize = writeBufSize;
    if(outputSize<10*obc->getDataChunk())outputSize=10*obc->getDataChunk();
    obc->setCacheParameters(sizeof(OMDE),outputSize);

    obc->resetNumBoxes();
    // Perform the first box splitting
    outWS->splitBox();

    // --- File back end ? ----------------
    std::string filename = getProperty("OutputFilename");
    if (!filename.empty())
    {
      // First save to the NXS file
      g_log.notice() << "Running SaveMD" << std::endl;
      IAlgorithm_sptr alg = createChildAlgorithm("SaveMD");
      alg->setPropertyValue("Filename", filename);
      alg->setProperty("InputWorkspace", outWS);
      alg->executeAsChildAlg();
      // And now re-load it with this file as the backing.
      g_log.notice() << "Running LoadMD" << std::endl;
      alg = createChildAlgorithm("LoadMD");
      alg->setPropertyValue("Filename", filename);
      alg->setProperty("FileBackEnd", true);
      alg->setPropertyValue("Memory", getPropertyValue("Memory"));
      alg->executeAsChildAlg();
      // Replace the workspace with the loaded, file-backed one
      IMDWorkspace_sptr temp;
      temp = alg->getProperty("OutputWorkspace");
      outWS = boost::dynamic_pointer_cast<MDEventWorkspace<OMDE, ond> >(temp);
    }


    // Function defining which events (in the input dimensions) to place in the output
    MDImplicitFunction * function = this->getImplicitFunctionForChunk(NULL, NULL);

    std::vector<Kernel::ISaveable *> boxes;
    // Leaf-only; no depth limit; with the implicit function passed to it.
    ws->getBox()->getBoxes(boxes, 1000, true, function);
    // Sort boxes by file position IF file backed. This reduces seeking time, hopefully.
    bool fileBackedWS = bc->isFileBacked();
    if (fileBackedWS)
      Kernel::ISaveable::sortObjByFilePos(boxes);

    Progress * prog = new Progress(this, 0.0, 1.0, boxes.size());

    // The root of the output workspace
    MDBoxBase<OMDE,ond>* outRootBox = outWS->getBox();

    uint64_t totalAdded = 0;
    uint64_t numSinceSplit = 0;

    // Go through every box for this chunk.
    //PARALLEL_FOR_IF( !bc->isFileBacked() )
    for (int i=0; i<int(boxes.size()); i++)
    {
      MDBox<MDE,nd> * box = dynamic_cast<MDBox<MDE,nd> *>(boxes[i]);
      // Perform the binning in this separate method.
      if (box)
      {
        // An array to hold the rotated/transformed coordinates
        coord_t outCenter[ond];

        const std::vector<MDE> & events = box->getConstEvents();
        bool clearBox = box->wasSaved();

        typename std::vector<MDE>::const_iterator it = events.begin();
        typename std::vector<MDE>::const_iterator it_end = events.end();
        for (; it != it_end; it++)
        {
          // Cache the center of the event (again for speed)
          const coord_t * inCenter = it->getCenter();

          if (function->isPointContained(inCenter))
          {
//.........这里部分代码省略.........
开发者ID:trnielsen,项目名称:mantid,代码行数:101,代码来源:SliceMD.cpp


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