本文整理汇总了C++中BoxController_sptr::shouldSplitBoxes方法的典型用法代码示例。如果您正苦于以下问题:C++ BoxController_sptr::shouldSplitBoxes方法的具体用法?C++ BoxController_sptr::shouldSplitBoxes怎么用?C++ BoxController_sptr::shouldSplitBoxes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BoxController_sptr
的用法示例。
在下文中一共展示了BoxController_sptr::shouldSplitBoxes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exec
//.........这里部分代码省略.........
// To track when to split up boxes
this->failedDetectorLookupCount = 0;
size_t eventsAdded = 0;
size_t approxEventsInOutput = 0;
size_t lastNumBoxes = ws->getBoxController()->getTotalNumMDBoxes();
if (DODEBUG)
g_log.information() << cputim << ": initial setup. There are "
<< lastNumBoxes << " MDBoxes.\n";
for (size_t wi = 0; wi < m_inWS->getNumberHistograms(); wi++) {
// Get an idea of how many events we'll be adding
size_t eventsAdding = m_inWS->blocksize();
if (m_inEventWS && !OneEventPerBin)
eventsAdding = m_inEventWS->getEventList(wi).getNumberEvents();
if (MultiThreadedAdding) {
// Equivalent to calling "this->convertSpectrum(wi)"
boost::function<void()> func =
boost::bind(&ConvertToDiffractionMDWorkspace::convertSpectrum, &*this,
static_cast<int>(wi));
// Give this task to the scheduler
double cost = static_cast<double>(eventsAdding);
ts->push(new FunctionTask(func, cost));
} else {
// Not thread-safe. Just add right now
this->convertSpectrum(static_cast<int>(wi));
}
// Keep a running total of how many events we've added
eventsAdded += eventsAdding;
approxEventsInOutput += eventsAdding;
if (bc->shouldSplitBoxes(approxEventsInOutput, eventsAdded, lastNumBoxes)) {
if (DODEBUG)
g_log.information() << cputim << ": Added tasks worth " << eventsAdded
<< " events. WorkspaceIndex " << wi << std::endl;
// Do all the adding tasks
tp.joinAll();
if (DODEBUG)
g_log.information() << cputim
<< ": Performing the addition of these events.\n";
// Now do all the splitting tasks
ws->splitAllIfNeeded(ts);
if (ts->size() > 0)
prog->doReport("Splitting Boxes");
tp.joinAll();
// Count the new # of boxes.
lastNumBoxes = ws->getBoxController()->getTotalNumMDBoxes();
if (DODEBUG)
g_log.information() << cputim
<< ": Performing the splitting. There are now "
<< lastNumBoxes << " boxes.\n";
eventsAdded = 0;
}
}
if (this->failedDetectorLookupCount > 0) {
if (this->failedDetectorLookupCount == 1)
g_log.warning() << "Unable to find a detector for "
<< this->failedDetectorLookupCount
<< " spectrum. It has been skipped." << std::endl;
else
g_log.warning() << "Unable to find detectors for "
示例2: slice
//.........这里部分代码省略.........
MDImplicitFunction *function = this->getImplicitFunctionForChunk(NULL, NULL);
std::vector<API::IMDNode *> 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)
API::IMDNode::sortObjByID(boxes);
Progress *prog = new Progress(this, 0.0, 1.0, boxes.size());
// The root of the output workspace
MDBoxBase<OMDE, ond> *outRootBox = outWS->getBox();
// if target workspace has events, we should count them as added
uint64_t totalAdded = outWS->getNEvents();
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();
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)) {
// Now transform to the output dimensions
m_transformFromOriginal->apply(inCenter, outCenter);
// Create the event
OMDE newEvent(it->getSignal(), it->getErrorSquared(), outCenter);
// Copy extra data, if any
copyEvent(*it, newEvent);
// Add it to the workspace
outRootBox->addEvent(newEvent);
numSinceSplit++;
}
}
box->releaseEvents();
// Ask BC if one needs to split boxes
if (obc->shouldSplitBoxes(totalAdded, numSinceSplit, lastNumBoxes))
// if (numSinceSplit > 20000000 || (i == int(boxes.size()-1)))
{
// This splits up all the boxes according to split thresholds and sizes.
Kernel::ThreadScheduler *ts = new ThreadSchedulerFIFO();
ThreadPool tp(ts);
outWS->splitAllIfNeeded(ts);
tp.joinAll();
// Accumulate stats
totalAdded += numSinceSplit;
numSinceSplit = 0;
lastNumBoxes = obc->getTotalNumMDBoxes();
// Progress reporting
if (!fileBackedWS)
prog->report(i);
}
if (fileBackedWS) {
if (!(i % 10))
prog->report(i);
}
} // is box
} // for each box in the vector
prog->report();
outWS->splitAllIfNeeded(NULL);
// Refresh all cache.
outWS->refreshCache();
g_log.notice() << totalAdded << " " << OMDE::getTypeName()
<< "'s added to the output workspace." << std::endl;
if (outWS->isFileBacked()) {
// Update the file-back-end
g_log.notice() << "Running SaveMD" << std::endl;
IAlgorithm_sptr alg = createChildAlgorithm("SaveMD");
alg->setProperty("UpdateFileBackEnd", true);
alg->setProperty("InputWorkspace", outWS);
alg->executeAsChildAlg();
}
// return the size of the input workspace write buffer to its initial value
// bc->setCacheParameters(sizeof(MDE),writeBufSize);
this->setProperty("OutputWorkspace",
boost::dynamic_pointer_cast<IMDEventWorkspace>(outWS));
delete prog;
}