//-------------------------------------------------------------------------------------- void ImplProfile::__save( std::ostream & output, MagicNumberType type ) const { debug_func_cerr(5); if (type == MNNoType ) { type = MNImplProfile; output.write( (char*)&type, sizeof(MagicNumberType ) ); } ImplAlignandum::__save( output, type ); output.write( (char*)&mProfileWidth, sizeof(Residue) ); size_t size = getFullLength() * mProfileWidth; if ( mStorageType == Full ) { output.write( (char*)mWeightedCountMatrix->getData(), sizeof(WeightedCount) * size); if (isPrepared() ) { output.write( (char*)mFrequencyMatrix->getData(), sizeof(Frequency) * size); output.write( (char*)mScoreMatrix->getData(), sizeof(Score) * size ); } } else if ( mStorageType == Sparse ) { saveSparseMatrix<WeightedCount>( output, mWeightedCountMatrix ); if (isPrepared() ) { saveSparseMatrix<Frequency>( output, mFrequencyMatrix ); // can only compress counts and frequencies output.write( (char*)mScoreMatrix->getData(), sizeof(Score) * size ); } } }
//-------------------------------------------------------------------------------------- void ImplProfile::load( std::istream & input) { debug_func_cerr(5); ImplAlignandum::load( input ); input.read( (char*)&mProfileWidth, sizeof( Residue ) ); size_t size = getFullLength() * mProfileWidth; if ( mStorageType == Full ) { allocateCounts(); input.read( (char*)mWeightedCountMatrix->getData(), sizeof( WeightedCount) * size ); if (input.fail() ) throw AlignlibException( "incomplete profile in stream."); if (isPrepared() ) { allocateFrequencies(); input.read( (char*)mFrequencyMatrix->getData(), sizeof( Frequency) * size ); allocateScores(); input.read( (char*)mScoreMatrix->getData(), sizeof(Score) * size ); } } else if ( mStorageType == Sparse ) { allocateCounts(); loadSparseMatrix<WeightedCount>( input, mWeightedCountMatrix ); if (input.fail() ) throw AlignlibException( "incomplete profile in stream."); if (isPrepared() ) { allocateFrequencies(); loadSparseMatrix<Frequency>( input, mFrequencyMatrix ); allocateScores(); input.read( (char*)mScoreMatrix->getData(), sizeof(Score) * size ); } } }
void MySqlPreparedStatement::bind( const SqlStmtParameters& holder ) { poco_assert(isPrepared()); poco_assert(_myArgs.size() == _numParams); //finalize adding params if (_myArgs.size() < 1) return; //verify if we bound all needed input parameters if(_numParams != holder.boundParams()) { poco_bugcheck_msg("Not all parameters bound in MySqlPreparedStatement"); return; } size_t nIndex = 0; const SqlStmtParameters::ParameterContainer& holderArgs = holder.params(); for (auto it = holderArgs.begin(); it!=holderArgs.end(); ++it) { //bind parameter addParam(nIndex++, (*it)); } //bind input arguments if(mysql_stmt_bind_param(_myStmt, &_myArgs[0])) poco_bugcheck_msg((string("mysql_stmt_bind_param() failed with ERROR ")+mysql_stmt_error(_myStmt)).c_str()); }
bool MySqlPreparedStatement::prepare() { if(isPrepared()) return true; //remove old binds RemoveBinds(); //create statement object m_stmt = mysql_stmt_init(m_pMySQLConn); if (!m_stmt) { sLog.outError("SQL: mysql_stmt_init()() failed "); return false; } //prepare statement if (mysql_stmt_prepare(m_stmt, m_szFmt.c_str(), m_szFmt.length())) { sLog.outError("SQL: mysql_stmt_prepare() failed for '%s'", m_szFmt.c_str()); sLog.outError("SQL ERROR: %s", mysql_stmt_error(m_stmt)); return false; } /* Get the parameter count from the statement */ m_nParams = mysql_stmt_param_count(m_stmt); /* Fetch result set meta information */ m_pResultMetadata = mysql_stmt_result_metadata(m_stmt); //if we do not have result metadata if (!m_pResultMetadata && strnicmp(m_szFmt.c_str(), "select", 6) == 0) { sLog.outError("SQL: no meta information for '%s'", m_szFmt.c_str()); sLog.outError("SQL ERROR: %s", mysql_stmt_error(m_stmt)); return false; } //bind input buffers if(m_nParams) { m_pInputArgs = new MYSQL_BIND[m_nParams]; memset(m_pInputArgs, 0, sizeof(MYSQL_BIND) * m_nParams); } //check if we have a statement which returns result sets if(m_pResultMetadata) { //our statement is query m_bIsQuery = true; /* Get total columns in the query */ m_nColumns = mysql_num_fields(m_pResultMetadata); //bind output buffers } m_bPrepared = true; return true; }
bool MySqlPreparedStatement::execute() { poco_assert(isPrepared()); MYSQL_BIND* args = nullptr; if (_myArgs.size() > 0) args = &_myArgs[0]; _mySqlConn._MySQLStmtExecute(*this, _myStmt); return true; }
Handle<Value> DispObject::findElement(LPOLESTR name) { // Prepare disp if (!isPrepared()) Prepare(); // Search dispid DISPID dispid; IDispatch *pdisp = (disp) ? disp : owner_disp; if (!pdisp || FAILED(DispFind(pdisp, name, &dispid))) return Undefined(); if (dispid == DISPID_UNKNOWN) return Undefined(); return DispObject::NodeCreate(disp, name, dispid); }
bool MySqlPreparedStatement::execute() { if(!isPrepared()) return false; if(mysql_stmt_execute(m_stmt)) { sLog.outError("SQL: cannot execute '%s'", m_szFmt.c_str()); sLog.outError("SQL ERROR: %s", mysql_stmt_error(m_stmt)); return false; } return true; }
Handle<Value> DispObject::set(LPOLESTR name, Local<Value> value) { // Prepare disp if (!isPrepared()) Prepare(); if (!disp) return DispError(E_NOTIMPL, __FUNCTIONW__); // Set value using dispatch DISPID dispid; CComVariant ret; VarArgumets vargs(value); HRESULT hrcode = DispInvoke(disp, name, 0, 0, &ret, DISPATCH_PROPERTYPUT, &dispid); if FAILED(hrcode) return DispError(hrcode, L"DispPropertyPut"); return DispObject::NodeCreate(disp, name, dispid); }
void MySqlPreparedStatement::prepare() { if(isPrepared()) return; //remove old binds unprepare(); //create statement object _myStmt = _mySqlConn._MySQLStmtInit(); poco_assert(_myStmt != nullptr); //prepare statement _mySqlConn._MySQLStmtPrepare(*this, _myStmt, _stmtSql, _stmtLen); //Get the parameter count from the statement _numParams = mysql_stmt_param_count(_myStmt); //Fetch result set meta information _myResMeta = mysql_stmt_result_metadata(_myStmt); //if we do not have result metadata if (!_myResMeta && (!strnicmp("select",_stmtSql,6))) poco_bugcheck_msg(Poco::format("SQL: no meta information for '%s', ERROR %s",this->getSqlString(),this->lastErrorDescr()).c_str()); //set up bind input buffers _myArgs.resize(_numParams); for (size_t i=0;i<_myArgs.size();i++) memset(&_myArgs[i], 0, sizeof(MYSQL_BIND)); //check if we have a statement which returns result sets if(_myResMeta) { //our statement is a query _isQuery = true; //get number of columns of the query _numColumns = mysql_num_fields(_myResMeta); //set up bind output buffers _myRes.resize(_numColumns); for (size_t i=0;i<_myRes.size();i++) { MYSQL_BIND& curr = _myRes[i]; memset(&curr,0,sizeof(MYSQL_BIND)); //TODO: implement fetching results from statements } } _prepared = true; }
system::error_code Capture::setCamera(intrusive_ptr<hal::Camera> const &camera) { if(isPrepared()) return base::makeErrorCode(base::kENotApplicable); if(m_Camera) { m_Camera->cameraDelegate() -= this; } m_Camera = camera; if(m_Camera) { m_Camera->cameraDelegate() += this; } return base::makeErrorCode(base::kENoError); }
void MembershipTableMgr::handleMemberStatusEvent(const std::shared_ptr<ActorMessage>& actor_msg_ptr) { function_footprint(); if (members.empty() || !getLocalMember()) { return; } auto payload = dynamic_cast<MemberStatusEvent*>(actor_msg_ptr->getPayload().get()); uint32_t pos = payload->member_id(); auto status = payload->status(); auto member = getMember(pos); if (!member) { return; } setMemberStatus(member, status); if(member->isPrepared()) { DVLOG(0) << toSimpleString(); joining.store(false); } }
MemberWrapper* MembershipTableMgr::selectLeading(const std::vector<MemberWrapper*>& leftMembers) { for(auto it = members.begin(); it != members.end(); ++it) {/// select new leading bool isLeave = false; for(auto jt = leftMembers.begin(); jt != leftMembers.end(); ++jt) { if(it->getId() == (*jt)->getId()) { /// ignore leave member isLeave = true; break; } } if(isLeave) { continue; } if(it->isActive() || it->isPrepared()) { return &members.at(it->getId()); break; } } /// end for return NULL; }
void MySqlPreparedStatement::bind( const SqlStmtParameters& holder ) { if(!isPrepared()) { MANGOS_ASSERT(false); return; } //finalize adding params if(!m_pInputArgs) return; //verify if we bound all needed input parameters if(m_nParams != holder.boundParams()) { MANGOS_ASSERT(false); return; } int nIndex = 0; SqlStmtParameters::ParameterContainer const& _args = holder.params(); SqlStmtParameters::ParameterContainer::const_iterator iter_last = _args.end(); for (SqlStmtParameters::ParameterContainer::const_iterator iter = _args.begin(); iter != iter_last; ++iter) { //bind parameter addParam(nIndex++, (*iter)); } //bind input arguments if(mysql_stmt_bind_param(m_stmt, m_pInputArgs)) { sLog.outError("SQL ERROR: mysql_stmt_bind_param() failed\n"); sLog.outError("SQL ERROR: %s", mysql_stmt_error(m_stmt)); } }
bool MySqlPreparedStatement::execute() { if(!isPrepared()) return false; uint32 _s = WorldTimer::getMSTime(); if(mysql_stmt_execute(m_stmt)) { sLog.outLog(LOG_DEFAULT, "ERROR: SQL: cannot execute '%s'", m_szFmt.c_str()); sLog.outLog(LOG_DEFAULT, "ERROR: SQL ERROR: %s", mysql_stmt_error(m_stmt)); return false; } else { uint32 queryDiff = WorldTimer::getMSTimeDiff(_s, WorldTimer::getMSTime()); if (this->m_pConn.DB().CheckMinLogTime(queryDiff)) sLog.outLog(LOG_DB_DIFF, "[%u ms] SQL: %s", queryDiff, m_szFmt.c_str()); sLog.outDebug("[%u ms] SQL: %s", queryDiff, m_szFmt.c_str()); } return true; }
//------------------------------------------------------------------------------------------ void ImplProfile::add( const HAlignandum & source, const HAlignment & map_source2dest, bool is_reverse ) { debug_func_cerr(5); debug_cerr( 3, "adding to profile: is_reverse=" << is_reverse << " this=" << map_source2dest->getRowFrom() << "-" << map_source2dest->getRowTo() << " len=" << getFullLength() << " other=" << map_source2dest->getColFrom() << "-" << map_source2dest->getColTo() << " len=" << source->getFullLength() ); assert( source->getToolkit()->getEncoder()->getAlphabetSize() == getToolkit()->getEncoder()->getAlphabetSize()); if (is_reverse) { assert (map_source2dest->getColTo() <= source->getFullLength() ); assert (map_source2dest->getRowTo() <= getFullLength() ); } else { assert (map_source2dest->getRowTo() <= source->getFullLength() ); assert (map_source2dest->getColTo() <= getFullLength() ); } const HSequence sequence(toSequence( source )); if (sequence) { AlignmentIterator it(map_source2dest->begin()); AlignmentIterator it_end(map_source2dest->end()); if (is_reverse) { for (; it != it_end; ++it) { Position row = it->mCol; Position col = it->mRow; Residue i = sequence->asResidue(row); mWeightedCountMatrix->addValue(col,i,1); } } else { for (; it != it_end; ++it) { Position row = it->mRow; Position col = it->mCol; Residue i = sequence->asResidue(row); mWeightedCountMatrix->addValue(col,i,1); } } } else { const HProfile profile(toProfile(source)); if (profile) { AlignmentIterator it(map_source2dest->begin()); AlignmentIterator it_end(map_source2dest->end()); HWeightedCountMatrix m(profile->getWeightedCountMatrix()); if (is_reverse) { for (; it != it_end; ++it) { Position row = it->mCol; Position col = it->mRow; for (Residue i = 0; i < mProfileWidth; i++) mWeightedCountMatrix->addValue(col,i,(*m)[row][i]); } } else { for (; it != it_end; ++it) { Position row = it->mRow; Position col = it->mCol; for (Residue i = 0; i < mProfileWidth; i++) mWeightedCountMatrix->addValue(col,i,(*m)[row][i]); } } } else throw AlignlibException( "can not guess type of src - neither profile nor sequence"); } if (isPrepared()) { release(); // first release, otherwise it won't calculate anew prepare(); } }