From f60c1675cd33ed8f69dc3e9b07d39c4633dabcbb Mon Sep 17 00:00:00 2001 From: lexluo09 <39718951+lexluo09@users.noreply.github.com> Date: Tue, 19 Dec 2023 16:12:11 +0800 Subject: [PATCH] [improvement](chat) udpate EmbeddingConfig embeddingStorePersistentPath and if the persistentPath directory does not exist, create the directory. (#550) --- .../com/tencent/supersonic/common/config/EmbeddingConfig.java | 2 +- .../common/util/embedding/InMemoryS2EmbeddingStore.java | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/com/tencent/supersonic/common/config/EmbeddingConfig.java b/common/src/main/java/com/tencent/supersonic/common/config/EmbeddingConfig.java index 1a032b787..a41afe690 100644 --- a/common/src/main/java/com/tencent/supersonic/common/config/EmbeddingConfig.java +++ b/common/src/main/java/com/tencent/supersonic/common/config/EmbeddingConfig.java @@ -32,6 +32,6 @@ public class EmbeddingConfig { @Value("${embedding.metric.analyzeQuery.nResult:5}") private int metricAnalyzeQueryResultNum; - @Value("${embeddingStore.persistent.path:/tmp}") + @Value("${inMemoryEmbeddingStore.persistent.path:/tmp}") private String embeddingStorePersistentPath; } diff --git a/common/src/main/java/com/tencent/supersonic/common/util/embedding/InMemoryS2EmbeddingStore.java b/common/src/main/java/com/tencent/supersonic/common/util/embedding/InMemoryS2EmbeddingStore.java index c9b544630..cf92fa63e 100644 --- a/common/src/main/java/com/tencent/supersonic/common/util/embedding/InMemoryS2EmbeddingStore.java +++ b/common/src/main/java/com/tencent/supersonic/common/util/embedding/InMemoryS2EmbeddingStore.java @@ -71,6 +71,10 @@ public class InMemoryS2EmbeddingStore implements S2EmbeddingStore { for (Entry> entry : collectionNameToStore.entrySet()) { Path filePath = getPersistentPath(entry.getKey()); try { + Path directoryPath = filePath.getParent(); + if (!Files.exists(directoryPath)) { + Files.createDirectories(directoryPath); + } entry.getValue().serializeToFile(filePath); } catch (Exception e) { log.error("persistentToFile error, persistentFile:" + filePath, e);