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 05:13:40 UTC
[iotdb] branch stirngmem12 created (now 56468a5)
This is an automated email from the ASF dual-hosted git repository.
haonan pushed a change to branch stirngmem12
in repository https://gitbox.apache.org/repos/asf/iotdb.git.
at 56468a5 [To rel/0.12] Using cached pool to reduce the String memory size in TsFileResourse
This branch includes the following new commits:
new 56468a5 [To rel/0.12] Using cached pool to reduce the String memory size in TsFileResourse
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: [To rel/0.12] Using cached pool to reduce the String
memory size in TsFileResourse
Posted by ha...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
haonan pushed a commit to branch stirngmem12
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 56468a5c08fa9be9b70f6c563fd797104778d390
Author: HTHou <hh...@outlook.com>
AuthorDate: Tue Jul 13 13:13:00 2021 +0800
[To rel/0.12] Using cached pool to reduce the String memory size in TsFileResourse
---
.../iotdb/db/engine/storagegroup/timeindex/DeviceTimeIndex.java | 6 +++++-
.../iotdb/db/engine/storagegroup/timeindex/FileTimeIndex.java | 6 +++++-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/timeindex/DeviceTimeIndex.java b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/timeindex/DeviceTimeIndex.java
index 86d7dc6..1d103a7 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/timeindex/DeviceTimeIndex.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/timeindex/DeviceTimeIndex.java
@@ -88,13 +88,17 @@ public class DeviceTimeIndex implements ITimeIndex {
ReadWriteIOUtils.write(endTimes[i], outputStream);
}
+ Map<String, Integer> stringMemoryReducedMap = new ConcurrentHashMap<>();
for (Entry<String, Integer> stringIntegerEntry : deviceToIndex.entrySet()) {
String deviceName = stringIntegerEntry.getKey();
- deviceName = cachedDevicePool.computeIfAbsent(deviceName, k -> k);
int index = stringIntegerEntry.getValue();
+ // To reduce the String number in memory,
+ // use the deviceId from cached pool
+ stringMemoryReducedMap.put(cachedDevicePool.computeIfAbsent(deviceName, k -> k), index);
ReadWriteIOUtils.write(deviceName, outputStream);
ReadWriteIOUtils.write(index, outputStream);
}
+ deviceToIndex = stringMemoryReducedMap;
}
@Override
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/timeindex/FileTimeIndex.java b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/timeindex/FileTimeIndex.java
index 7c3f6ec..0b06750 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/timeindex/FileTimeIndex.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/timeindex/FileTimeIndex.java
@@ -66,12 +66,16 @@ public class FileTimeIndex implements ITimeIndex {
@Override
public void serialize(OutputStream outputStream) throws IOException {
ReadWriteIOUtils.write(devices.size(), outputStream);
+ Set<String> stringMemoryReducedSet = new ConcurrentSet<>();
for (String device : devices) {
- device = cachedDevicePool.computeIfAbsent(device, k -> k);
+ // To reduce the String number in memory,
+ // use the deviceId from cached pool
+ stringMemoryReducedSet.add(cachedDevicePool.computeIfAbsent(device, k -> k));
ReadWriteIOUtils.write(device, outputStream);
}
ReadWriteIOUtils.write(startTime, outputStream);
ReadWriteIOUtils.write(endTime, outputStream);
+ devices = stringMemoryReducedSet;
}
@Override