You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2021/07/13 04:54:01 UTC
[iotdb] 01/01: [To rel/0.11] Using cached pool to reduce the String
memory size in TsFileResourse
This is an automated email from the ASF dual-hosted git repository.
haonan pushed a commit to branch stirngmem11
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit f2d77fba8811657594e7f1fa4af14a39585c8532
Author: HTHou <hh...@outlook.com>
AuthorDate: Tue Jul 13 12:53:29 2021 +0800
[To rel/0.11] Using cached pool to reduce the String memory size in TsFileResourse
---
.../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);