ApplicationCacheGroup* ApplicationCacheStorage::loadCacheGroup(const KURL& manifestURL) { openDatabase(false); if (!m_database.isOpen()) return 0; SQLiteStatement statement(m_database, "SELECT id, manifestURL, newestCache FROM CacheGroups WHERE newestCache IS NOT NULL AND manifestURL=?"); if (statement.prepare() != SQLResultOk) return 0; statement.bindText(1, manifestURL); int result = statement.step(); if (result == SQLResultDone) return 0; if (result != SQLResultRow) { LOG_ERROR("Could not load cache group, error \"%s\"", m_database.lastErrorMsg()); return 0; } unsigned newestCacheStorageID = (unsigned)statement.getColumnInt64(2); RefPtr<ApplicationCache> cache = loadCache(newestCacheStorageID); if (!cache) return 0; ApplicationCacheGroup* group = new ApplicationCacheGroup(manifestURL); group->setStorageID((unsigned)statement.getColumnInt64(0)); group->setNewestCache(cache.release()); return group; }
QPixmap& TPhoto::thumbnail() { if (!m_thumbnail) loadCache(); return *m_thumbnail; }
QSize& TPhoto::size() // private { if (m_size == 0) loadCache(); return *m_size; }
int eMPEGStreamInformation::moveCache(int index) { //eDebug("[eMPEGStreamInformation::moveCache] index=%d m_cache_index=%d m_structure_cache_entries=%d", index, m_cache_index, m_structure_cache_entries); // Check if index falls inside current range. if ((m_structure_cache_entries != 0) && (index >= m_cache_index) && (index < m_cache_index + m_structure_cache_entries)) { // Request for the same data. If the request is at the end of the stream, // check if the file has become larger. if (index + m_structure_cache_entries >= m_structure_file_entries) { int l = ::lseek(m_structure_read_fd, 0, SEEK_END) / entry_size; if (l == m_structure_file_entries) { // No change to file, just return return m_structure_cache_entries; } m_structure_file_entries = l; } else { // Requested same position as last time, just return return m_structure_cache_entries; } } // Really have to re-read the cache now return loadCache(index); }
Collection::Collection() : QAbstractTableModel() { m_coverLoader = new CoverLoader; QThread *thread = new QThread; m_coverLoader->moveToThread(thread); thread->start(); loadCache(); }
void JpwordReader::loadCourse(int courseNo){ levels.clear(-1,MAX_LEVEL); loadCache(levels, courseNo); if(levelList().empty()){ IOUtils::log("loading from cache failed."); loadMp3(levels,courseNo); }else{ IOUtils::log("loaded from cache."); } }
Result DiskBackedCache::simulate(SimulationTaskClass const & task ) { Result cached = loadCache(task); if (cached.numberOfGames < task.minimalNumberOfGames) { unsigned long missingGames = task.minimalNumberOfGames - cached.numberOfGames; SimulationTaskClass remainderTask(task); remainderTask.minimalNumberOfGames = missingGames; remainderTask.randomSeed = rand_r(&(this->randomData)); Result fresh = this->delegate->simulate(remainderTask); this->addToCache(remainderTask, fresh); return cached + fresh; } else { return cached; } }
Result DiskBackedCache::simulate(SimulationTaskClass const & task ,unsigned long numberOfNewSamples ) { Result cached = loadCache(task); if (cached.numberOfGames < task.minimalNumberOfGames) { unsigned long missingGames = task.minimalNumberOfGames - cached.numberOfGames; unsigned long newGames = std::max(missingGames, numberOfNewSamples); SimulationTaskClass remainderTask(task); remainderTask.minimalNumberOfGames = newGames; Result fresh = this->delegate->simulate(remainderTask); this->addToCache(remainderTask, fresh); return cached + fresh; } else { return cached; } }
QMakeSourceFileInfo::QMakeSourceFileInfo(const QString &cf) { //dep_mode dep_mode = Recursive; //quick project lookups includes = files = 0; files_changed = false; //buffer spare_buffer = 0; spare_buffer_size = 0; //cache cachefile = cf; if(!cachefile.isEmpty()) loadCache(cachefile); }
MyWidget::MyWidget(QWidget *parent) : QWidget(parent), uiForm(new Ui::Form), mpMessageBox(nullptr), mpCurrentSoundFile(nullptr), mCurrentDir(""), mCurrentWord(""), mStrListFiles(""), mNumber(0) { uiForm ->setupUi(this); setWindowTitle(QWidget::tr("Произношение-4")); mMyPlayer.createMyPlayer(uiForm); if (loadCache()) uiForm ->cacheWord ->addItems(mCacheFiles.keys()); mpClipboard = QApplication::clipboard(); fromClipboardToLineEdit(); // текст из буфера обмена -> в строку ввода слова // при изменении буфера обмена, текст из буфера -> в строку ввода QObject::connect(mpClipboard, SIGNAL(changed(QClipboard::Mode)), this, SLOT(fromClipboardToLineEdit())); }
/* ** Implementation of read() */ static int sqlarfs_read( const char *path, char *buf, size_t size, off_t offset, struct fuse_file_info *fi ){ int rc; rc = loadCache(&path[1]); if( rc==0 ){ if( offset>=g.szCache ){ return 0; } if( offset+size>g.szCache ) size = g.szCache - offset; memcpy(buf, g.zCacheData + offset, size); return size; }else{ return rc; } }
TableGenerator::TableGenerator() : m_state(NoErrors), m_systemComposeDir(QString()) { initPossibleLocations(); QString composeFilePath = findComposeFile(); #ifdef DEBUG_GENERATOR // don't use cache when in debug mode. if (!composeFilePath.isEmpty()) qDebug() << "Using Compose file from: " << composeFilePath; #else QComposeCacheFileHeader fileInfo = readFileMetadata(composeFilePath); if (fileInfo.fileSize != 0) m_composeTable = loadCache(fileInfo); #endif if (m_composeTable.isEmpty() && cleanState()) { if (composeFilePath.isEmpty()) { m_state = MissingComposeFile; } else { QFile composeFile(composeFilePath); composeFile.open(QIODevice::ReadOnly); parseComposeFile(&composeFile); orderComposeTable(); if (m_composeTable.isEmpty()) { m_state = EmptyTable; #ifndef DEBUG_GENERATOR // don't save cache when in debug mode } else { fileInfo.cacheVersion = SupportedCacheVersion; saveCache(fileInfo, m_composeTable); #endif } } } #ifdef DEBUG_GENERATOR printComposeTable(); #endif }
void MaprTests::testMRInterResultAsync() { hThreadPool *pool = new hThreadPool(1); pool->run(); TaskLauncher flush_tasks_launcher(pool, 1, boost::bind(&MaprTests::onMRInterMergerFinished, this)); MRInterResult *inter = new MRInterResult("testMRInterResultAsync", new MapReduceInvertIndex, flush_tasks_launcher); const int nemits = 100; const int nparts = 10; int emits_per_part = nemits/nparts; for (int64_t i = 1; i<=nemits; i++) { InvertLine* line = new InvertLine(); for (int j = i; j<i+1000; j++) line->pages.push_back(j); //std::cout << line->pages[0] << " " << std::endl; inter->addEmit(i, line); } std::cout << "file written\n"; Int64VecPtr keys = inter->getKeys(); int key_r_b = 0; int key_r_e = emits_per_part; bool cid = 0; int key_b = 0; int key_e = fmin(key_b+emits_per_part, nemits); loadCache(inter, 0, keys, key_b, key_e); key_b += emits_per_part; key_e = fmin(key_b+emits_per_part, nemits); loadCache(inter, 1, keys, key_b, key_e); std::cout << "init caches loaded\n"; int nread = 0; while (1) { //std::cout << "waiting cache\n"; inter->condWaitCache(cid); //std::cout << "reading from cache " << key_r_b << " to " << key_r_e << "\n"; nread += key_r_e - key_r_b; // get for (int i = key_r_b; i<key_r_e; i++) { inter->getEmit(keys->at(i), cid); } key_r_b += emits_per_part; key_r_e = fmin(key_r_b+emits_per_part, nemits); if (key_r_b >= nemits) { std::cout << "read all: " << nread << std::endl; exit(0); //break; } key_b += emits_per_part; key_e = fmin(key_b+emits_per_part, nemits); /*if (key_b >= nemits) { continue; }*/ inter->clearCache(cid); pool->addTask(new boost::function<void()>( boost::bind(&MaprTests::loadCache, this, inter, cid, keys, key_b, key_e))); cid = !cid; } std::cout << "FINISHED\n"; exit(0); }
Registry::Registry() { loadCache(); }
void QMakeSourceFileInfo::setCacheFile(const QString &cf) { cachefile = cf; loadCache(cachefile); }
ApplicationCacheGroup* ApplicationCacheStorage::cacheGroupForURL(const KURL& url) { loadManifestHostHashes(); // Hash the host name and see if there's a manifest with the same host. if (!m_cacheHostSet.contains(urlHostHash(url))) return 0; // Check if a cache already exists in memory. CacheGroupMap::const_iterator end = m_cachesInMemory.end(); for (CacheGroupMap::const_iterator it = m_cachesInMemory.begin(); it != end; ++it) { ApplicationCacheGroup* group = it->second; if (!protocolHostAndPortAreEqual(url, group->manifestURL())) continue; if (ApplicationCache* cache = group->newestCache()) { if (cache->resourceForURL(url)) return group; } } if (!m_database.isOpen()) return 0; // Check the database. Look for all cache groups with a newest cache. SQLiteStatement statement(m_database, "SELECT id, manifestURL, newestCache FROM CacheGroups WHERE newestCache IS NOT NULL"); if (statement.prepare() != SQLResultOk) return 0; int result; while ((result = statement.step()) == SQLResultRow) { KURL manifestURL = KURL(statement.getColumnText(1)); if (!protocolHostAndPortAreEqual(url, manifestURL)) continue; // We found a cache group that matches. Now check if the newest cache has a resource with // a matching URL. unsigned newestCacheID = (unsigned)statement.getColumnInt64(2); RefPtr<ApplicationCache> cache = loadCache(newestCacheID); if (!cache->resourceForURL(url)) continue; ApplicationCacheGroup* group = new ApplicationCacheGroup(manifestURL); group->setStorageID((unsigned)statement.getColumnInt64(0)); group->setNewestCache(cache.release()); ASSERT(!m_cachesInMemory.contains(manifestURL)); m_cachesInMemory.set(group->manifestURL(), group); return group; } if (result != SQLResultDone) LOG_ERROR("Could not load cache group, error \"%s\"", m_database.lastErrorMsg()); return 0; }
void SecretManager::initData() { loadCache(); }