void GSA::__convertWithArrays() { std::vector<SfaType> docs(size,0); std::vector<LcpType> poss(size,0); SfaType doc = 0; LcpType pos = 0; for ( size_t i = 0; i < size; i++ ) { docs[i] = doc; poss[i] = pos; pos++; if ( concat[i] == '$' ) { doc++; pos = 0; } } Ids = new SfaType[size]; Pos = new LcpType[size]; for ( size_t i = 0; i < size; i++ ) { SfaType doc = docs[SA[i]]; LcpType pos = poss[SA[i]]; Ids[i] = doc; Pos[i] = pos; } }
bool Index::readDict( QDataStream& stream ) { dict.clear(); docList.clear(); QString key; int version, numOfDocs; stream >> version; if ( version < 2 ) return false; stream >> m_charssplit; stream >> m_charsword; // Read the document list stream >> docList; while ( !stream.atEnd() ) { stream >> key; stream >> numOfDocs; QVector<Document> docs( numOfDocs ); stream >> docs; dict.insert( key, new Entry( docs ) ); } return dict.size() > 0; }
void run() { OperationContextImpl txn; DBDirectClient client(&txn); for ( int i = 0; i < 10; ++i ) { client.insert( ns, BSON( "_id" << i ) ); } { // Remove _id range [_min, _max). Lock::DBWrite lk(txn.lockState(), ns); WriteUnitOfWork wunit(txn.recoveryUnit()); Client::Context ctx(&txn, ns ); KeyRange range( ns, BSON( "_id" << _min ), BSON( "_id" << _max ), BSON( "_id" << 1 ) ); mongo::WriteConcernOptions dummyWriteConcern; Helpers::removeRange(&txn, range, false, dummyWriteConcern); wunit.commit(); } // Check that the expected documents remain. ASSERT_EQUALS( expected(), docs(&txn) ); }
void CTestClient::getPlayerInfo(void) { const char *route = "connector.entryHandler.getPlayerInfo";; CJsonT msg; m_pomelo->request(route, msg, [&](Node* node, void* resp) { CCPomeloReponse* ccpomeloresp = (CCPomeloReponse*)resp; CJsonT docs(ccpomeloresp->docs); CCLOG("playerInfo: %s", docs.dump().c_str()); if (docs.getInt("code") != 200) { MT->print("get player info failed"); } else { CCLOG("get player info done!"); CCLOG("playerInfo: %s", docs.dump().c_str()); CJsonT player(docs.getChild("player")); m_playerInfo.setUID(player.getUInt("uid")); const char* nickname = player.getString("nickname"); m_playerInfo.setNickName(nickname ? nickname : ""); m_playerInfo.setLevel(player.getInt("level")); m_playerInfo.setMoney(player.getInt("money")); m_state = STATE::LoginReady; } }); msg.release(); }
void IRProject::ClusterBasedConditionalMarkovRandomWalk::initialAdjacencyMatrix(Matrix &m, const std::vector<ClusterInfo> &clusters) { std::vector<DocInfo> docs(docsCount+1); initialDocsInfo(docs, clusters); m.resize(docsCount+1); for(int i = 1 ; i<= docsCount ; i++) { m[i].resize(docsCount+1); ClusterRep docRepI(i,*index); for(int j = 1 ; j<= docsCount ; j++) { if(i == j) m[i][j] = 0; else { ClusterRep docRepJ(j,*index); double sim = cosSim->similarity(&docRepI, &docRepJ); m[i][j] = sim * (lambda* docs[i].clusterInfo->weight * docs[i].weight) + ((1-lambda) * docs[j].clusterInfo->weight * docs[j].weight ); } } } normalize(m); }
void CTestClient::onStartMatch(Node* node, void* resp) { CCPomeloReponse* ccpomeloresp = (CCPomeloReponse*)resp; CJsonT docs(ccpomeloresp->docs); MT->print("start match!"); m_state = STATE::Running; m_syncTime = 0.f; }
LRESULT RTFEditor::OnNcDestroy() { oleObject.release(); richEditOle.release(); docs()->remove(this); ::CoDisconnectObject(((IMoeDocument*)this),0); ((IMoeDocument*)this)->Release(); return 0; }
void CTestClient::onPair(Node* node, void* resp) { CCPomeloReponse* ccpomeloresp = (CCPomeloReponse*)resp; CJsonT docs(ccpomeloresp->docs); if (200 != docs.getInt("code")) { return; } m_state = STATE::Paired; }
bool CTestClient::init(const char* username, const char* password) { do { BREAK_IF(nullptr == username); BREAK_IF(nullptr == password); m_username = username; m_password = password; int index = POMELO_NEW; m_pomelo = POMELO(index); BREAK_IF(nullptr == m_pomelo); std::string ip = "127.0.0.1"; int port = 3017; m_pomelo->asyncConnect(ip.c_str(), port, [&](Node* node, void* resp) { CCPomeloReponse* pr = (CCPomeloReponse*)resp; if (pr->status != 0) { MT->print("not connected!"); return; } CCLOG("connect ok"); const char *route = "gate.gateHandler.queryConnectorEntry"; CJsonT msg; msg.setChild("userName", m_username.c_str()); msg.setChild("password", m_password.c_str()); m_pomelo->request(route, msg, [&](Node* node, void* resp){ CCPomeloReponse* ccpomeloresp = (CCPomeloReponse*)resp; CJsonT docs(ccpomeloresp->docs); CCLOG("entryCB %s", docs.dump().c_str()); if (200 != docs.getInt("code")) { return; } connectToConnector(docs.getString("host"), docs.getInt("port")); }); msg.release(); }); return true; } while (false); return false; }
void run() { for( int i = 0; i < 10; ++i ) { client.insert( ns, BSON( "_id" << i ) ); } { // Remove _id range [_min, _max). Lock::DBWrite lk(ns); Client::Context ctx( ns ); Helpers::removeRange( ns, BSON( "_id" << _min ), BSON( "_id" << _max ) ); } // Check that the expected documents remain. ASSERT_EQUALS( expected(), docs() ); }
void CTestClient::signUp() { const char *route = "league.leagueHandler.signUp"; CJsonT msg; m_pomelo->request(route, msg, [&](Node* node, void* resp){ CCPomeloReponse* ccpomeloresp = (CCPomeloReponse*)resp; CJsonT docs(ccpomeloresp->docs); if (200 != docs.getInt("code")) { return; } }); msg.release(); m_state = STATE::SignedUp; }
void run() { for( int i = 0; i < 10; ++i ) { client.insert( ns, BSON( "_id" << i ) ); } { // Remove _id range [_min, _max). Client::WriteContext ctx(ns); Client::Transaction transaction(DB_SERIALIZABLE); deleteIndexRange( ns, BSON( "_id" << _min ), BSON( "_id" << _max ), BSON( "_id" << 1 ) ); transaction.commit(); } // Check that the expected documents remain. ASSERT_EQUALS( expected(), docs() ); }
int32_t IndexReader::deleteDocuments(const TermPtr& term) { ensureOpen(); TermDocsPtr docs(termDocs(term)); if (!docs) { return 0; } int32_t n = 0; LuceneException finally; try { while (docs->next()) { deleteDocument(docs->doc()); ++n; } } catch (LuceneException& e) { finally = e; } docs->close(); finally.throwException(); return n; }
void CTestClient::run(float dt) { if (m_state == STATE::Running) { switch (m_caseState) { case CASE_STATE::Start: syncCase(); if (isAttacking() && m_testCase->active) { CJsonT msg; msg.setChild("cmd", (unsigned int)m_testCase->m_atk[0]->instruction); if (isAttacking() && m_testCase->m_atk.size() > 1) { msg.setChild("targetPlayerId", (unsigned int)m_testCase->m_atk[1]->playerNumber); } m_pomelo->request("match.matchHandler.menuCmd", msg, [this](Node* node, void* resp){ CCPomeloReponse* ccpomeloresp = (CCPomeloReponse*)resp; CJsonT docs(ccpomeloresp->docs); }); msg.release(); } m_caseState = CASE_STATE::WaitEncounter; break; case CASE_STATE::WaitEncounter: break; case CASE_STATE::Encounter: break; case CASE_STATE::None: m_syncTime -= dt; if (m_syncTime <= 0) { syncNormal(); m_syncTime = 1.f; } break; } } }
void run() { for ( int i = 0; i < 10; ++i ) { client.insert( ns, BSON( "_id" << i ) ); } { // Remove _id range [_min, _max). OperationContextImpl txn; Lock::DBWrite lk(txn.lockState(), ns); Client::Context ctx( ns ); KeyRange range( ns, BSON( "_id" << _min ), BSON( "_id" << _max ), BSON( "_id" << 1 ) ); Helpers::removeRange( &txn, range ); } // Check that the expected documents remain. ASSERT_EQUALS( expected(), docs() ); }
static void dumpClassMember( Stream &stream, const AbstractClassRep::Field& field ) { stream.writeText( "/*!\r\n" ); if( field.pFieldDocs && field.pFieldDocs[ 0 ] ) { stream.writeText( "@brief " ); String docs( field.pFieldDocs ); S32 newline = docs.find( '\n' ); if( newline == -1 ) stream.writeText( field.pFieldDocs ); else { String brief = docs.substr( 0, newline ); String body = docs.substr( newline + 1 ); stream.writeText( brief ); stream.writeText( "\r\n\r\n" ); stream.writeText( body ); } stream.writeText( "\r\n" ); } const bool isDeprecated = ( field.type == AbstractClassRep::DeprecatedFieldType ); if( isDeprecated ) stream.writeText( "@deprecated This member is deprecated and its value is always undefined.\r\n" ); stream.writeText( "*/\r\n" ); ConsoleBaseType* cbt = ConsoleBaseType::getType( field.type ); const char* type = ( cbt ? cbt->getTypeClassName() : "" ); if( field.elementCount > 1 ) stream.writeText( String::ToString( "%s %s[ %i ];\r\n", isDeprecated ? "deprecated" : type, field.pFieldname, field.elementCount ) ); else stream.writeText( String::ToString( "%s %s;\r\n", isDeprecated ? "deprecated" : type, field.pFieldname ) ); }
void CTestClient::connectToConnector(const char* ip, int port) { m_pomelo->stop(); m_pomelo->asyncConnect(ip, port, [&](Node* node, void* resp) { CCPomeloReponse* pr = (CCPomeloReponse*)resp; if (pr->status != 0) { MT->print("gate not connected!"); return; } CCLOG("gate connect ok"); const char *route = "connector.entryHandler.login";; CJsonT msg; msg.setChild("userName", m_username.c_str()); msg.setChild("password", m_password.c_str()); m_pomelo->request(route, msg, [&](Node* node, void* resp){ CCPomeloReponse* ccpomeloresp = (CCPomeloReponse*)resp; CJsonT docs(ccpomeloresp->docs); CCLOG("entryCB %s", docs.dump().c_str()); if (docs.getInt("code") != 200) { MT->print("connect to connector failed"); } else { CCLOG("connect to connector ok"); addAllListener(); getPlayerInfo(); } }); msg.release(); }); }
void CTestClient::onTriggerMenu(Node* node, void* resp) { MT->print("case encounter"); m_caseState = CASE_STATE::Encounter; CCPomeloReponse* ccpomeloresp = (CCPomeloReponse*)resp; CJsonT docs(ccpomeloresp->docs); int type = docs.getInt("menuType"); if (type == (int)FBDefs::MENU_TYPE::NONE) { return; } CC_ASSERT(type >= 0 && type < (unsigned int)FBDefs::MENU_TYPE::NONE); json_t* players = nullptr; decltype(m_testCase->m_atk)* tpInfo = nullptr; if (isAttacking()) { players = docs.getChild("attackPlayers"); tpInfo = &(m_testCase->m_atk); CCLOG("attack"); } else { players = docs.getChild("defendplayers"); tpInfo = &(m_testCase->m_def); CCLOG("def"); } CJsonTArray ja(players); for (int i = 0; i < ja.size(); ++i) { auto playerId = ja.get(i).toInt(); MT->print("playerId: %d", playerId); for (auto info : *tpInfo) { if (info->playerNumber == playerId) { // 发送命令 CJsonT msg; if (isAttacking()) { MT->printA("%s", CTestPlayerInfo::ins_str[(int)info->instruction].c_str()); } log("ins: %d", (unsigned int)info->instruction); msg.setChild("cmd", (unsigned int)info->instruction); if (isAttacking() && (*tpInfo).size() > 1) { msg.setChild("targetPlayerId", (unsigned int)(*tpInfo)[1]->playerNumber); } m_pomelo->request("match.matchHandler.menuCmd", msg, [this](Node* node, void* resp){ CCPomeloReponse* ccpomeloresp = (CCPomeloReponse*)resp; CJsonT docs(ccpomeloresp->docs); }); msg.release(); break; } } } }
void CTestClient::onGetMatchInfo(Node*, void* r) { CCPomeloReponse* ccpomeloresp = (CCPomeloReponse*)r; CJsonT docs(ccpomeloresp->docs); CJsonTArray left(docs.getChild("left")); CJsonTArray right(docs.getChild("right")); unsigned int u1 = docs.getUInt("leftUid"); unsigned int u2 = docs.getUInt("rightUid"); FBDefs::SIDE kickOffSide = FBDefs::SIDE::LEFT; if (u1 == m_playerInfo.getUID()) { m_side = FBDefs::SIDE::LEFT; } else if (u2 == m_playerInfo.getUID()) { m_side = FBDefs::SIDE::RIGHT; } else { CC_ASSERT(false); } if ( 1 == docs.getInt("kickOffSide")) { kickOffSide = FBDefs::SIDE::RIGHT; } if (kickOffSide == m_side) { m_ballPos = docs.getInt("kickOffPlayer"); } int size = (int)left.size(); CC_ASSERT(size == right.size()); CFBPlayerInitInfo info; for (int i = 0; i < size; ++i) { { CJsonT player(left.get(i)); auto& card = info.card; card.m_cardID = player.getUInt("pcId"); card.m_speed = player.getFloat("speed"); strncpy(card.m_icon, player.getString("icon"), FBDefs::MAX_CARD_ICON_LEN - 1); card.m_strength = player.getFloat("strength"); card.m_dribbleSkill = player.getFloat("dribbleSkill"); card.m_passSkill = player.getFloat("passSkill"); card.m_shootSkill = player.getFloat("shootSkill"); card.m_defenceSkill = player.getFloat("defenceSkill"); card.m_attackSkill = player.getFloat("attackSkill"); card.m_groundSkill = player.getFloat("groundSkill"); card.m_airSkill = player.getFloat("airSkill"); CJsonT position(player.getChild("position")); info.position.x = position.getFloat("x"); info.position.y = position.getFloat("y"); CJsonT homePosition(player.getChild("homePosition")); info.homePosition.x = homePosition.getFloat("x"); info.homePosition.y = homePosition.getFloat("y"); info.aiClass = player.getInt("aiClass"); } { CJsonT player(right.get(i)); auto& card = info.card; card.m_cardID = player.getUInt("pcId"); card.m_speed = player.getFloat("speed"); strncpy(card.m_icon, player.getString("icon"), FBDefs::MAX_CARD_ICON_LEN - 1); card.m_strength = player.getFloat("strength"); card.m_dribbleSkill = player.getFloat("dribbleSkill"); card.m_passSkill = player.getFloat("passSkill"); card.m_shootSkill = player.getFloat("shootSkill"); card.m_defenceSkill = player.getFloat("defenceSkill"); card.m_attackSkill = player.getFloat("attackSkill"); card.m_groundSkill = player.getFloat("groundSkill"); card.m_airSkill = player.getFloat("airSkill"); CJsonT position(player.getChild("position")); info.position.x = position.getFloat("x"); info.position.y = position.getFloat("y"); CJsonT homePosition(player.getChild("homePosition")); info.homePosition.x = homePosition.getFloat("x"); info.homePosition.y = homePosition.getFloat("y"); info.aiClass = player.getInt("aiClass"); } } MT->print("uid: %ud is ready", m_playerInfo.getUID()); const char *route = "match.matchHandler.ready"; CJsonT msg; m_pomelo->notify(route, msg, [](Node* node, void* resp){}); msg.release(); }