You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2021/07/13 05:11:17 UTC

[iotdb] branch rel/0.11 updated: [To rel/0.11] Using cached pool to reduce the String memory size in TsFileResourse (#3549)

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

qiaojialin pushed a commit to branch rel/0.11
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/rel/0.11 by this push:
     new 974c3c0  [To rel/0.11] Using cached pool to reduce the String memory size in TsFileResourse (#3549)
974c3c0 is described below

commit 974c3c016a41d73b4f2e3129622ab677f4bc795b
Author: Haonan <hh...@outlook.com>
AuthorDate: Tue Jul 13 13:10:55 2021 +0800

    [To rel/0.11] Using cached pool to reduce the String memory size in TsFileResourse (#3549)
---
 .../org/apache/iotdb/db/engine/storagegroup/TsFileResource.java     | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/TsFileResource.java b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/TsFileResource.java
index 6e79298..6035381 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/TsFileResource.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/TsFileResource.java
@@ -253,10 +253,16 @@ public class TsFileResource {
     try (OutputStream outputStream =
         fsFactory.getBufferedOutputStream(file + RESOURCE_SUFFIX + TEMP_SUFFIX)) {
       ReadWriteIOUtils.write(this.deviceToIndex.size(), outputStream);
+      Map<String, Integer> stringMemoryReducedMap = new ConcurrentHashMap<>();
       for (Entry<String, Integer> entry : this.deviceToIndex.entrySet()) {
+        // To reduce the String number in memory,
+        // use the deviceId from cached pool
+        stringMemoryReducedMap.put(cachedDevicePool.computeIfAbsent(entry.getKey(), k -> k),
+            entry.getValue());
         ReadWriteIOUtils.write(entry.getKey(), outputStream);
         ReadWriteIOUtils.write(startTimes[entry.getValue()], outputStream);
       }
+      this.deviceToIndex = stringMemoryReducedMap;
       ReadWriteIOUtils.write(this.deviceToIndex.size(), outputStream);
       for (Entry<String, Integer> entry : this.deviceToIndex.entrySet()) {
         ReadWriteIOUtils.write(entry.getKey(), outputStream);