23 std::optional<EMPTY_META_INFO> meta_info) {
32 key, item_type, device_identifier, *layout_cache, lock);
33 if (candidate_layout) {
34 CHECK(!candidate_layout->isDirty());
35 VLOG(1) <<
"[" << item_type <<
", "
37 <<
"] Recycle hashtable layout in cache: "
39 <<
"(key: " << key <<
")";
40 return candidate_layout->cached_item;
46 std::optional<HashType> item,
51 std::optional<EMPTY_META_INFO> meta_info) {
60 key, item_type, device_identifier, *layout_cache, lock);
61 if (candidate_layout) {
64 layout_cache->emplace_back(key, item,
nullptr, meta_info);
65 VLOG(1) <<
"[" << item_type <<
", "
67 <<
"] Put hashtable layout to cache (key: " << key <<
")";
75 std::lock_guard<std::mutex>& lock,
76 std::optional<EMPTY_META_INFO> meta_info) {
78 auto filter = [key](
auto const& item) {
return item.key == key; };
79 auto itr = std::find_if(layout_cache->cbegin(), layout_cache->cend(), filter);
80 if (itr == layout_cache->cend()) {
83 VLOG(1) <<
"[" << item_type <<
", "
85 <<
"] remove cached item from cache (key: " << key <<
")";
86 layout_cache->erase(itr);
94 if (!layout_cache_container->empty()) {
97 <<
"] clear cache (# items: " << layout_cache_container->size() <<
")";
98 layout_cache_container->clear();
104 std::unordered_set<QueryPlanHash>& key_set,
113 for (
auto key : key_set) {
121 std::ostringstream oss;
122 oss <<
"Hashing scheme cache:\n";
126 for (
auto& kv : *layout_cache_container) {
127 oss <<
"\tkey: " << kv.key
137 std::lock_guard<std::mutex>& lock,
138 std::optional<EMPTY_META_INFO> meta_info)
const {
147 [&key](
const auto& cached_item) {
return cached_item.key == key; });
std::mutex & getCacheLock() const
static std::string getDeviceIdentifierString(DeviceIdentifier device_identifier)
bool hasItemInCache(QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier, std::lock_guard< std::mutex > &lock, std::optional< EMPTY_META_INFO > meta_info=std::nullopt) const override
std::optional< CachedItem< std::optional< HashType >, EMPTY_META_INFO > > getCachedItemWithoutConsideringMetaInfo(QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier, CachedItemContainer &m, std::lock_guard< std::mutex > &lock)
void clearCache() override
constexpr QueryPlanHash EMPTY_HASHED_PLAN_DAG_KEY
constexpr DeviceIdentifier LAYOUT_CACHE_DEVICE_IDENTIFIER
std::shared_ptr< CachedItemContainer > getCachedItemContainer(CacheItemType item_type, DeviceIdentifier device_identifier) const
void markCachedItemAsDirtyImpl(QueryPlanHash key, CachedItemContainer &m) const
bool g_enable_data_recycler
void markCachedItemAsDirty(size_t table_key, std::unordered_set< QueryPlanHash > &key_set, CacheItemType item_type, DeviceIdentifier device_identifier) override
void putItemToCache(QueryPlanHash key, std::optional< HashType > item, CacheItemType item_type, DeviceIdentifier device_identifier, size_t item_size, size_t compute_time, std::optional< EMPTY_META_INFO > meta_info=std::nullopt) override
static std::string getHashTypeString(HashType ht) noexcept
void removeItemFromCache(QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier, std::lock_guard< std::mutex > &lock, std::optional< EMPTY_META_INFO > meta_info=std::nullopt) override
virtual std::optional< HashType > getItemFromCache(QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier, std::optional< EMPTY_META_INFO > meta_info=std::nullopt)=0
bool any_of(std::vector< Analyzer::Expr * > const &target_exprs)
std::string toString() const override
bool g_use_hashtable_cache