LeiRui commented on a change in pull request #262: [IOTDB-144]meta data cache
for query
URL: https://github.com/apache/incubator-iotdb/pull/262#discussion_r306152636
##########
File path:
iotdb/src/main/java/org/apache/iotdb/db/engine/cache/DeviceMetaDataCache.java
##########
@@ -19,77 +19,144 @@
package org.apache.iotdb.db.engine.cache;
import java.io.IOException;
-import java.util.LinkedHashMap;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
import java.util.Map;
-import java.util.Objects;
+import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
+import org.apache.iotdb.db.conf.IoTDBConfig;
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
+import org.apache.iotdb.db.engine.StorageEngine;
+import org.apache.iotdb.tsfile.file.metadata.ChunkMetaData;
import org.apache.iotdb.tsfile.file.metadata.TsDeviceMetadata;
import org.apache.iotdb.tsfile.file.metadata.TsFileMetaData;
+import org.apache.iotdb.tsfile.read.common.Path;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * This class is used to cache <code>DeviceMetaDataCache</code> of tsfile in
IoTDB.
+ * This class is used to cache <code>List<ChunkMetaData></code> of tsfile in
IoTDB. The caching
+ * strategy is LRU.
*/
public class DeviceMetaDataCache {
private static final Logger logger =
LoggerFactory.getLogger(DeviceMetaDataCache.class);
+ private static final IoTDBConfig config =
IoTDBDescriptor.getInstance().getConfig();
- private static final int CACHE_SIZE = 100;
+ private static StorageEngine storageEngine = StorageEngine.getInstance();
+
+ private static final long MEMORY_THRESHOLD_IN_B = (long) (0.3 * config
+ .getAllocateMemoryForRead());
/**
- * key: the file path + deviceId.
+ * key: file path dot deviceId dot sensorId.
+ * <p>
+ * value: chunkMetaData list of one timeseries in the file.
*/
- private LinkedHashMap<String, TsDeviceMetadata> lruCache;
+ private LruLinkedHashMap<String, List<ChunkMetaData>> lruCache;
private AtomicLong cacheHintNum = new AtomicLong();
Review comment:
Hit or hint?
----------------------------------------------------------------
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