mirror of
https://github.com/neuml/txtai.git
synced 2026-10-11 21:39:55 +00:00
Switch SQLite ANN connections when load() is given a new path
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user