You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ma...@apache.org on 2024/02/22 07:30:47 UTC
(iotdb) 05/09: not allocating byte array when writing string to wal
This is an automated email from the ASF dual-hosted git repository.
marklau99 pushed a commit to branch compressed-wal
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 7d4e16c12a7679a3b0439752e6bebd46b4e36284
Author: Liu Xuxin <li...@outlook.com>
AuthorDate: Tue Jan 23 10:28:40 2024 +0800
not allocating byte array when writing string to wal
---
.../db/storageengine/dataregion/wal/utils/WALWriteUtils.java | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/utils/WALWriteUtils.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/utils/WALWriteUtils.java
index 18c9cf79e6b..7b6b7bae1b1 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/utils/WALWriteUtils.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/utils/WALWriteUtils.java
@@ -125,10 +125,12 @@ public class WALWriteUtils {
return write(NO_BYTE_TO_READ, buffer);
}
int len = 0;
- byte[] bytes = s.getBytes();
- len += write(bytes.length, buffer);
- buffer.put(bytes);
- len += bytes.length;
+ len += write(s.length(), buffer);
+ for (int i = 0; i < s.length(); i++) {
+ char c = s.charAt(i);
+ buffer.put((byte) c); // ascii only
+ }
+ len += s.length();
return len;
}