| 476 | } |
| 477 | |
| 478 | TAtomicSharedPtr<NCB::IQuantizedPoolLoader> NCB::TQuantizedPoolLoadersCache::GetLoader( |
| 479 | const TPathWithScheme& pathWithScheme, |
| 480 | TDatasetSubset loadSubset |
| 481 | ) { |
| 482 | auto& loadersCache = GetRef(); |
| 483 | TAtomicSharedPtr<IQuantizedPoolLoader> loader = nullptr; |
| 484 | with_lock(loadersCache.Lock) { |
| 485 | CATBOOST_DEBUG_LOG << __PRETTY_FUNCTION__ << ": loaders cache size " << loadersCache.Cache.size() << Endl; |
| 486 | const auto loaderKey = std::make_pair(pathWithScheme, loadSubset); |
| 487 | if (!loadersCache.Cache.contains(loaderKey)) { |
| 488 | loader = GetProcessor<IQuantizedPoolLoader, const TPathWithScheme&>( |
| 489 | pathWithScheme, |
| 490 | pathWithScheme).Release(); |
| 491 | loadersCache.Cache[loaderKey] = loader; |
| 492 | if (loadSubset.HasFeatures) { |
| 493 | TLoadQuantizedPoolParameters params{/*LockMemory=*/false, /*Precharge=*/false, loadSubset}; |
| 494 | loader->LoadQuantizedPool(params); |
| 495 | } |
| 496 | } |
| 497 | loader = loadersCache.Cache.at(loaderKey); |
| 498 | } |
| 499 | return loader; |
| 500 | } |
| 501 | |
| 502 | bool NCB::TQuantizedPoolLoadersCache::HaveLoader(const TPathWithScheme& pathWithScheme, TDatasetSubset loadSubset) { |
| 503 | auto& loadersCache = GetRef(); |