OmniSciDB  ca0c39ec8f
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE > Class Template Referenceabstract

#include <DataRecycler.h>

Public Types

using CachedItemContainer = std::vector< CachedItem< CACHED_ITEM_TYPE, META_INFO_TYPE >>
 
using PerDeviceCacheItemContainer = std::unordered_map< DeviceIdentifier, std::shared_ptr< CachedItemContainer >>
 
using PerTypeCacheItemContainer = std::unordered_map< CacheItemType, std::shared_ptr< PerDeviceCacheItemContainer >>
 
using PerTypeCacheMetricTracker = std::unordered_map< CacheItemType, CacheMetricTracker >
 

Public Member Functions

 DataRecycler (const std::vector< CacheItemType > &item_types, size_t total_cache_size, size_t max_item_size, int num_gpus)
 
virtual ~DataRecycler ()=default
 
virtual CACHED_ITEM_TYPE getItemFromCache (QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier, std::optional< META_INFO_TYPE > meta_info=std::nullopt)=0
 
virtual void putItemToCache (QueryPlanHash key, CACHED_ITEM_TYPE item_ptr, CacheItemType item_type, DeviceIdentifier device_identifier, size_t item_size, size_t compute_time, std::optional< META_INFO_TYPE > meta_info=std::nullopt)=0
 
virtual void initCache ()=0
 
virtual void clearCache ()=0
 
virtual void markCachedItemAsDirty (size_t table_key, std::unordered_set< QueryPlanHash > &key_set, CacheItemType item_type, DeviceIdentifier device_identifier)=0
 
void markCachedItemAsDirtyImpl (QueryPlanHash key, CachedItemContainer &m) const
 
bool isCachedItemDirty (QueryPlanHash key, CachedItemContainer &m) const
 
virtual std::string toString () const =0
 
std::shared_ptr
< CachedItemContainer
getCachedItemContainer (CacheItemType item_type, DeviceIdentifier device_identifier) const
 
std::optional< CachedItem
< CACHED_ITEM_TYPE,
META_INFO_TYPE > > 
getCachedItemWithoutConsideringMetaInfo (QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier, CachedItemContainer &m, std::lock_guard< std::mutex > &lock)
 
size_t getCurrentNumCachedItems (CacheItemType item_type, DeviceIdentifier device_identifier) const
 
size_t getCurrentNumDirtyCachedItems (CacheItemType item_type, DeviceIdentifier device_identifier) const
 
size_t getCurrentNumCleanCachedItems (CacheItemType item_type, DeviceIdentifier device_identifier) const
 
size_t getCurrentCacheSizeForDevice (CacheItemType item_type, DeviceIdentifier device_identifier) const
 
std::shared_ptr< CacheItemMetricgetCachedItemMetric (CacheItemType item_type, DeviceIdentifier device_identifier, QueryPlanHash key) const
 
void setTotalCacheSize (CacheItemType item_type, size_t new_total_cache_size)
 
void setMaxCacheItemSize (CacheItemType item_type, size_t new_max_cache_item_size)
 

Protected Member Functions

void removeCachedItemFromBeginning (CacheItemType item_type, DeviceIdentifier device_identifier, int offset)
 
void sortCacheContainerByQueryMetric (CacheItemType item_type, DeviceIdentifier device_identifier)
 
std::mutex & getCacheLock () const
 
CacheMetricTrackergetMetricTracker (CacheItemType item_type)
 
CacheMetricTracker const & getMetricTracker (CacheItemType item_type) const
 
std::unordered_set
< CacheItemType > const & 
getCacheItemType () const
 
PerTypeCacheItemContainer const & getItemCache () const
 

Private Member Functions

virtual bool hasItemInCache (QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier, std::lock_guard< std::mutex > &lock, std::optional< META_INFO_TYPE > meta_info=std::nullopt) const =0
 
virtual void removeItemFromCache (QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier, std::lock_guard< std::mutex > &lock, std::optional< META_INFO_TYPE > meta_info=std::nullopt)=0
 
virtual void cleanupCacheForInsertion (CacheItemType item_type, DeviceIdentifier device_identifier, size_t required_size, std::lock_guard< std::mutex > &lock, std::optional< META_INFO_TYPE > meta_info=std::nullopt)=0
 

Private Attributes

std::unordered_set< CacheItemTypecache_item_types_
 
PerTypeCacheMetricTracker metric_tracker_
 
