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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]