void TextCache::Flush() { #ifdef ENABLE_OPENGL assert(pthread_equal(pthread_self(), OpenGL::thread)); #endif #ifndef ENABLE_OPENGL const ScopeLock protect(text_cache_mutex); #endif size_cache.Clear(); text_cache.Clear(); }
void LocalityFinder::GetLocality(m2::PointD const & pt, string & name) { Cache * working = nullptr; // Find suitable cache that includes needed point. for (auto & cache : m_caches) { if (cache.m_rect.IsPointInside(pt)) { working = &cache; break; } } if (working == nullptr) { // Find most unused cache. size_t minUsage = numeric_limits<size_t>::max(); for (auto & cache : m_caches) { if (cache.m_usage < minUsage) { working = &cache; minUsage = cache.m_usage; } } ASSERT(working, ()); working->Clear(); }
/** * Populate cache with test data. */ void Initialize() { Cache<int64_t, Organization> orgCache = Ignition::Get().GetCache<int64_t, Organization>(ORG_CACHE); // Clear cache before running the example. orgCache.Clear(); // Organizations. Organization org1("ApacheIgnite"); Organization org2("Other"); const int64_t org1Id = 1; const int64_t org2Id = 2; orgCache.Put(org1Id, org1); orgCache.Put(org2Id, org2); Cache<int64_t, Person> personCache = Ignition::Get().GetCache<int64_t, Person>(PERSON_CACHE); // Clear cache before running the example. personCache.Clear(); // People. Person p1(org1Id, "John", "Doe", "John Doe has Master Degree.", 2000); Person p2(org1Id, "Jane", "Doe", "Jane Doe has Bachelor Degree.", 1000); Person p3(org2Id, "John", "Smith", "John Smith has Bachelor Degree.", 1000); Person p4(org2Id, "Jane", "Smith", "Jane Smith has Master Degree.", 2000); // Note that in this example we use custom affinity key for Person objects // to ensure that all persons are collocated with their organizations. personCache.Put(1, p1); personCache.Put(2, p2); personCache.Put(3, p3); personCache.Put(4, p4); }
int main() { IgniteConfiguration cfg; cfg.jvmInitMem = 512; cfg.jvmMaxMem = 512; cfg.springCfgPath = "platforms/cpp/examples/putget-example/config/example-cache.xml"; try { // Start a node. Ignite grid = Ignition::Start(cfg); std::cout << std::endl; std::cout << ">>> Cache put-get example started." << std::endl; std::cout << std::endl; // Get cache instance. Cache<int, Organization> cache = grid.GetCache<int, Organization>(NULL); // Clear cache. cache.Clear(); PutGet(cache); PutGetAll(cache); // Stop node. Ignition::StopAll(false); } catch (IgniteError& err) { std::cout << "An error occurred: " << err.GetText() << std::endl; } std::cout << std::endl; std::cout << ">>> Example finished, press 'Enter' to exit ..." << std::endl; std::cout << std::endl; std::cin.get(); return 0; }
void LocalityFinder::RecreateCache(Cache & cache, m2::RectD rect) const { vector<shared_ptr<MwmInfo>> mwmsInfo; m_pIndex->GetMwmsInfo(mwmsInfo); cache.Clear(); CorrectMinimalRect(rect); covering::CoveringGetter cov(rect, covering::ViewportWithLowLevels); for (shared_ptr<MwmInfo> & info : mwmsInfo) { typedef feature::DataHeader HeaderT; MwmSet::MwmId mwmId(info); Index::MwmHandle const mwmHandle = m_pIndex->GetMwmHandleById(mwmId); MwmValue const * pMwm = mwmHandle.GetValue<MwmValue>(); if (pMwm && pMwm->GetHeader().GetType() == HeaderT::world) { HeaderT const & header = pMwm->GetHeader(); int const scale = header.GetLastScale(); // scales::GetUpperWorldScale() covering::IntervalsT const & interval = cov.Get(scale); ScaleIndex<ModelReaderPtr> index(pMwm->m_cont.GetReader(INDEX_FILE_TAG), pMwm->m_factory); FeaturesVector loader(pMwm->m_cont, header, pMwm->m_table); cache.m_rect = rect; for (size_t i = 0; i < interval.size(); ++i) { DoLoader doLoader(*this, loader, cache); index.ForEachInIntervalAndScale(doLoader, interval[i].first, interval[i].second, scale); } } } }