You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2020/12/19 03:09:27 UTC

[iotdb] branch Parallelism011 created (now 5ea2d80)

This is an automated email from the ASF dual-hosted git repository.

jackietien pushed a change to branch Parallelism011
in repository https://gitbox.apache.org/repos/asf/iotdb.git.


      at 5ea2d80  change parallelism in timeseries metadata cache

This branch includes the following new commits:

     new 5ea2d80  change parallelism in timeseries metadata cache

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[iotdb] 01/01: change parallelism in timeseries metadata cache

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jackietien pushed a commit to branch Parallelism011
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 5ea2d80d29d237b1f23e11edef0c7174e10e19ff
Author: JackieTien97 <Ja...@foxmail.com>
AuthorDate: Sat Dec 19 11:08:53 2020 +0800

    change parallelism in timeseries metadata cache
---
 .../iotdb/db/engine/cache/TimeSeriesMetadataCache.java      | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/engine/cache/TimeSeriesMetadataCache.java b/server/src/main/java/org/apache/iotdb/db/engine/cache/TimeSeriesMetadataCache.java
index 8273476..05ecabd 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/cache/TimeSeriesMetadataCache.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/cache/TimeSeriesMetadataCache.java
@@ -20,9 +20,13 @@
 package org.apache.iotdb.db.engine.cache;
 
 import java.io.IOException;
+import java.lang.ref.WeakReference;
+import java.util.Collections;
 import java.util.List;
+import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
+import java.util.WeakHashMap;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
@@ -60,6 +64,10 @@ public class TimeSeriesMetadataCache {
 
   private final ReadWriteLock lock = new ReentrantReadWriteLock();
 
+  private final Map<String, WeakReference<String>> devices = Collections
+      .synchronizedMap(new WeakHashMap<>());
+  private static final String SEPARATOR = "$";
+
 
   private TimeSeriesMetadataCache() {
     if (CACHE_ENABLE) {
@@ -126,8 +134,9 @@ public class TimeSeriesMetadataCache {
       cacheHitNum.incrementAndGet();
       printCacheLog(true);
     } else {
-      // allow for the parallelism of different devices
-      synchronized (key.device.intern()) {
+      // allow for the parallelism of different devices in different files
+      synchronized (devices
+          .computeIfAbsent(key.device + SEPARATOR + key.filePath, WeakReference::new)) {
         // double check
         lock.readLock().lock();
         try {