PerTypeCacheItemContainer cached_items_container_
 
std::mutex cache_lock_
 

Detailed Description

template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
class DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >

Definition at line 451 of file DataRecycler.h.

Member Typedef Documentation

template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
using DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::CachedItemContainer = std::vector<CachedItem<CACHED_ITEM_TYPE, META_INFO_TYPE>>

Definition at line 453 of file DataRecycler.h.

template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
using DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::PerDeviceCacheItemContainer = std::unordered_map<DeviceIdentifier, std::shared_ptr<CachedItemContainer>>

Definition at line 455 of file DataRecycler.h.

template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
using DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::PerTypeCacheItemContainer = std::unordered_map<CacheItemType, std::shared_ptr<PerDeviceCacheItemContainer>>

Definition at line 457 of file DataRecycler.h.

template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
using DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::PerTypeCacheMetricTracker = std::unordered_map<CacheItemType, CacheMetricTracker>

Definition at line 458 of file DataRecycler.h.

Constructor & Destructor Documentation

template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::DataRecycler ( const std::vector< CacheItemType > &  item_types,
size_t  total_cache_size,
size_t  max_item_size,
int  num_gpus 
)
inline

Definition at line 460 of file DataRecycler.h.

463  {
464  for (auto& item_type : item_types) {
465  cache_item_types_.insert(item_type);
466  metric_tracker_.emplace(
467  item_type,
468  CacheMetricTracker(item_type, total_cache_size, max_item_size, num_gpus));
469  auto item_container = std::make_shared<PerDeviceCacheItemContainer>();
470  for (int gpu_device_identifier = num_gpus; gpu_device_identifier >= 1;
471  --gpu_device_identifier) {
472  item_container->emplace(gpu_device_identifier,
473  std::make_shared<CachedItemContainer>());
474  }
475  item_container->emplace(DataRecyclerUtil::CPU_DEVICE_IDENTIFIER,
476  std::make_shared<CachedItemContainer>());
477  cached_items_container_.emplace(item_type, item_container);
478  }
479  }
std::unordered_set< CacheItemType > cache_item_types_
Definition: DataRecycler.h:700
PerTypeCacheMetricTracker metric_tracker_
Definition: DataRecycler.h:703
PerTypeCacheItemContainer cached_items_container_
Definition: DataRecycler.h:706
static constexpr DeviceIdentifier CPU_DEVICE_IDENTIFIER
Definition: DataRecycler.h:136
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
virtual DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::~DataRecycler ( )
virtualdefault

Member Function Documentation

template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
virtual void DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::cleanupCacheForInsertion ( CacheItemType  item_type,
DeviceIdentifier  device_identifier,
size_t  required_size,
std::lock_guard< std::mutex > &  lock,
std::optional< META_INFO_TYPE >  meta_info = std::nullopt 
)
privatepure virtual
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
virtual void DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::clearCache ( )
pure virtual
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
std::shared_ptr<CachedItemContainer> DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::getCachedItemContainer ( CacheItemType  item_type,
DeviceIdentifier  device_identifier 
) const
inline

Definition at line 530 of file DataRecycler.h.

Referenced by DataRecycler< std::optional< HashType >, EMPTY_META_INFO >::getCurrentNumCachedItems(), DataRecycler< std::optional< HashType >, EMPTY_META_INFO >::getCurrentNumCleanCachedItems(), DataRecycler< std::optional< HashType >, EMPTY_META_INFO >::getCurrentNumDirtyCachedItems(), DataRecycler< std::optional< HashType >, EMPTY_META_INFO >::removeCachedItemFromBeginning(), and DataRecycler< std::optional< HashType >, EMPTY_META_INFO >::sortCacheContainerByQueryMetric().

532  {
533  auto item_type_container_itr = cached_items_container_.find(item_type);
534  if (item_type_container_itr != cached_items_container_.end()) {
535  auto device_type_container_itr =
536  item_type_container_itr->second->find(device_identifier);
537  return device_type_container_itr != item_type_container_itr->second->end()
538  ? device_type_container_itr->second
539  : nullptr;
540  }
541  return nullptr;
542  }
PerTypeCacheItemContainer cached_items_container_
Definition: DataRecycler.h:706

+ Here is the caller graph for this function:

template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
std::shared_ptr<CacheItemMetric> DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::getCachedItemMetric ( CacheItemType  item_type,
DeviceIdentifier  device_identifier,
QueryPlanHash  key 
) const
inline

