You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2020/06/12 10:58:44 UTC

[GitHub] [incubator-iotdb] samperson1997 commented on a change in pull request #1356: Accelerate cache usage: combine get and contains

samperson1997 commented on a change in pull request #1356:
URL: https://github.com/apache/incubator-iotdb/pull/1356#discussion_r439350970



##########
File path: server/src/main/java/org/apache/iotdb/db/engine/cache/ChunkMetadataCache.java
##########
@@ -20,6 +20,7 @@
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collections;

Review comment:
       useless import

##########
File path: server/src/main/java/org/apache/iotdb/db/engine/cache/ChunkCache.java
##########
@@ -93,40 +93,33 @@ public Chunk get(ChunkMetadata chunkMetaData, TsFileSequenceReader reader) throw
 
     try {
       lock.readLock().lock();
-      if (lruCache.containsKey(chunkMetaData)) {
+      Chunk chunk = lruCache.get(chunkMetaData);
+      if (chunk != null) {
         cacheHitNum.incrementAndGet();
         printCacheLog(true);
-        Chunk chunk = lruCache.get(chunkMetaData);
         return new Chunk(chunk.getHeader(), chunk.getData().duplicate(), chunk.getDeletedAt());
       }
     } finally {
       lock.readLock().unlock();
     }
 
-    Lock cacheLock = lock.writeLock();

Review comment:
       useless import: `java.util.concurrent.locks.Lock`




----------------------------------------------------------------
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:
users@infra.apache.org