Switch SQLite ANN connections when load() is given a new path

This commit is contained in:
kartsan03
2026-10-10 11:11:24 +00:00
parent 084a1eca4d
commit fe1fbbc933
2 changed files with 4 additions and 0 deletions
+2
View File
@@ -35,6 +35,8 @@ class SQLite(ANN):
self.quantize = 8 if isinstance(self.quantize, bool) and self.quantize else int(self.quantize) if self.quantize else None
def load(self, path):
if self.path != path:
self.close()
self.path = path
def index(self, embeddings):
@@ -140,6 +140,8 @@ class TestSQLite(DenseTest):
# Load new copy and check that it has all the changes
model = ANNFactory.create(model.config)
model.load(index)
self.assertEqual(model.count(), 500)
model.load(new)
self.assertEqual(model.count(), 509)
self.assertEqual(len(model.search(np.random.rand(1, 240).astype(np.float32), 10)[0]), 10)