Definition at line 600 of file DataRecycler.h.

602  {
603  std::lock_guard<std::mutex> lock(cache_lock_);
604  auto cache_metric_tracker = getMetricTracker(item_type);
605  return cache_metric_tracker.getCacheItemMetric(key, device_identifier);
606  }
CacheMetricTracker & getMetricTracker(CacheItemType item_type)
Definition: DataRecycler.h:656
std::mutex cache_lock_
Definition: DataRecycler.h:708
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
std::optional<CachedItem<CACHED_ITEM_TYPE, META_INFO_TYPE> > DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::getCachedItemWithoutConsideringMetaInfo ( QueryPlanHash  key,
CacheItemType  item_type,
DeviceIdentifier  device_identifier,
CachedItemContainer m,
std::lock_guard< std::mutex > &  lock 
)
inline

Definition at line 545 of file DataRecycler.h.

549  {
550  auto candidate_it = std::find_if(
551  m.begin(),
552  m.end(),
553  [&key](const CachedItem<CACHED_ITEM_TYPE, META_INFO_TYPE>& cached_item) {
554  return cached_item.key == key;
555  });
556  if (candidate_it != m.end()) {
557  if (candidate_it->isDirty()) {
559  key, item_type, device_identifier, lock, candidate_it->meta_info);
560  return std::nullopt;
561  }
562  return *candidate_it;
563  }
564  return std::nullopt;
565  }
virtual void removeItemFromCache(QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier, std::lock_guard< std::mutex > &lock, std::optional< META_INFO_TYPE > meta_info=std::nullopt)=0
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
std::unordered_set<CacheItemType> const& DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::getCacheItemType ( ) const
inlineprotected

Definition at line 666 of file DataRecycler.h.

666  {
667  return cache_item_types_;
668  }
std::unordered_set< CacheItemType > cache_item_types_
Definition: DataRecycler.h:700
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
std::mutex& DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::getCacheLock ( ) const
inlineprotected

Definition at line 654 of file DataRecycler.h.

654 { return cache_lock_; }
std::mutex cache_lock_
Definition: DataRecycler.h:708
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
size_t DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::getCurrentCacheSizeForDevice ( CacheItemType  item_type,
DeviceIdentifier  device_identifier 
) const
inline

Definition at line 592 of file DataRecycler.h.

593  {
594  std::lock_guard<std::mutex> lock(cache_lock_);
595  auto metric_tracker = getMetricTracker(item_type);
596  auto current_size_opt = metric_tracker.getCurrentCacheSize(device_identifier);
597  return current_size_opt ? current_size_opt.value() : 0;
598  }
CacheMetricTracker & getMetricTracker(CacheItemType item_type)
Definition: DataRecycler.h:656
std::mutex cache_lock_
Definition: DataRecycler.h:708
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
size_t DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::getCurrentNumCachedItems ( CacheItemType  item_type,
DeviceIdentifier  device_identifier 
) const
inline

Definition at line 567 of file DataRecycler.h.

568  {
569  std::lock_guard<std::mutex> lock(cache_lock_);
570  auto container = getCachedItemContainer(item_type, device_identifier);
571  return container ? container->size() : 0;
572  }
std::shared_ptr< CachedItemContainer > getCachedItemContainer(CacheItemType item_type, DeviceIdentifier device_identifier) const
Definition: DataRecycler.h:530
std::mutex cache_lock_
Definition: DataRecycler.h:708
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
size_t DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::getCurrentNumCleanCachedItems ( CacheItemType  item_type,
DeviceIdentifier  device_identifier 
) const
inline

Definition at line 583 of file DataRecycler.h.

584  {
585  std::lock_guard<std::mutex> lock(cache_lock_);
586  auto container = getCachedItemContainer(item_type, device_identifier);
587  return std::count_if(container->begin(),
588  container->end(),
589  [](const auto& cached_item) { return !cached_item.isDirty(); });
590  }
std::shared_ptr< CachedItemContainer > getCachedItemContainer(CacheItemType item_type, DeviceIdentifier device_identifier) const
Definition: DataRecycler.h:530
std::mutex cache_lock_
Definition: DataRecycler.h:708
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
size_t DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::getCurrentNumDirtyCachedItems ( CacheItemType  item_type,
DeviceIdentifier  device_identifier 
) const
inline

Definition at line 574 of file DataRecycler.h.

