This is an automated email from the ASF dual-hosted git repository.
tanxinyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 52bc1889d53 Copy tsfile, its resources, and mods to the same directory
when using multiple data directories (#12420)
52bc1889d53 is described below
commit 52bc1889d53a2618bab5389fcb792b17dbee64aa
Author: Xiangpeng Hu <[email protected]>
AuthorDate: Thu Apr 25 21:19:18 2024 +0800
Copy tsfile, its resources, and mods to the same directory when using
multiple data directories (#12420)
---
.../db/storageengine/dataregion/snapshot/SnapshotLoader.java | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/snapshot/SnapshotLoader.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/snapshot/SnapshotLoader.java
index 795bd960d7c..c608f1be5ac 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/snapshot/SnapshotLoader.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/snapshot/SnapshotLoader.java
@@ -40,8 +40,10 @@ import java.nio.file.Path;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import java.util.Set;
public class SnapshotLoader {
@@ -288,8 +290,16 @@ public class SnapshotLoader {
private void createLinksFromSnapshotToSourceDir(
String targetSuffix, File[] files, FolderManager folderManager)
throws DiskSpaceInsufficientException, IOException {
+ Map<String, String> fileTarget = new HashMap<>();
for (File file : files) {
- String dataDir = folderManager.getNextFolder();
+ String fileKey = file.getName().split("\\.")[0];
+ String dataDir;
+ if (fileTarget.containsKey(fileKey)) {
+ dataDir = fileTarget.get(fileKey);
+ } else {
+ dataDir = folderManager.getNextFolder();
+ fileTarget.put(fileKey, dataDir);
+ }
File targetFile =
new File(dataDir + File.separator + targetSuffix + File.separator +
file.getName());
if (!targetFile.getParentFile().exists() &&
!targetFile.getParentFile().mkdirs()) {