bool UniPAX::PublicationXref::merge(PublicationXref& object) { if (!object.getYear() != 0) { if (!getYear() != 0) { if (getYear() != object.getYear()) { std::cerr << "Error during merging: UniPAX::PublicationXref::year not equal ..." << getYear() << " != " << object.getYear() << std::endl; return false; } } else setYear(object.getYear()); } { std::set<std::string> tmp(getUrls().begin(), getUrls().end()); for (std::vector<std::string>::iterator it = object.getUrls().begin(); it != object.getUrls().end(); it++) { tmp.insert(*it); } getUrls().assign(tmp.begin(), tmp.end()); } if (!object.getTitle().empty()) { if (!getTitle().empty()) { if (getTitle() != object.getTitle()) { std::cerr << "Error during merging: UniPAX::PublicationXref::title not equal ..." << getTitle() << " != " << object.getTitle() << std::endl; return false; } } else setTitle(object.getTitle()); } { std::set<std::string> tmp(getSources().begin(), getSources().end()); for (std::vector<std::string>::iterator it = object.getSources().begin(); it != object.getSources().end(); it++) { tmp.insert(*it); } getSources().assign(tmp.begin(), tmp.end()); } { std::set<std::string> tmp(getAuthors().begin(), getAuthors().end()); for (std::vector<std::string>::iterator it = object.getAuthors().begin(); it != object.getAuthors().end(); it++) { tmp.insert(*it); } getAuthors().assign(tmp.begin(), tmp.end()); } return UniPAX::Xref::merge(object); }
void evaluateProFile(const ProFileEvaluator &visitor, QHash<QByteArray, QStringList> *varMap, const QString &projectDir) { QStringList baseVPaths; baseVPaths += visitor.absolutePathValues(QLatin1String("VPATH"), projectDir); baseVPaths << projectDir; // QMAKE_ABSOLUTE_SOURCE_PATH baseVPaths += visitor.absolutePathValues(QLatin1String("DEPENDPATH"), projectDir); baseVPaths.removeDuplicates(); QStringList sourceFiles; QString codecForTr; QString codecForSource; QStringList tsFileNames; // app/lib template sourceFiles += getSources("SOURCES", "VPATH_SOURCES", baseVPaths, projectDir, visitor); sourceFiles += getSources("FORMS", "VPATH_FORMS", baseVPaths, projectDir, visitor); sourceFiles += getSources("FORMS3", "VPATH_FORMS3", baseVPaths, projectDir, visitor); QStringList vPathsInc = baseVPaths; vPathsInc += visitor.absolutePathValues(QLatin1String("INCLUDEPATH"), projectDir); vPathsInc.removeDuplicates(); sourceFiles += visitor.absoluteFileValues(QLatin1String("HEADERS"), projectDir, vPathsInc, 0); QDir proDir(projectDir); foreach (const QString &tsFile, visitor.values(QLatin1String("TRANSLATIONS"))) tsFileNames << QFileInfo(proDir, tsFile).filePath(); QStringList trcodec = visitor.values(QLatin1String("CODEC")) + visitor.values(QLatin1String("DEFAULTCODEC")) + visitor.values(QLatin1String("CODECFORTR")); if (!trcodec.isEmpty()) codecForTr = trcodec.last(); QStringList srccodec = visitor.values(QLatin1String("CODECFORSRC")); if (!srccodec.isEmpty()) codecForSource = srccodec.last(); sourceFiles.sort(); sourceFiles.removeDuplicates(); tsFileNames.sort(); tsFileNames.removeDuplicates(); varMap->insert("SOURCES", sourceFiles); varMap->insert("CODECFORTR", QStringList() << codecForTr); varMap->insert("CODECFORSRC", QStringList() << codecForSource); varMap->insert("TRANSLATIONS", tsFileNames); }
dbitvec Search_by_item::getGrammarStem_sources() { //just for stems if (type == STEM) { return getSources("stem", id); } else { _warning << "getGrammarStem_sources() does not work for PREFIX or SUFFIX\n"; return INVALID_BITSET; } }
CustomSource::CustomSource(QObject *parent, const QStringList args) : AbstractExtSysMonSource(parent, args) { Q_ASSERT(args.count() == 0); qCDebug(LOG_ESM) << __PRETTY_FUNCTION__; extScripts = new ExtItemAggregator<ExtScript>(nullptr, QString("scripts")); m_sources = getSources(); }
void solver::solveCircuit(circuit C) { if(!C.goodCircuit()) throw "Circuit is not well formed"; getImpedance(C); getIncidence(C); getSources(C); // Need to check sources frequencies, impedace depends on it }
std::vector<T> getModelObjectSources(IddObjectType iddObjectType) const { std::vector<T> result; std::vector<WorkspaceObject> wos = getSources(iddObjectType); for (const WorkspaceObject& wo : wos) { // assume iddObjectType is valid for T result.push_back(wo.cast<T>()); } return result; }
std::vector<openstudio::IdfObject> PhotovoltaicPerformance_Impl::remove() { std::vector<openstudio::IdfObject> result; if (getSources(GeneratorPhotovoltaic::iddObjectType()).empty()){ result = ModelObject_Impl::remove(); } return result; }
virtual bool run(OperationContext* txn, const string& db, BSONObj& cmdObj, int options, string& errmsg, BSONObjBuilder& result) { const std::string ns = parseNs(db, cmdObj); if (nsToCollectionSubstring(ns).empty()) { errmsg = "missing collection name"; return false; } NamespaceString nss(ns); // Parse the options for this request. auto request = AggregationRequest::parseFromBSON(nss, cmdObj); if (!request.isOK()) { return appendCommandStatus(result, request.getStatus()); } // Set up the ExpressionContext. intrusive_ptr<ExpressionContext> expCtx = new ExpressionContext(txn, request.getValue()); expCtx->tempDir = storageGlobalParams.dbpath + "/_tmp"; // Parse the pipeline. auto statusWithPipeline = Pipeline::parse(request.getValue().getPipeline(), expCtx); if (!statusWithPipeline.isOK()) { return appendCommandStatus(result, statusWithPipeline.getStatus()); } auto pipeline = std::move(statusWithPipeline.getValue()); auto resolvedNamespaces = resolveInvolvedNamespaces(txn, pipeline, expCtx); if (!resolvedNamespaces.isOK()) { return appendCommandStatus(result, resolvedNamespaces.getStatus()); } expCtx->resolvedNamespaces = std::move(resolvedNamespaces.getValue()); unique_ptr<ClientCursorPin> pin; // either this OR the exec will be non-null unique_ptr<PlanExecutor> exec; auto curOp = CurOp::get(txn); { // This will throw if the sharding version for this connection is out of date. If the // namespace is a view, the lock will be released before re-running the aggregation. // Otherwise, the lock must be held continuously from now until we have we created both // the output ClientCursor and the input executor. This ensures that both are using the // same sharding version that we synchronize on here. This is also why we always need to // create a ClientCursor even when we aren't outputting to a cursor. See the comment on // ShardFilterStage for more details. AutoGetCollectionOrViewForRead ctx(txn, nss); Collection* collection = ctx.getCollection(); // If running $collStats on a view, we do not resolve the view since we want stats // on this view namespace. auto startsWithCollStats = [&pipeline]() { const Pipeline::SourceContainer& sources = pipeline->getSources(); return !sources.empty() && dynamic_cast<DocumentSourceCollStats*>(sources.front().get()); }; // If this is a view, resolve it by finding the underlying collection and stitching view // pipelines and this request's pipeline together. We then release our locks before // recursively calling run, which will re-acquire locks on the underlying collection. // (The lock must be released because recursively acquiring locks on the database will // prohibit yielding.) auto view = ctx.getView(); if (view && !startsWithCollStats()) { auto viewDefinition = ViewShardingCheck::getResolvedViewIfSharded(txn, ctx.getDb(), view); if (!viewDefinition.isOK()) { return appendCommandStatus(result, viewDefinition.getStatus()); } if (!viewDefinition.getValue().isEmpty()) { ViewShardingCheck::appendShardedViewStatus(viewDefinition.getValue(), &result); return false; } auto resolvedView = ctx.getDb()->getViewCatalog()->resolveView(txn, nss); if (!resolvedView.isOK()) { return appendCommandStatus(result, resolvedView.getStatus()); } // With the view resolved, we can relinquish locks. ctx.releaseLocksForView(); // Parse the resolved view into a new aggregation request. auto viewCmd = resolvedView.getValue().asExpandedViewAggregation(request.getValue()); if (!viewCmd.isOK()) { return appendCommandStatus(result, viewCmd.getStatus()); } bool status = this->run(txn, db, viewCmd.getValue(), options, errmsg, result); { // Set the namespace of the curop back to the view namespace so ctx records // stats on this view namespace on destruction. stdx::lock_guard<Client>(*txn->getClient()); curOp->setNS_inlock(nss.ns()); } return status; } // If the pipeline does not have a user-specified collation, set it from the collection // default. if (request.getValue().getCollation().isEmpty() && collection && collection->getDefaultCollator()) { invariant(!expCtx->getCollator()); expCtx->setCollator(collection->getDefaultCollator()->clone()); } // Propagate the ExpressionContext throughout all of the pipeline's stages and // expressions. pipeline->injectExpressionContext(expCtx); // The pipeline must be optimized after the correct collator has been set on it (by // injecting the ExpressionContext containing the collator). This is necessary because // optimization may make string comparisons, e.g. optimizing {$eq: [<str1>, <str2>]} to // a constant. pipeline->optimizePipeline(); if (kDebugBuild && !expCtx->isExplain && !expCtx->inShard) { // Make sure all operations round-trip through Pipeline::serialize() correctly by // re-parsing every command in debug builds. This is important because sharded // aggregations rely on this ability. Skipping when inShard because this has // already been through the transformation (and this un-sets expCtx->inShard). pipeline = reparsePipeline(pipeline, request.getValue(), expCtx); } // This does mongod-specific stuff like creating the input PlanExecutor and adding // it to the front of the pipeline if needed. PipelineD::prepareCursorSource(collection, pipeline); // Create the PlanExecutor which returns results from the pipeline. The WorkingSet // ('ws') and the PipelineProxyStage ('proxy') will be owned by the created // PlanExecutor. auto ws = make_unique<WorkingSet>(); auto proxy = make_unique<PipelineProxyStage>(txn, pipeline, ws.get()); auto statusWithPlanExecutor = (NULL == collection) ? PlanExecutor::make( txn, std::move(ws), std::move(proxy), nss.ns(), PlanExecutor::YIELD_MANUAL) : PlanExecutor::make( txn, std::move(ws), std::move(proxy), collection, PlanExecutor::YIELD_MANUAL); invariant(statusWithPlanExecutor.isOK()); exec = std::move(statusWithPlanExecutor.getValue()); { auto planSummary = Explain::getPlanSummary(exec.get()); stdx::lock_guard<Client>(*txn->getClient()); curOp->setPlanSummary_inlock(std::move(planSummary)); } if (collection) { PlanSummaryStats stats; Explain::getSummaryStats(*exec, &stats); collection->infoCache()->notifyOfQuery(txn, stats.indexesUsed); } if (collection) { const bool isAggCursor = true; // enable special locking behavior ClientCursor* cursor = new ClientCursor(collection->getCursorManager(), exec.release(), nss.ns(), txn->recoveryUnit()->isReadingFromMajorityCommittedSnapshot(), 0, cmdObj.getOwned(), isAggCursor); pin.reset(new ClientCursorPin(collection->getCursorManager(), cursor->cursorid())); // Don't add any code between here and the start of the try block. } // At this point, it is safe to release the collection lock. // - In the case where we have a collection: we will need to reacquire the // collection lock later when cleaning up our ClientCursorPin. // - In the case where we don't have a collection: our PlanExecutor won't be // registered, so it will be safe to clean it up outside the lock. invariant(!exec || !collection); } try { // Unless set to true, the ClientCursor created above will be deleted on block exit. bool keepCursor = false; // Use of the aggregate command without specifying to use a cursor is deprecated. // Applications should migrate to using cursors. Cursors are strictly more useful than // outputting the results as a single document, since results that fit inside a single // BSONObj will also fit inside a single batch. // // We occasionally log a deprecation warning. if (!request.getValue().isCursorCommand()) { RARELY { warning() << "Use of the aggregate command without the 'cursor' " "option is deprecated. See " "http://dochub.mongodb.org/core/aggregate-without-cursor-deprecation."; } } // If both explain and cursor are specified, explain wins. if (expCtx->isExplain) { result << "stages" << Value(pipeline->writeExplainOps()); } else if (request.getValue().isCursorCommand()) { keepCursor = handleCursorCommand(txn, nss.ns(), pin.get(), pin ? pin->c()->getExecutor() : exec.get(), request.getValue(), result); } else { pipeline->run(result); } if (!expCtx->isExplain) { PlanSummaryStats stats; Explain::getSummaryStats(pin ? *pin->c()->getExecutor() : *exec.get(), &stats); curOp->debug().setPlanSummaryMetrics(stats); curOp->debug().nreturned = stats.nReturned; } // Clean up our ClientCursorPin, if needed. We must reacquire the collection lock // in order to do so. if (pin) { // We acquire locks here with DBLock and CollectionLock instead of using // AutoGetCollectionForRead. AutoGetCollectionForRead will throw if the // sharding version is out of date, and we don't care if the sharding version // has changed. Lock::DBLock dbLock(txn->lockState(), nss.db(), MODE_IS); Lock::CollectionLock collLock(txn->lockState(), nss.ns(), MODE_IS); if (keepCursor) { pin->release(); } else { pin->deleteUnderlying(); } } } catch (...) {