LSHSearch<SortPolicy>:: LSHSearch(const arma::mat& referenceSet, const size_t numProj, const size_t numTables, const double hashWidthIn, const size_t secondHashSize, const size_t bucketSize) : referenceSet(referenceSet), querySet(referenceSet), numProj(numProj), numTables(numTables), hashWidth(hashWidthIn), secondHashSize(secondHashSize), bucketSize(bucketSize), distanceEvaluations(0) { if (hashWidth == 0.0) // The user has not provided any value. { // Compute a heuristic hash width from the data. for (size_t i = 0; i < 25; i++) { size_t p1 = (size_t) math::RandInt(referenceSet.n_cols); size_t p2 = (size_t) math::RandInt(referenceSet.n_cols); hashWidth += std::sqrt(metric::EuclideanDistance::Evaluate( referenceSet.unsafe_col(p1), referenceSet.unsafe_col(p2))); } hashWidth /= 25; } Log::Info << "Hash width chosen as: " << hashWidth << std::endl; BuildHash(); }
int param_analyse(int argc,char* argv[],hNode* list) { int i,j; if(argc>14) { printUsage(); return 0; } BuildHash(list); readFromConf(DEFAULT_FILE); //printf("-------------%s\n",fs[4].buf); for(i=1;i<=argc-1;i=i+2) { if(strcmp("-ConfigFile",argv[i])==0) { isConfUsed = TRUE; continue; } j = hash(argv[i],list); if(type(argv[i],list)==number) { fi[j].num = atoi(argv[i+1]); fi[j].modify = 2; } else { fs[j].buf = argv[i+1]; fs[j].modify = 2; } } for(i=0;i<=MAX_PARA;i++) { if(isConfUsed==TRUE && fi[i].tag==number) di[i] = fi[i].num; else if(isConfUsed==FALSE && fi[i].modify==2) di[i] = fi[i].num; } for(i=0;i<=MAX_PARA;i++) { if(isConfUsed==TRUE && fs[i].tag==string) ds[i] = fs[i].buf; else if(isConfUsed==FALSE && fs[i].modify==2) ds[i] = fs[i].buf; } //getchar(); return 0; }
int SavedataParam::UpdateHash(u8* sfoData, int sfoSize, int sfoDataParamsOffset, int encryptmode) { int alignedLen = align16(sfoSize); memset(sfoData+sfoDataParamsOffset, 0, 128); u8 filehash[16]; int ret = 0; /* Compute 11D0 hash over entire file */ if ((ret = BuildHash(filehash, sfoData, sfoSize, alignedLen, (encryptmode & 2) ? 4 : 2, NULL)) < 0) { // Not sure about "2" return ret - 400; } /* Copy 11D0 hash to param.sfo and set flag indicating it's there */ memcpy(sfoData+sfoDataParamsOffset + 0x20, filehash, 0x10); *(sfoData+sfoDataParamsOffset) |= 0x01; /* If new encryption mode, compute and insert the 1220 hash. */ if (encryptmode & 2) { /* Enable the hash bit first */ *(sfoData+sfoDataParamsOffset) |= 0x20; if ((ret = BuildHash(filehash, sfoData, sfoSize, alignedLen, 3, 0)) < 0) { return ret - 500; } memcpy(sfoData+sfoDataParamsOffset + 0x70, filehash, 0x10); } /* Compute and insert the 11C0 hash. */ if ((ret = BuildHash(filehash, sfoData, sfoSize, alignedLen, 1, 0)) < 0) { return ret - 600; } memcpy(sfoData+sfoDataParamsOffset + 0x10, filehash, 0x10); /* All done. */ return 0; }
void CWaveSession::PostChannelRequest() { if (m_lpRequest != NULL) { m_vOwnedRequests.push_back(m_lpChannelRequest); } m_lpChannelRequest = new CCurl( Format(WAVE_URL_CHANNEL, m_szStickySessionID.c_str(), m_szSID.c_str(), m_nAID, BuildHash().c_str()), m_lpTargetWindow ); m_lpChannelRequest->SetUserAgent(GetUserAgent()); m_lpChannelRequest->SetTimeout(WEB_TIMEOUT_CHANNEL); m_lpChannelRequest->SetIgnoreSSLErrors(TRUE); m_lpChannelRequest->SetCookies(GetCookies()); m_lpChannelRequest->SetReader(new CWaveReader(this)); CNotifierApp::Instance()->QueueRequest(m_lpChannelRequest); }
void CWaveSession::PostSIDRequest() { if (m_lpRequest != NULL) { m_vOwnedRequests.push_back(m_lpRequest); } m_lpRequest = new CCurl( Format(WAVE_URL_SESSIONID, m_szStickySessionID.c_str(), m_nRID++, BuildHash().c_str()), m_lpTargetWindow ); m_lpRequest->SetUserAgent(GetUserAgent()); m_lpRequest->SetTimeout(WEB_TIMEOUT_SHORT); m_lpRequest->SetIgnoreSSLErrors(TRUE); m_lpRequest->SetCookies(GetCookies()); m_lpRequest->SetReader(new CCurlUTF8StringReader()); m_lpRequest->SetUrlEncodedPostData(L"count=0"); m_nRequesting = WSR_SID; CNotifierApp::Instance()->QueueRequest(m_lpRequest); }
void CWaveSession::PostRequests() { // This method is responsible for deleting the requests because requests // may later be stored. Responses can be linked to a request and when this // becomes necessary, this function will take the requests for later retrieval. // Now, we just delete them. wstringstream szPostData; ASSERT(m_vRequestQueue.size() > 0); szPostData << L"count=" << m_vRequestQueue.size(); INT nOffset = 0; for (TWaveRequestVectorConstIter iter = m_vRequestQueue.begin(); iter != m_vRequestQueue.end(); iter++) { szPostData << L"&req" << nOffset << L"_key=" << UrlEncode(SerializeRequest(*iter)); nOffset++; } // Post the JSON to the channel. wstring szUrl = Format(WAVE_URL_CHANNEL_POST, m_szStickySessionID.c_str(), m_szSID.c_str(), m_nRID++, BuildHash().c_str()); if (m_lpPostRequest != NULL) { m_vOwnedRequests.push_back(m_lpPostRequest); } m_lpPostRequest = new CCurl(szUrl, m_lpTargetWindow); m_lpPostRequest->SetUserAgent(GetUserAgent()); m_lpPostRequest->SetTimeout(WEB_TIMEOUT_SHORT); m_lpPostRequest->SetIgnoreSSLErrors(TRUE); m_lpPostRequest->SetCookies(GetCookies()); m_lpPostRequest->SetUrlEncodedPostData(szPostData.str()); CNotifierApp::Instance()->QueueRequest(m_lpPostRequest); for (TWaveRequestVectorIter iter1 = m_vRequestQueue.begin(); iter1 != m_vRequestQueue.end(); iter1++) { ASSERT(*iter1 != NULL); (*iter1)->RequestCompleted(); delete *iter1; } m_vRequestQueue.clear(); }