arp7 commented on a change in pull request #1100: HDDS-1802. Add Eviction
policy for table cache.
URL: https://github.com/apache/hadoop/pull/1100#discussion_r303692949
##########
File path:
hadoop-hdds/common/src/main/java/org/apache/hadoop/utils/db/TypedTable.java
##########
@@ -104,14 +148,25 @@ public boolean isExist(KEY key) throws IOException {
public VALUE get(KEY key) throws IOException {
// Here the metadata lock will guarantee that cache is not updated for same
// key during get key.
- CacheValue< VALUE > cacheValue = cache.get(new CacheKey<>(key));
- if (cacheValue == null) {
- // If no cache for the table or if it does not exist in cache get from
- // RocksDB table.
+
+ // First get from cache. If it has return value.
+ // If it does not have
+ // If cache cleanup policy is NEVER return null. Because cache here is
+ // full table data in-memory, so no need to get from underlying rocksdb
+ // table.
+ // If cache cleanup policy is AFTER_FLUSH return from underlying rocksdb
+ // table. As it might have been cleaned up from cache, might be there in
+ // DB.
+ CacheValue<VALUE> cacheValue =
+ Optional.fromNullable(cache.get(new CacheKey<>(key))).orNull();
+ if (cacheValue != null) {
+ return cacheValue.getCacheValue();
+ }
+
+ if (cacheCleanupPolicy == TableCacheImpl.CacheCleanupPolicy.AFTER_FLUSH) {
Review comment:
Same here.. we should not have these checks here.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]