void QuerySolutionNode::addCommon(stringstream* ss, int indent) const { addIndent(ss, indent + 1); *ss << "fetched = " << fetched() << endl; addIndent(ss, indent + 1); *ss << "sortedByDiskLoc = " << sortedByDiskLoc() << endl; addIndent(ss, indent + 1); *ss << "getSort = ["; for (BSONObjSet::const_iterator it = getSort().begin(); it != getSort().end(); it++) { *ss << it->toString() << ", "; } *ss << "]" << endl; }
void SettingsDialogImpl::acceptClicked() { if(ui.tableWidget->rowCount() == 0) { QString errorstring = "You have to choose a player."; QMessageBox::critical( this, QString("Error in Player choose"), errorstring); return; } Settings* instance = Settings::Instance(); instance->clearPlayers(); instance->setSort( getSort() ); instance->setOngoingSort( getOngoingSort() ); instance->setPriorSort( getPriorSort() ); instance->setReloadSort( getReloadSort() ); for(int i=0; i<ui.tableWidget->rowCount(); i++) { QString player = ui.tableWidget->item(i,0)->text(); QString arg = ui.tableWidget->item(i,1)->text(); instance->addPlayer( player, arg ); } instance->setConvertNames(getConvertNames()); instance->setScanMedia(getScanMedia()); instance->setSettingsFilename(getSettingsFile()); instance->setOpacity(ui.opacitySpinbox->value()); accept(); }
void ExprSMTLIBLetPrinter::printExpression( const ref<Expr> &e, ExprSMTLIBPrinter::SMTLIB_SORT expectedSort) { map<const ref<Expr>, unsigned int>::const_iterator i = bindings.find(e); if (disablePrintedAbbreviations || i == bindings.end()) { /*There is no abbreviation for this expression so print it normally. * Do this by using the parent method. */ ExprSMTLIBPrinter::printExpression(e, expectedSort); } else { // Use binding name e.g. "?B1" /* Handle the corner case where the expectedSort * doesn't match the sort of the abbreviation. Not really very efficient * (calls bindings.find() twice), * we'll cast and call ourself again but with the correct expectedSort. */ if (getSort(e) != expectedSort) { printCastToSort(e, expectedSort); return; } // No casting is needed in this depth of recursion, just print the // abbreviation *p << BINDING_PREFIX << i->second; } }
void ExprSMTLIBPrinter::printNotEqualExpr(const ref<NeExpr> &e) { *p << "(not ("; p->pushIndent(); *p << "=" << " "; p->pushIndent(); printSeperator(); /* The "=" operators allows both sorts. We assume * that the second argument sort should be forced to be the same sort as the * first argument */ SMTLIB_SORT s = getSort(e->getKid(0)); printExpression(e->getKid(0), s); printSeperator(); printExpression(e->getKid(1), s); p->popIndent(); printSeperator(); *p << ")"; p->popIndent(); printSeperator(); *p << ")"; }
ExprSMTLIBPrinter::SMTLIB_SORT ExprSMTLIBPrinter::getSort(const ref<Expr> &e) { switch (e->getKind()) { case Expr::NotOptimized: return getSort(e->getKid(0)); // The relational operators are bools. case Expr::Eq: case Expr::Ne: case Expr::Slt: case Expr::Sle: case Expr::Sgt: case Expr::Sge: case Expr::Ult: case Expr::Ule: case Expr::Ugt: case Expr::Uge: return SORT_BOOL; // These may be bitvectors or bools depending on their width (see // printConstant and printLogicalOrBitVectorExpr). case Expr::Constant: case Expr::And: case Expr::Not: case Expr::Or: case Expr::Xor: return e->getWidth() == Expr::Bool ? SORT_BOOL : SORT_BITVECTOR; // Everything else is a bitvector. default: return SORT_BITVECTOR; } }
Sort SortManager::getSort(const std::string& name, const std::vector<Sort>& params) { assert(params.size() > 0); auto decl = mDeclarations.find(name); if (decl != mDeclarations.end()) { std::size_t arity = decl->second; if (arity != params.size()) { CARL_LOG_ERROR("carl.formula", "The sort " << name << " was declared to have " << arity << " parameters, but " << params.size() << " were given."); return Sort(0); } SortContent* sc = new SortContent(name, params); return getSort(sc, VariableType::VT_UNINTERPRETED); } auto def = mDefinitions.find(name); if (def != mDefinitions.end()) { const SortTemplate& st = def->second; if (st.first.size() != params.size()) { CARL_LOG_ERROR("carl.formula", "The sort " << name << " was defined to have " << st.first.size() << " parameters, but " << params.size() << " were given."); return Sort(0); } std::map<std::string,Sort> repl; for (std::size_t i = 0; i < params.size(); i++) repl[st.first[i]] = params[i]; return replace(st.second, repl); } CARL_LOG_ERROR("carl.formula", "The sort " << name << " was neither declared nor defined and thus cannot be instantiated."); return Sort(0); }
static VALUE wrap_Sort_init(VALUE self, VALUE _values) { const char* values = StringValuePtr(_values); Sort* p = getSort(self); new (p) Sort(values); return Qnil; }
Sort SortManager::index(const Sort& sort, const std::vector<std::size_t>& indices) { if (indices.size() == 0) return sort; const SortContent& sc = getContent(sort); SortContent* newsc = new SortContent(sc); if (newsc->indices == nullptr) newsc->indices = new std::vector<std::size_t>(indices); else newsc->indices->insert(newsc->indices->end(), indices.begin(), indices.end()); return getSort(newsc, checkIndices(sc.getUnindexed(), newsc->indices->size())); }
SortConstructorType Parser::mkUnresolvedTypeConstructor( const std::string& name, const std::vector<Type>& params) { Debug("parser") << "newSortConstructor(P)(" << name << ", " << params.size() << ")" << std::endl; SortConstructorType unresolved = d_exprManager->mkSortConstructor(name, params.size()); defineType(name, params, unresolved); Type t = getSort(name, params); d_unresolved.insert(unresolved); return unresolved; }
Sort SortManager::replace(const Sort& sort, const std::map<std::string, Sort>& parameters) { const SortContent& sc = getContent(sort); auto pIter = parameters.find(sc.name); if (pIter != parameters.end()) return pIter->second; if (sc.parameters == nullptr) return sort; std::vector<Sort> v; v.reserve(sc.parameters->size()); for (const auto& sd: *sc.parameters) v.push_back(replace(sd, parameters)); return getSort(new SortContent(sc.name, std::move(v)), VariableType::VT_UNINTERPRETED); }
void Geo2DNode::appendToString(stringstream* ss, int indent) const { addIndent(ss, indent); *ss << "GEO_2D\n"; addIndent(ss, indent + 1); *ss << "keyPattern = " << indexKeyPattern.toString() << endl; addIndent(ss, indent + 1); //*ss << "seek = " << seek.toString() << endl; //addIndent(ss, indent + 1); *ss << "fetched = " << fetched() << endl; addIndent(ss, indent + 1); *ss << "sortedByDiskLoc = " << sortedByDiskLoc() << endl; addIndent(ss, indent + 1); *ss << "getSort = " << getSort().toString() << endl; }
void LimitNode::appendToString(stringstream* ss, int indent) const { addIndent(ss, indent); *ss << "LIMIT\n"; addIndent(ss, indent + 1); *ss << "limit = " << limit << endl; addIndent(ss, indent + 1); *ss << "fetched = " << fetched() << endl; addIndent(ss, indent + 1); *ss << "sortedByDiskLoc = " << sortedByDiskLoc() << endl; addIndent(ss, indent + 1); *ss << "getSort = " << getSort().toString() << endl; addIndent(ss, indent + 1); *ss << "Child:" << endl; child->appendToString(ss, indent + 2); }
void SkipNode::appendToString(stringstream* ss, int indent) const { addIndent(ss, indent); *ss << "SKIP\n"; addIndent(ss, indent + 1); *ss << "skip= " << skip << endl; addIndent(ss, indent + 1); *ss << "fetched = " << fetched() << endl; addIndent(ss, indent + 1); *ss << "sortedByDiskLoc = " << sortedByDiskLoc() << endl; addIndent(ss, indent + 1); *ss << "getSort = " << getSort().toString() << endl; addIndent(ss, indent + 1); *ss << "Child:" << endl; child->appendToString(ss, indent + 2); }
void ProjectionNode::appendToString(stringstream* ss, int indent) const { addIndent(ss, indent); *ss << "PROJ\n"; verify(NULL != projection); addIndent(ss, indent + 1); *ss << "proj = " << projection->toString() << endl; addIndent(ss, indent + 1); *ss << "fetched = " << fetched() << endl; addIndent(ss, indent + 1); *ss << "sortedByDiskLoc = " << sortedByDiskLoc() << endl; addIndent(ss, indent + 1); *ss << "getSort = " << getSort().toString() << endl; addIndent(ss, indent + 1); *ss << "Child:" << endl; child->appendToString(ss, indent + 2); }
void CollectionScanNode::appendToString(stringstream* ss, int indent) const { addIndent(ss, indent); *ss << "COLLSCAN\n"; addIndent(ss, indent + 1); *ss << "ns = " << name << endl; if (NULL != filter) { addIndent(ss, indent + 1); *ss << " filter = " << filter->toString(); } addIndent(ss, indent + 1); *ss << "fetched = " << fetched() << endl; addIndent(ss, indent + 1); *ss << "sortedByDiskLoc = " << sortedByDiskLoc() << endl; addIndent(ss, indent + 1); *ss << "getSort = " << getSort().toString() << endl; }
void GeoNear2DNode::appendToString(stringstream* ss, int indent) const { addIndent(ss, indent); *ss << "GEO_NEAR_2D\n"; addIndent(ss, indent + 1); *ss << "keyPattern = " << indexKeyPattern.toString() << endl; addIndent(ss, indent + 1); *ss << "fetched = " << fetched() << endl; addIndent(ss, indent + 1); *ss << "sortedByDiskLoc = " << sortedByDiskLoc() << endl; addIndent(ss, indent + 1); *ss << "getSort = " << getSort().toString() << endl; addIndent(ss, indent + 1); *ss << "nearQuery = " << nq.toString() << endl; if (NULL != filter) { addIndent(ss, indent + 1); *ss << " filter = " << filter->toString(); } }
void TextNode::appendToString(stringstream* ss, int indent) const { addIndent(ss, indent); *ss << "TEXT\n"; addIndent(ss, indent + 1); *ss << "numWanted = " << _numWanted << endl; addIndent(ss, indent + 1); *ss << "keyPattern = " << _indexKeyPattern.toString() << endl; addIndent(ss, indent + 1); *ss << "fetched = " << fetched() << endl; addIndent(ss, indent + 1); *ss << "sortedByDiskLoc = " << sortedByDiskLoc() << endl; addIndent(ss, indent + 1); *ss << "getSort = " << getSort().toString() << endl; addIndent(ss, indent + 1); *ss << "query = " << _query << endl; addIndent(ss, indent + 1); *ss << "language = " << _language << endl; }
void AndSortedNode::appendToString(stringstream* ss, int indent) const { addIndent(ss, indent); *ss << "AND_SORTED"; if (NULL != filter) { addIndent(ss, indent + 1); *ss << " filter = " << filter->toString() << endl; } addIndent(ss, indent + 1); *ss << "fetched = " << fetched() << endl; addIndent(ss, indent + 1); *ss << "sortedByDiskLoc = " << sortedByDiskLoc() << endl; addIndent(ss, indent + 1); *ss << "getSort = " << getSort().toString() << endl; for (size_t i = 0; i < children.size(); ++i) { *ss << "Child " << i << ": "; children[i]->appendToString(ss, indent + 1); } }
void IndexScanNode::appendToString(stringstream* ss, int indent) const { addIndent(ss, indent); *ss << "IXSCAN\n"; addIndent(ss, indent + 1); *ss << "keyPattern = " << indexKeyPattern << endl; if (NULL != filter) { addIndent(ss, indent + 1); *ss << " filter= " << filter->toString() << endl; } addIndent(ss, indent + 1); *ss << "direction = " << direction << endl; addIndent(ss, indent + 1); *ss << "bounds = " << bounds.toString() << endl; addIndent(ss, indent + 1); *ss << "fetched = " << fetched() << endl; addIndent(ss, indent + 1); *ss << "sortedByDiskLoc = " << sortedByDiskLoc() << endl; addIndent(ss, indent + 1); *ss << "getSort = " << getSort().toString() << endl; }
void FetchNode::appendToString(stringstream* ss, int indent) const { addIndent(ss, indent); *ss << "FETCH\n"; if (NULL != filter) { addIndent(ss, indent + 1); StringBuilder sb; *ss << "filter:\n"; filter->debugString(sb, indent + 2); *ss << sb.str(); } addIndent(ss, indent + 1); *ss << "fetched = " << fetched() << endl; addIndent(ss, indent + 1); *ss << "sortedByDiskLoc = " << sortedByDiskLoc() << endl; addIndent(ss, indent + 1); *ss << "getSort = " << getSort().toString() << endl; addIndent(ss, indent + 1); *ss << "Child:" << endl; child->appendToString(ss, indent + 2); }
static VALUE wrap_Sort_toString(VALUE self) { return rb_str_new2(getSort(self)->toString().c_str()); }
Sort SortManager::getSort( const std::string& _name, const std::vector<std::size_t>& _indices ) { auto r = index(getSort(_name), _indices); return r; }
Sort SortManager::getSort( const std::string& _name, const std::vector<std::size_t>& _indices, const std::vector<Sort>& _params ) { return index(getSort(_name, _params), _indices); }
void ExprSMTLIBPrinter::printExpression( const ref<Expr> &e, ExprSMTLIBPrinter::SMTLIB_SORT expectedSort) { // check if casting might be necessary if (getSort(e) != expectedSort) { printCastToSort(e, expectedSort); return; } switch (e->getKind()) { case Expr::Constant: printConstant(cast<ConstantExpr>(e)); return; // base case case Expr::NotOptimized: // skip to child printExpression(e->getKid(0), expectedSort); return; case Expr::Read: printReadExpr(cast<ReadExpr>(e)); return; case Expr::Extract: printExtractExpr(cast<ExtractExpr>(e)); return; case Expr::SExt: case Expr::ZExt: printCastExpr(cast<CastExpr>(e)); return; case Expr::Ne: printNotEqualExpr(cast<NeExpr>(e)); return; case Expr::Select: // the if-then-else expression. printSelectExpr(cast<SelectExpr>(e), expectedSort); return; case Expr::Eq: /* The "=" operator is special in that it can take any sort but we must * enforce that both arguments are the same type. We do this a lazy way * by enforcing the second argument is of the same type as the first. */ printSortArgsExpr(e, getSort(e->getKid(0))); return; case Expr::And: case Expr::Or: case Expr::Xor: case Expr::Not: /* These operators have a bitvector version and a bool version. * For these operators only (e.g. wouldn't apply to bvult) if the expected * sort the * expression is T then that implies the arguments are also of type T. */ printLogicalOrBitVectorExpr(e, expectedSort); return; default: /* The remaining operators (Add,Sub...,Ult,Ule,..) * Expect SORT_BITVECTOR arguments */ printSortArgsExpr(e, SORT_BITVECTOR); return; } }
bool Parser::isUnresolvedType(const std::string& name) { if (!isDeclared(name, SYM_SORT)) { return false; } return d_unresolved.find(getSort(name)) != d_unresolved.end(); }
BSONObj cmdObj(fromjson(R"json({ query: { x: 1 }, update: { y: 1 } })json")); auto parseStatus = FindAndModifyRequest::parseFromBSON(NamespaceString("a.b"), cmdObj); ASSERT_OK(parseStatus.getStatus()); auto request = parseStatus.getValue(); ASSERT_EQUALS(NamespaceString("a.b").toString(), request.getNamespaceString().toString()); ASSERT_EQUALS(BSON("x" << 1), request.getQuery()); ASSERT_EQUALS(BSON("y" << 1), request.getUpdateObj()); ASSERT_EQUALS(false, request.isUpsert()); ASSERT_EQUALS(false, request.isRemove()); ASSERT_EQUALS(BSONObj(), request.getFields()); ASSERT_EQUALS(BSONObj(), request.getSort()); ASSERT_EQUALS(false, request.shouldReturnNew()); } TEST(FindAndModifyRequest, ParseWithUpdateFullSpec) { BSONObj cmdObj(fromjson(R"json({ query: { x: 1 }, update: { y: 1 }, upsert: true, fields: { x: 1, y: 1 }, sort: { z: -1 }, new: true })json")); auto parseStatus = FindAndModifyRequest::parseFromBSON(NamespaceString("a.b"), cmdObj); ASSERT_OK(parseStatus.getStatus());
void ExprSMTLIBLetPrinter::printLetExpression() { *p << "(assert"; p->pushIndent(); printSeperator(); if (bindings.size() != 0) { // Only print let expression if we have bindings to use. *p << "(let"; p->pushIndent(); printSeperator(); *p << "( "; p->pushIndent(); // Print each binding for (map<const ref<Expr>, unsigned int>::const_iterator i = bindings.begin(); i != bindings.end(); ++i) { printSeperator(); *p << "(" << BINDING_PREFIX << i->second << " "; p->pushIndent(); // Disable abbreviations so none are used here. disablePrintedAbbreviations = true; // We can abbreviate SORT_BOOL or SORT_BITVECTOR in let expressions printExpression(i->first, getSort(i->first)); p->popIndent(); printSeperator(); *p << ")"; } p->popIndent(); printSeperator(); *p << ")"; printSeperator(); // Re-enable printing abbreviations. disablePrintedAbbreviations = false; } // print out Expressions with abbreviations. unsigned int numberOfItems = query->constraints.size() + 1; //+1 for query unsigned int itemsLeft = numberOfItems; vector<ref<Expr> >::const_iterator constraint = query->constraints.begin(); /* Produce nested (and () () statements. If the constraint set * is empty then we will only print the "queryAssert". */ for (; itemsLeft != 0; --itemsLeft) { if (itemsLeft >= 2) { *p << "(and"; p->pushIndent(); printSeperator(); printExpression(*constraint, SORT_BOOL); // We must and together bool expressions printSeperator(); ++constraint; continue; } else { // must have 1 item left (i.e. the "queryAssert") if (isHumanReadable()) { *p << "; query"; p->breakLineI(); } printExpression(queryAssert, SORT_BOOL); // The query must be a bool expression } } /* Produce closing brackets for nested "and statements". * Number of "nested ands" = numberOfItems -1 */ itemsLeft = numberOfItems - 1; for (; itemsLeft != 0; --itemsLeft) { p->popIndent(); printSeperator(); *p << ")"; } if (bindings.size() != 0) { // end let expression p->popIndent(); printSeperator(); *p << ")"; printSeperator(); } // end assert p->popIndent(); printSeperator(); *p << ")"; p->breakLineI(); }
static VALUE wrap_Sort_getValues(VALUE self) { return rb_str_new2(getSort(self)->getValues().c_str()); }
static VALUE wrap_Sort_greet(VALUE self) { return rb_str_new2(getSort(self)->greet().c_str()); }
BSONObj cmdObj(fromjson(R"json({ query: { x: 1 }, update: { y: 1 } })json")); auto parseStatus = FindAndModifyRequest::parseFromBSON(NamespaceString("a.b"), cmdObj); ASSERT_OK(parseStatus.getStatus()); auto request = parseStatus.getValue(); ASSERT_EQUALS(NamespaceString("a.b").toString(), request.getNamespaceString().toString()); ASSERT_BSONOBJ_EQ(BSON("x" << 1), request.getQuery()); ASSERT_BSONOBJ_EQ(BSON("y" << 1), request.getUpdateObj()); ASSERT_EQUALS(false, request.isUpsert()); ASSERT_EQUALS(false, request.isRemove()); ASSERT_BSONOBJ_EQ(BSONObj(), request.getFields()); ASSERT_BSONOBJ_EQ(BSONObj(), request.getSort()); ASSERT_BSONOBJ_EQ(BSONObj(), request.getCollation()); ASSERT_EQUALS(0u, request.getArrayFilters().size()); ASSERT_EQUALS(false, request.shouldReturnNew()); } TEST(FindAndModifyRequest, ParseWithUpdateFullSpec) { BSONObj cmdObj(fromjson(R"json({ query: { x: 1 }, update: { y: 1 }, upsert: true, fields: { x: 1, y: 1 }, sort: { z: -1 }, collation: {locale: 'en_US' }, arrayFilters: [ { i: 0 } ], new: true