575  {
576  std::lock_guard<std::mutex> lock(cache_lock_);
577  auto container = getCachedItemContainer(item_type, device_identifier);
578  return std::count_if(container->begin(),
579  container->end(),
580  [](const auto& cached_item) { return cached_item.isDirty(); });
581  }
std::shared_ptr< CachedItemContainer > getCachedItemContainer(CacheItemType item_type, DeviceIdentifier device_identifier) const
Definition: DataRecycler.h:530
std::mutex cache_lock_
Definition: DataRecycler.h:708
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
PerTypeCacheItemContainer const& DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::getItemCache ( ) const
inlineprotected

Definition at line 670 of file DataRecycler.h.

670  {
672  }
PerTypeCacheItemContainer cached_items_container_
Definition: DataRecycler.h:706
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
virtual CACHED_ITEM_TYPE DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::getItemFromCache ( QueryPlanHash  key,
CacheItemType  item_type,
DeviceIdentifier  device_identifier,
std::optional< META_INFO_TYPE >  meta_info = std::nullopt 
)
pure virtual

Implemented in ChunkMetadataRecycler.

template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
CacheMetricTracker& DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::getMetricTracker ( CacheItemType  item_type)
inlineprotected

Definition at line 656 of file DataRecycler.h.

Referenced by DataRecycler< std::optional< HashType >, EMPTY_META_INFO >::getCachedItemMetric(), DataRecycler< std::optional< HashType >, EMPTY_META_INFO >::getCurrentCacheSizeForDevice(), DataRecycler< std::optional< HashType >, EMPTY_META_INFO >::getMetricTracker(), DataRecycler< std::optional< HashType >, EMPTY_META_INFO >::setMaxCacheItemSize(), and DataRecycler< std::optional< HashType >, EMPTY_META_INFO >::setTotalCacheSize().

656  {
657  auto metric_iter = metric_tracker_.find(item_type);
658  CHECK(metric_iter != metric_tracker_.end());
659  return metric_iter->second;
660  }
PerTypeCacheMetricTracker metric_tracker_
Definition: DataRecycler.h:703
#define CHECK(condition)
Definition: Logger.h:222

+ Here is the caller graph for this function:

template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
CacheMetricTracker const& DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::getMetricTracker ( CacheItemType  item_type) const
inlineprotected

Definition at line 662 of file DataRecycler.h.

662  {
663  return const_cast<DataRecycler*>(this)->getMetricTracker(item_type);
664  }
CacheMetricTracker & getMetricTracker(CacheItemType item_type)
Definition: DataRecycler.h:656
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
virtual bool DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::hasItemInCache ( QueryPlanHash  key,
CacheItemType  item_type,
DeviceIdentifier  device_identifier,
std::lock_guard< std::mutex > &  lock,
std::optional< META_INFO_TYPE >  meta_info = std::nullopt 
) const
privatepure virtual
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
virtual void DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::initCache ( )
pure virtual
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
bool DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::isCachedItemDirty ( QueryPlanHash  key,
CachedItemContainer m 
) const
inline

Definition at line 518 of file DataRecycler.h.

518  {
519  auto candidate_it = std::find_if(
520  m.begin(),
521  m.end(),
522  [&key](const CachedItem<CACHED_ITEM_TYPE, META_INFO_TYPE>& cached_item) {
523  return cached_item.key == key;
524  });
525  return candidate_it != m.end() && candidate_it->isDirty();
526  }
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
virtual void DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::markCachedItemAsDirty ( size_t  table_key,
std::unordered_set< QueryPlanHash > &  key_set,
CacheItemType  item_type,
DeviceIdentifier  device_identifier 
)
pure virtual
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
void DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::markCachedItemAsDirtyImpl ( QueryPlanHash  key,
CachedItemContainer m 
) const
inline

Definition at line 506 of file DataRecycler.h.

506  {
507  auto candidate_it = std::find_if(
508  m.begin(),
509  m.end(),
510  [&key](const CachedItem<CACHED_ITEM_TYPE, META_INFO_TYPE>& cached_item) {
511  return cached_item.key == key;
512  });
513  if (candidate_it != m.end()) {
514  candidate_it->setDirty();
515  }
516  }
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
virtual void DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::putItemToCache ( QueryPlanHash  key,
CACHED_ITEM_TYPE  item_ptr,
CacheItemType  item_type,
DeviceIdentifier  device_identifier,
size_t  item_size,
size_t  compute_time,
std::optional< META_INFO_TYPE >  meta_info = std::nullopt 
)
pure virtual
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
void DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::removeCachedItemFromBeginning ( CacheItemType  item_type,
DeviceIdentifier  device_identifier,
int  offset 
)
inlineprotected

