void gProjectCore::updateAllHost(const QString &host,const QString &dbName) { updateObjects(host,dbName,GDB_P); updateObjects(host,dbName,GDB_F); updateObjects(host,dbName,GDB_T); updateObjects(host,dbName,GDB_V); }
/** @param fromRepl false if from ApplyOpsCmd @return true if was and update should have happened and the document DNE. see replset initial sync code. */ bool applyOperation_inlock(const BSONObj& op, bool fromRepl, bool convertUpdateToUpsert) { LOG(6) << "applying op: " << op << endl; bool failedUpdate = false; OpCounters * opCounters = fromRepl ? &replOpCounters : &globalOpCounters; const char *names[] = { "o", "ns", "op", "b" }; BSONElement fields[4]; op.getFields(4, names, fields); BSONObj o; if( fields[0].isABSONObj() ) o = fields[0].embeddedObject(); const char *ns = fields[1].valuestrsafe(); Lock::assertWriteLocked(ns); NamespaceDetails *nsd = nsdetails(ns); // operation type -- see logOp() comments for types const char *opType = fields[2].valuestrsafe(); if ( *opType == 'i' ) { opCounters->gotInsert(); const char *p = strchr(ns, '.'); if ( p && strcmp(p, ".system.indexes") == 0 ) { // updates aren't allowed for indexes -- so we will do a regular insert. if index already // exists, that is ok. theDataFileMgr.insert(ns, (void*) o.objdata(), o.objsize()); } else { // do upserts for inserts as we might get replayed more than once OpDebug debug; BSONElement _id; if( !o.getObjectID(_id) ) { /* No _id. This will be very slow. */ Timer t; updateObjects(ns, o, o, true, false, false, debug, false, QueryPlanSelectionPolicy::idElseNatural() ); if( t.millis() >= 2 ) { RARELY OCCASIONALLY log() << "warning, repl doing slow updates (no _id field) for " << ns << endl; } } else { // probably don't need this since all replicated colls have _id indexes now // but keep it just in case RARELY if ( nsd && !nsd->isCapped() ) { ensureHaveIdIndex(ns); } /* todo : it may be better to do an insert here, and then catch the dup key exception and do update then. very few upserts will not be inserts... */ BSONObjBuilder b; b.append(_id); updateObjects(ns, o, b.done(), true, false, false , debug, false, QueryPlanSelectionPolicy::idElseNatural() ); } } }
void testTheDb() { stringstream ss; setClient("sys.unittest.pdfile"); /* this is not validly formatted, if you query this namespace bad things will happen */ theDataFileMgr.insert("sys.unittest.pdfile", (void *) "hello worldx", 13); theDataFileMgr.insert("sys.unittest.pdfile", (void *) "hello worldx", 13); BSONObj j1((const char *) &js1); deleteObjects("sys.unittest.delete", j1, false); theDataFileMgr.insert("sys.unittest.delete", &js1, sizeof(js1)); deleteObjects("sys.unittest.delete", j1, false); updateObjects("sys.unittest.delete", j1, j1, true,ss); updateObjects("sys.unittest.delete", j1, j1, false,ss); auto_ptr<Cursor> c = theDataFileMgr.findAll("sys.unittest.pdfile"); while ( c->ok() ) { c->_current(); c->advance(); } out() << endl; database = 0; }
/** @param fromRepl false if from ApplyOpsCmd @return true if was and update should have happened and the document DNE. see replset initial sync code. */ bool applyOperation_inlock(const BSONObj& op , bool fromRepl ) { assertInWriteLock(); LOG(6) << "applying op: " << op << endl; bool failedUpdate = false; OpCounters * opCounters = fromRepl ? &replOpCounters : &globalOpCounters; const char *names[] = { "o", "ns", "op", "b" }; BSONElement fields[4]; op.getFields(4, names, fields); BSONObj o; if( fields[0].isABSONObj() ) o = fields[0].embeddedObject(); const char *ns = fields[1].valuestrsafe(); NamespaceDetails *nsd = nsdetails(ns); // operation type -- see logOp() comments for types const char *opType = fields[2].valuestrsafe(); if ( *opType == 'i' ) { opCounters->gotInsert(); const char *p = strchr(ns, '.'); if ( p && strcmp(p, ".system.indexes") == 0 ) { // updates aren't allowed for indexes -- so we will do a regular insert. if index already // exists, that is ok. theDataFileMgr.insert(ns, (void*) o.objdata(), o.objsize()); } else { // do upserts for inserts as we might get replayed more than once OpDebug debug; BSONElement _id; if( !o.getObjectID(_id) ) { /* No _id. This will be very slow. */ Timer t; updateObjects(ns, o, o, true, false, false, debug ); if( t.millis() >= 2 ) { RARELY OCCASIONALLY log() << "warning, repl doing slow updates (no _id field) for " << ns << endl; } } else { /* erh 10/16/2009 - this is probably not relevant any more since its auto-created, but not worth removing */ RARELY if (nsd && !nsd->capped) { ensureHaveIdIndex(ns); // otherwise updates will be slow } /* todo : it may be better to do an insert here, and then catch the dup key exception and do update then. very few upserts will not be inserts... */ BSONObjBuilder b; b.append(_id); updateObjects(ns, o, b.done(), true, false, false , debug ); } } }
void gProjectCore::updateAll() { QString host; QString dbName; for (int i=0;i<connections.count();i++){ host=connections.at(i)->host; dbName=connections.at(i)->dbName; updateObjects(host,dbName,GDB_P); updateObjects(host,dbName,GDB_F); updateObjects(host,dbName,GDB_T); updateObjects(host,dbName,GDB_V); } }
bool CScenePlay::SequenceMain(CCommand &command) { CVector3 pos = Player->getCamera()->getEye(); TimeupLogo->Position = CVector3(pos.x * 1.5f, pos.y, pos.z * 1.5f); TimeupLogo->qRotation = Player->getFrontRotation(); // ゲームオブジェクト更新 updateObjects(); // UIの更新 updateUI(); // ランダムな生成 PopObjectRandom(); if(command.Check(CCommand::START)) CSceneManager::Pause_(); // ポーズ画像の描画 PauseImage->isRender = (CSceneManager::getisPause_()) ? true : false; if(CSceneManager::getisPause_()) SequenceState = SEQ_PAUSE; if(TimeLimit <= 0) { CSceneManager::LockKey(); Direct = Normalize(CVector3((TimeupLogo->Position - Player->Transform.Position).x, 0, (TimeupLogo->Position - Player->Transform.Position).z)); TimeupLogo->isRender = true; SequenceState = SEQ_END; } Count++; // 正常動作 return false; }
bool CScenePlay::SequenceBegin(CCommand &command) { // トランジションが終了したら if(!CTransition::IsExistTransition()) { if(!CSceneManager::getisKeyLock_()) CSceneManager::LockKey(); ++Count; } // ゲームオブジェクト更新 updateObjects(); if(Count > 60 && StartLogo->vColorRGBA.w < 1) StartLogo->vColorRGBA.w += AddAlpha / 255; // ゲームカウントが一定値に到達した場合 if(Count > 180) --StartLogo->Position.z; if(StartLogo->Position.z < BorderLine) { CSceneManager::UnLockKey(); StartLogo->isRender = false; // メインシーケンス移行 SequenceState = SEQ_MAIN; } // 正常終了 return false ; }
PhysicalObject* PhysicsSim::applyPhysics(SceneObject* object, Shape shape, float mass) { PhysicalObject* phyObject; switch(shape) { case shSphere: phyObject = new Sphere(object, mass); break; case shBox: phyObject = new Box(object, mass); break; case shCapsule: phyObject = new Capsule(object, mass); break; case shCylinder: phyObject = new Cylinder(object, mass); break; case shCone: phyObject = new Cone(object, mass); break; case shConvexHull: phyObject = new ConvexHull(object, mass); break; case shTriMesh: phyObject = new TriMesh(object, mass); break; } objects_list.push_back(phyObject); dynamicsWorld->addRigidBody(phyObject->getRigidBody()); updateObjects(); return phyObject; }
void receivedUpdate(Message& m, stringstream& ss) { DbMessage d(m); const char *ns = d.getns(); assert(*ns); uassert( "not master", isMasterNs( ns ) ); setClient(ns); Client& client = cc(); client.top.setWrite(); ss << ns << ' '; int flags = d.pullInt(); BSONObj query = d.nextJsObj(); assert( d.moreJSObjs() ); assert( query.objsize() < m.data->dataLen() ); BSONObj toupdate = d.nextJsObj(); uassert("update object too large", toupdate.objsize() <= MaxBSONObjectSize); assert( toupdate.objsize() < m.data->dataLen() ); assert( query.objsize() + toupdate.objsize() < m.data->dataLen() ); bool upsert = flags & Option_Upsert; bool multi = flags & Option_Multi; { string s = query.toString(); /* todo: we shouldn't do all this ss stuff when we don't need it, it will slow us down. */ ss << " query: " << s; CurOp& currentOp = *client.curop(); strncpy(currentOp.query, s.c_str(), sizeof(currentOp.query)-2); } UpdateResult res = updateObjects(ns, toupdate, query, upsert, multi, ss, true); recordUpdate( res.existing , res.num ); // for getlasterror }
void jfBigBallisticSimulation_x86::run() { while(m_EventHandler->handleEvents()) { m_CurrentShotType = m_EventHandler->getCurrentShotType(); m_EventHandler->handleKeyEvents(); m_LastFrameDuration = m_Timer->getTicks(); m_Timer->start(); jfReal timeStep = ((jfReal)m_LastFrameDuration)/1000.0; if((m_EventHandler->getMouseEvent().getStatus() == EVENT_MOUSELEFT)) { if(!m_MousePressedLast) { m_MousePressedLast = true; fire(); } } else { m_MousePressedLast = false; } updateObjects(timeStep); generateContacts(); vector<jfContact*> contacts; m_CollisionData->getContacts(&contacts); m_ContactResolver->resolveContacts(contacts, timeStep); m_3DGraphicsHandler->draw(); drawDebug(); } }
SceneObject* PhysicsSim::loadSceneObject(stringw mesh_file, stringw texture_file) { IAnimatedMesh *mesh = smgr->getMesh(mediaDirectory + mesh_file); IAnimatedMeshSceneNode* Node = smgr->addAnimatedMeshSceneNode(mesh, smgr->getRootSceneNode()); stringw tex_file = texture_file; if(tex_file == L"") { tex_file = mesh_file; if(tex_file.find(".dae") > -1) tex_file.remove(".dae"); if(tex_file.find(".3ds") > -1) tex_file.remove(".3ds"); tex_file.append(".jpg"); } tex_file = mediaDirectory + tex_file; if(smgr->getFileSystem()->existFile(tex_file)) Node->setMaterialTexture(0, driver->getTexture(tex_file)); Node->setMaterialFlag(EMF_LIGHTING, true); Node->setMaterialFlag(EMF_TEXTURE_WRAP, false); Node->setMaterialFlag(EMF_BACK_FACE_CULLING, true); Node->addShadowVolumeSceneNode(0,-1,false); Node->getMaterial(0).AmbientColor.set(255,255,255,255); updateObjects(); return Node; }
void ObjectAnimationTask::update() { _timer.update(); if (_timer.isFinished()) { _timer.start(); updateObjects(); } }
void getMe(BSONObj& me) { const string myname = getHostName(); Client::Transaction transaction(0); // local.me is an identifier for a server for getLastError w:2+ if (!Collection::findOne("local.me", BSONObj(), me) || !me.hasField("host") || me["host"].String() != myname) { // cleaning out local.me requires write // lock. This is a rare operation, so it should // be ok if (!Lock::isWriteLocked("local")) { throw RetryWithWriteLock(); } // clean out local.me deleteObjects("local.me", BSONObj(), false, false); // repopulate BSONObjBuilder b; b.appendOID( "_id" , 0 , true ); b.append( "host", myname ); me = b.obj(); updateObjects("local.me", me, BSONObj(), true, false); } transaction.commit(0); }
void RigidBodyApplication::update() { // Find the duration of the last frame in seconds float duration = (float)TimingData::get().lastFrameDuration * 0.001f; if (duration <= 0.0f) return; else if (duration > 0.05f) duration = 0.05f; // Exit immediately if we aren't running the simulation if (pauseSimulation) { Application::update(); return; } else if (autoPauseSimulation) { pauseSimulation = true; autoPauseSimulation = false; } // Update the objects updateObjects(duration); // Perform the contact generation generateContacts(); // Resolve detected contacts resolver.resolveContacts( cData.contactArray, cData.contactCount, duration ); Application::update(); }
void receivedUpdate(Message& m, CurOp& op) { DbMessage d(m); const char *ns = d.getns(); op.debug().ns = ns; int flags = d.pullInt(); BSONObj query = d.nextJsObj(); assert( d.moreJSObjs() ); assert( query.objsize() < m.header()->dataLen() ); BSONObj toupdate = d.nextJsObj(); uassert( 10055 , "update object too large", toupdate.objsize() <= BSONObjMaxUserSize); assert( toupdate.objsize() < m.header()->dataLen() ); assert( query.objsize() + toupdate.objsize() < m.header()->dataLen() ); bool upsert = flags & UpdateOption_Upsert; bool multi = flags & UpdateOption_Multi; bool broadcast = flags & UpdateOption_Broadcast; op.debug().query = query; op.setQuery(query); writelock lk; // writelock is used to synchronize stepdowns w/ writes uassert( 10054 , "not master", isMasterNs( ns ) ); // if this ever moves to outside of lock, need to adjust check Client::Context::_finishInit if ( ! broadcast && handlePossibleShardedMessage( m , 0 ) ) return; Client::Context ctx( ns ); UpdateResult res = updateObjects(ns, toupdate, query, upsert, multi, true, op.debug() ); lastError.getSafe()->recordUpdate( res.existing , res.num , res.upserted ); // for getlasterror }
void GameplayState::update(sf::Time elapsedTime) { servLoc.getProfiler()->start("GameplayState: update"); //physics updateObjects(elapsedTime); resolveCollisions(); cleanForces(); resolveExistance(); if(!player->exist) { servLoc.getLogger()->log(POS, "Player doesn't exist(destroyed)."); servLoc.getEngine()->popState(); return; } playerHP->update(player->hp); score->text.setString(ezo::string::format("Score: %u", player->score).c()); servLoc.getRender()->getWindow()->setView(sf::View(player->representation.getPosition(), servLoc.getRender()->getWindow()->getDefaultView().getSize())); servLoc.getProfiler()->stop(); }
void ImGui_Wrapper::update(int width, int height, int dstFbo) { if (!m_VAO) initGui(); ImGuiIO& io = ImGui::GetIO(); io.DisplaySize = ImVec2(static_cast<float>(width), static_cast<float>(height)); auto now = high_resolution_clock::now(); duration<double> delta = now - m_lastTime; m_lastTime = now; auto dt = delta.count(); io.DeltaTime = dt > 0 ? static_cast<float>(dt) : 1 / 60.f; ImGui::NewFrame(); updateObjects(); ImGui::Render(); glBindFramebuffer(GL_FRAMEBUFFER, dstFbo); renderGui(); if (!m_document->animationIsPlaying()) { auto& gui = m_document->getGUI(); TimedFunctions::delayRun(1 / 60.0, [&gui]() { gui.updateView(); }); } for (int i = 0; i < 3; ++i) io.MouseDown[i] = m_mouseButtons[i]; }
void UnifyLabelMannual::frameNext() { updateObjects(); updateLabel(); if( current_frame_ < inputs_.size() - 1 )current_frame_++; else current_frame_ = 0; reloadFrame(); showPatches(); }
void UnifyLabelMannual::frameLast() { updateObjects(); updateLabel(); if( current_frame_ > 0 )current_frame_--; else current_frame_ = inputs_.size() - 1; reloadFrame(); showPatches(); }
void Helpers::upsert( const string& ns , const BSONObj& o, bool fromMigrate ) { BSONElement e = o["_id"]; verify( e.type() ); BSONObj id = e.wrap(); OpDebug debug; Client::Context context(ns); updateObjects(ns.c_str(), o, /*pattern=*/id, /*upsert=*/true, /*multi=*/false , /*logtheop=*/true , debug, fromMigrate ); }
void MainWindow::updateCurrentScene(int scene){ SceneContainer::updateCurrentScene(scene); updateObjects(); updateSelectedInfo(NULL); ui->timebar->setKeyFrames(NULL); SceneContainer::setFrameRange(0,100); SceneContainer::setCurrentFrame(0); ui->viewer->repaint(); }
AddAction::AddAction(QWidget *parent, const char *name, const Mode &mode): AddActionBase(parent, name), theMode(mode) { connect(this, SIGNAL( selected(const QString &) ), SLOT( updateForPageChange() )); connect(this, SIGNAL( selected(const QString &) ), SLOT( slotCorrectPage() )); curPage = 0; updateProfiles(); updateButtons(); updateObjects(); updateProfileFunctions(); }
void SDLViewer::updateTraversal() { // Update CSP updateAtmosphere(); updateObjects(); updateCurrentScreen(); // Traverse osg updaters osgViewer::Viewer::updateTraversal(); }
void MainWindow::addObjectsFromFiles() { QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Add objects..."), Settings::workingDirectory(), tr("Image Files (%1)").arg(Settings::getGeneral_imageFormats())); if(fileNames.size()) { for(int i=0; i<fileNames.size(); ++i) { this->addObjectFromFile(fileNames.at(i)); } objectsModified_ = true; updateObjects(); } }
void Chunk::createObjects(const math::ivec3 &chunkPos, const cyberCubes::model::ModelTextures &modelTextures) { for (uint16_t i = 0; i < CHUNK_SIZE *CHUNK_SIZE *CHUNK_SIZE; ++i) { CubeType c = cubes[i]; if (isModel(c)) { math::ivec3 p = ind2c(i); BlockData data = getBlockData(i); updateObjects(chunkPos, p, c, data, modelTextures); } } }
static void lockedReceivedUpdate(const char *ns, Message &m, CurOp &op, const BSONObj &updateobj, const BSONObj &query, const bool upsert, const bool multi) { // void ReplSetImpl::relinquish() uses big write lock so // this is thus synchronized given our lock above. uassert(10054, "not master", isMasterNs(ns)); Client::Context ctx(ns); scoped_ptr<Client::AlternateTransactionStack> altStack(opNeedsAltTxn(ns) ? new Client::AlternateTransactionStack : NULL); Client::Transaction transaction(DB_SERIALIZABLE); UpdateResult res = updateObjects(ns, updateobj, query, upsert, multi, true); transaction.commit(); lastError.getSafe()->recordUpdate( res.existing , res.num , res.upserted ); // for getlasterror }
bool CScenePlay::SequenceEnd(CCommand &command) { // ゲームオブジェクト更新 updateObjects(); TimeupLogo->Position -= Direct; if(EndCounter == EndCount) CSceneManager::setNextScene_(CSceneResult::CreateScene()); Count++; EndCounter++; return false; }
void receivedUpdate(Message& m, CurOp& op) { DbMessage d(m); const char *ns = d.getns(); op.debug().ns = ns; int flags = d.pullInt(); BSONObj query = d.nextJsObj(); verify( d.moreJSObjs() ); verify( query.objsize() < m.header()->dataLen() ); BSONObj toupdate = d.nextJsObj(); uassert( 10055 , "update object too large", toupdate.objsize() <= BSONObjMaxUserSize); verify( toupdate.objsize() < m.header()->dataLen() ); verify( query.objsize() + toupdate.objsize() < m.header()->dataLen() ); bool upsert = flags & UpdateOption_Upsert; bool multi = flags & UpdateOption_Multi; bool broadcast = flags & UpdateOption_Broadcast; Status status = cc().getAuthorizationManager()->checkAuthForUpdate(ns, upsert); uassert(16538, status.reason(), status.isOK()); op.debug().query = query; op.setQuery(query); PageFaultRetryableSection s; while ( 1 ) { try { Lock::DBWrite lk(ns); // void ReplSetImpl::relinquish() uses big write lock so // this is thus synchronized given our lock above. uassert( 10054 , "not master", isMasterNs( ns ) ); // if this ever moves to outside of lock, need to adjust check Client::Context::_finishInit if ( ! broadcast && handlePossibleShardedMessage( m , 0 ) ) return; Client::Context ctx( ns ); UpdateResult res = updateObjects(ns, toupdate, query, upsert, multi, true, op.debug() ); lastError.getSafe()->recordUpdate( res.existing , res.num , res.upserted ); // for getlasterror break; } catch ( PageFaultException& e ) { e.touch(); } } }
bool WriteBatchExecutor::applyUpdate(const string& ns, const WriteBatch::WriteItem& writeItem, CurOp* currentOp) { OpDebug& opDebug = currentOp->debug(); _opCounters->gotUpdate(); BSONObj queryObj; BSONObj updateObj; bool multi; bool upsert; string errMsg; bool ret = writeItem.parseUpdateItem(&errMsg, &queryObj, &updateObj, &multi, &upsert); verify(ret); // writeItem should have been already validated by WriteBatch::parse(). currentOp->setQuery(queryObj); opDebug.op = dbUpdate; opDebug.query = queryObj; bool resExisting = false; long long resNum = 0; OID resUpserted = OID(); try { UpdateResult res = updateObjects(ns.c_str(), updateObj, queryObj, upsert, multi, /*logOp*/true, opDebug); resExisting = res.existing; resNum = res.num; resUpserted = res.upserted; } catch (UserException& e) { opDebug.exceptionInfo = e.getInfo(); return false; } _le->recordUpdate(resExisting, resNum, resUpserted); return true; }
void idleCB(void) { if( Animate == 1 ) { // TM.Reset() ; // commenting out this will make the time run from 0 // leaving 'Time' counts the time interval between successive calls to idleCB if( Recording == 0 ) TIME = TM.GetElapsedTime() ; else TIME += 0.033 ; // save at 30 frames per second. // eye.x = 20*sin(TIME); // eye.z = 20*cos(TIME); updateObjects(); printf("TIME %f\n", TIME) ; glutPostRedisplay() ; } }