You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/07/12 19:51:48 UTC

[GitHub] [arrow] jpedroantunes commented on a change in pull request #10465: ARROW-12986: [C++][Gandiva] Implement new cache eviction policy algorithm in Gandiva

jpedroantunes commented on a change in pull request #10465:
URL: https://github.com/apache/arrow/pull/10465#discussion_r667844965



##########
File path: cpp/src/gandiva/cache.h
##########
@@ -34,26 +35,29 @@ void LogCacheSize(size_t capacity);
 template <class KeyType, typename ValueType>
 class Cache {
  public:
-  explicit Cache(size_t capacity) : cache_(capacity) { LogCacheSize(capacity); }
+  explicit Cache(size_t capacity) {
+    this->cache_ = std::make_unique<GreedyDualSizeCache<KeyType, ValueType>>(capacity);
+    LogCacheSize(capacity);
+  }
 
   Cache() : Cache(GetCapacity()) {}
 
   ValueType GetModule(KeyType cache_key) {
-    arrow::util::optional<ValueType> result;
+    arrow::util::optional<ValueCacheObject<ValueType>> result;
     mtx_.lock();
-    result = cache_.get(cache_key);
+    result = (*cache_).get(cache_key);
     mtx_.unlock();
-    return result != arrow::util::nullopt ? *result : nullptr;
+    return result != arrow::util::nullopt ? (*result).module : nullptr;
   }
 
-  void PutModule(KeyType cache_key, ValueType module) {
+  void PutModule(KeyType cache_key, ValueCacheObject<ValueType> valueCacheObject) {
     mtx_.lock();
-    cache_.insert(cache_key, module);
+    (*cache_).insert(cache_key, valueCacheObject);
     mtx_.unlock();
   }
 
  private:
-  LruCache<KeyType, ValueType> cache_;
+  std::unique_ptr<GreedyDualSizeCache<KeyType, ValueType>> cache_;

Review comment:
       Before that, we were going to use cache of different types. Since, we not need it anymore I will change it!




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org