Definition at line 623 of file DataRecycler.h.

625  {
626  // it removes cached items located from `idx 0` to `offset`
627  // so, call this function after sorting the cached items container vec
628  // and we should call this function under the proper locking scheme
629  auto container = getCachedItemContainer(item_type, device_identifier);
630  CHECK(container);
631  container->erase(container->begin(), container->begin() + offset);
632  }
std::shared_ptr< CachedItemContainer > getCachedItemContainer(CacheItemType item_type, DeviceIdentifier device_identifier) const
Definition: DataRecycler.h:530
#define CHECK(condition)
Definition: Logger.h:222
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
virtual void DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::removeItemFromCache ( QueryPlanHash  key,
CacheItemType  item_type,
DeviceIdentifier  device_identifier,
std::lock_guard< std::mutex > &  lock,
std::optional< META_INFO_TYPE >  meta_info = std::nullopt 
)
privatepure virtual

Implemented in HashtableRecycler, ResultSetRecycler, ChunkMetadataRecycler, OverlapsTuningParamRecycler, and HashingSchemeRecycler.

Referenced by DataRecycler< std::optional< HashType >, EMPTY_META_INFO >::getCachedItemWithoutConsideringMetaInfo().

+ Here is the caller graph for this function:

template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
void DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::setMaxCacheItemSize ( CacheItemType  item_type,
size_t  new_max_cache_item_size 
)
inline

Definition at line 615 of file DataRecycler.h.

615  {
616  if (new_max_cache_item_size > 0) {
617  std::lock_guard<std::mutex> lock(cache_lock_);
618  getMetricTracker(item_type).setMaxCacheItemSize(new_max_cache_item_size);
619  }
620  }
CacheMetricTracker & getMetricTracker(CacheItemType item_type)
Definition: DataRecycler.h:656
void setMaxCacheItemSize(size_t new_max_cache_item_size)
Definition: DataRecycler.h:403
std::mutex cache_lock_
Definition: DataRecycler.h:708
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
void DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::setTotalCacheSize ( CacheItemType  item_type,
size_t  new_total_cache_size 
)
inline

Definition at line 608 of file DataRecycler.h.

608  {
609  if (new_total_cache_size > 0) {
610  std::lock_guard<std::mutex> lock(cache_lock_);
611  getMetricTracker(item_type).setTotalCacheSize(new_total_cache_size);
612  }
613  }
CacheMetricTracker & getMetricTracker(CacheItemType item_type)
Definition: DataRecycler.h:656
std::mutex cache_lock_
Definition: DataRecycler.h:708
void setTotalCacheSize(size_t new_total_cache_size)
Definition: DataRecycler.h:398
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
void DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::sortCacheContainerByQueryMetric ( CacheItemType  item_type,
DeviceIdentifier  device_identifier 
)
inlineprotected

Definition at line 634 of file DataRecycler.h.

635  {
636  // should call this function under the proper locking scheme
637  auto container = getCachedItemContainer(item_type, device_identifier);
638  CHECK(container);
639  std::sort(container->begin(),
640  container->end(),
643  auto& left_metrics = left.item_metric->getMetrics();
644  auto& right_metrics = right.item_metric->getMetrics();
645  for (size_t i = 0; i < CacheMetricType::NUM_METRIC_TYPE; ++i) {
646  if (left_metrics[i] != right_metrics[i]) {
647  return left_metrics[i] < right_metrics[i];
648  }
649  }
650  return false;
651  });
652  }
DEVICE void sort(ARGS &&...args)
Definition: gpu_enabled.h:105
std::shared_ptr< CachedItemContainer > getCachedItemContainer(CacheItemType item_type, DeviceIdentifier device_identifier) const
Definition: DataRecycler.h:530
#define CHECK(condition)
Definition: Logger.h:222
std::shared_ptr< CacheItemMetric > item_metric
Definition: DataRecycler.h:440
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
virtual std::string DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::toString ( ) const
pure virtual

Member Data Documentation

template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
std::unordered_set<CacheItemType> DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::cache_item_types_
private
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
PerTypeCacheMetricTracker DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::metric_tracker_
private

The documentation for this class was generated from the following file: