From 9a64f30f366c6797278d558aaf7e13269a30ec60 Mon Sep 17 00:00:00 2001 From: George Panchuk Date: Wed, 13 Nov 2024 15:40:46 +0100 Subject: [PATCH] refactoring: remove outdated stuff --- qdrant_client/local/persistence.py | 55 ++---------------------------- 1 file changed, 3 insertions(+), 52 deletions(-) diff --git a/qdrant_client/local/persistence.py b/qdrant_client/local/persistence.py index c43f7d78..975a60d6 100644 --- a/qdrant_client/local/persistence.py +++ b/qdrant_client/local/persistence.py @@ -1,6 +1,4 @@ import base64 -import dbm -import logging import pickle import sqlite3 from pathlib import Path @@ -8,53 +6,8 @@ from qdrant_client.http import models -STORAGE_FILE_NAME_OLD = "storage.dbm" -STORAGE_FILE_NAME = "storage.sqlite" - -def try_migrate_to_sqlite(location: str) -> None: - dbm_path = Path(location) / STORAGE_FILE_NAME_OLD - sql_path = Path(location) / STORAGE_FILE_NAME - - if sql_path.exists(): - return - - if not dbm_path.exists(): - return - - try: - dbm_storage = dbm.open(str(dbm_path), "c") - - con = sqlite3.connect(str(sql_path)) - cur = con.cursor() - - # Create table - cur.execute("CREATE TABLE IF NOT EXISTS points (id TEXT PRIMARY KEY, point BLOB)") - - for key in dbm_storage.keys(): - value = dbm_storage[key] - if isinstance(key, str): - key = key.encode("utf-8") - key = pickle.loads(key) - sqlite_key = CollectionPersistence.encode_key(key) - # Insert a row of data - cur.execute( - "INSERT INTO points VALUES (?, ?)", - ( - sqlite_key, - sqlite3.Binary(value), - ), - ) - con.commit() - con.close() - dbm_storage.close() - dbm_path.unlink() - except Exception as e: - logging.error("Failed to migrate dbm to sqlite:", e) - logging.error( - "Please try to use previous version of qdrant-client or re-create collection" - ) - raise e +STORAGE_FILE_NAME = "storage.sqlite" class CollectionPersistence: @@ -70,9 +23,6 @@ def __init__(self, location: str, force_disable_check_same_thread: bool = False) Args: location: path to the collection directory. """ - - try_migrate_to_sqlite(location) - self.location = Path(location) / STORAGE_FILE_NAME self.location.parent.mkdir(exist_ok=True, parents=True) @@ -92,7 +42,8 @@ def __init__(self, location: str, force_disable_check_same_thread: bool = False) self.__class__.CHECK_SAME_THREAD = False self.storage = sqlite3.connect( - str(self.location), check_same_thread=self.CHECK_SAME_THREAD # type: ignore + str(self.location), + check_same_thread=self.CHECK_SAME_THREAD, # type: ignore ) self._ensure_table()