void ConcurrentTableSharedStore::dumpKeyAndValue(std::ostream & out) { WriteLock l(m_lock); out << "Total " << m_vars.size() << std::endl; for (Map::iterator iter = m_vars.begin(); iter != m_vars.end(); ++iter) { const char *key = iter->first; out << key; out << " #### "; const StoreValue *sval = &iter->second; if (!sval->expired()) { VariableSerializer vs(VariableSerializer::Type::Serialize); auto const value = sval->data.match( [&] (APCHandle* handle) { return handle->toLocal(); }, [&] (char* sAddr) { // we need unserialize and serialize again because the format was // APCSerialize return apc_unserialize(sAddr, sval->getSerializedSize()); } ); try { String valS(vs.serialize(value, true)); out << valS.toCppString(); } catch (const Exception &e) { out << "Exception: " << e.what(); } } out << std::endl; } }
/*! Augments the prefix of the experiment files by \e strTrue followed by \e val. \param strTrue : String to add \param val : Value to add */ void vpIoTools::addNameElement(const std::string &strTrue, const double &val) { //if(val != 0.) if(std::fabs(val) < std::numeric_limits<double>::epsilon()) { char valC[256]; sprintf(valC, "%.3f", val); std::string valS(valC); baseName += "_" + strTrue + valS; } }
void ConcurrentTableSharedStore::dump(std::ostream & out, bool keyOnly, int waitSeconds) { // Use write lock here to prevent concurrent ops running in parallel from // invalidatint the iterator. // This functionality is for debugging and should not be called regularly if (RuntimeOption::ApcConcurrentTableLockFree) { m_lockingFlag = true; int begin = time(NULL); Logger::Info("waiting %d seconds before dump", waitSeconds); while (time(NULL) - begin < waitSeconds) { sleep(1); } } WriteLock l(m_lock); Logger::Info("dumping apc"); out << "Total " << m_vars.size() << std::endl; for (Map::iterator iter = m_vars.begin(); iter != m_vars.end(); ++iter) { const char *key = iter->first; out << key; if (!keyOnly) { out << " #### "; const StoreValue *sval = &iter->second; if (!sval->expired()) { VariableSerializer vs(VariableSerializer::Serialize); Variant value; if (sval->inMem()) { value = sval->var->toLocal(); } else { assert(sval->inFile()); // we need unserialize and serialize again because the format was // APCSerialize String s(sval->sAddr, sval->getSerializedSize(), AttachLiteral); value = apc_unserialize(s); } try { String valS(vs.serialize(value, true)); out << valS->toCPPString(); } catch (const Exception &e) { out << "Exception: " << e.what(); } } } out << std::endl; } Logger::Info("dumping apc done"); if (RuntimeOption::ApcConcurrentTableLockFree) { m_lockingFlag = false; } }
void ArrayData::dump(std::ostream &out) { unsigned int i = 0; for (ArrayIter iter(this); iter; ++iter, i++) { VariableSerializer vs(VariableSerializer::Serialize); Variant key(iter.first()); out << i << " #### " << key.toString()->toCPPString() << " #### "; Variant val(iter.second()); try { Variant valS(vs.serialize(val, true)); out << valS.toString()->toCPPString(); } catch (const Exception &e) { out << "Exception: " << e.what(); } out << endl; } }
void ConcurrentTableSharedStore::dump(std::ostream & out) { int i = 0; ReadLock l(m_lock); out << "Total " << m_vars.size() << endl; for (Map::iterator iter = m_vars.begin(); iter != m_vars.end(); ++iter, ++i) { const char *key = iter->first; const StoreValue &val = iter->second; if (!val.expired()) { VariableSerializer vs(VariableSerializer::Serialize); out << i << " #### " << key << " #### "; Variant value = val.var->toLocal(); try { String valS(vs.serialize(value, true)); out << valS->toCPPString(); } catch (const Exception &e) { out << "Exception: " << e.what(); } out << endl; } } }