Class DataRecycler

template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
class DataRecycler

Public Types

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

Public Functions

DataRecycler(const std::vector<CacheItemType> &item_types, size_t total_cache_size, size_t max_item_size, int num_gpus)
virtual ~DataRecycler()
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<CacheItemMetric> getCachedItemMetric(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 Functions

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

Private 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 Members

std::unordered_set<CacheItemType> cache_item_types_
PerTypeCacheMetricTracker metric_tracker_
PerTypeCacheItemContainer cached_items_container_
std::mutex cache_lock_