void Persistent::update(Updates& updates) { for (Updates::iterator i = updates.begin(); i != updates.end(); i++) { UpdateQuery uq(i->first); uq.where(RawExpr(LITESQL_L("id_ = '") + toString(oldKey) + LITESQL_L("'"))); bool notEmpty = false; for (std::vector<std::pair<FieldType, LITESQL_String> >::iterator i2 = i->second.begin(); i2 != i->second.end(); i2++) { uq.set(i2->first, i2->second); notEmpty = true; } if (notEmpty) db->query(uq); } }
void RecommendEngineWrapper::recommend(const izenelib::util::UString& userQuery, const uint32_t N, std::deque<izenelib::util::UString>& results) { if (NULL == engine_) return; boost::shared_lock<boost::shared_mutex> sl(mtx_, boost::try_to_lock); if (!sl) return; std::string str; userQuery.convertString(str, izenelib::util::UString::UTF_8); std::vector<std::string> recommends; engine_->recommend(str, N, recommends); for (std::size_t i = 0; i < recommends.size(); i++) { izenelib::util::UString uq(recommends[i], izenelib::util::UString::UTF_8); results.push_back(uq); } }