Skip to content

Commit

Permalink
optional auto_vacuum param
Browse files Browse the repository at this point in the history
Signed-off-by: Praneeth Bedapudi <[email protected]>
  • Loading branch information
bedapudi6788 committed Nov 7, 2024
1 parent 6ddb08f commit 83f5ccb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 15 additions & 3 deletions liteindex/defined_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,14 @@ class Key:
pass

def __init__(
self, name, schema=None, db_path=None, ram_cache_mb=64, compression_level=None
self,
name,
schema=None,
db_path=None,
ram_cache_mb=64,
compression_level=None,
auto_vacuum=True,
auto_vacuum_increment=1000,
):
if sqlite3.sqlite_version < "3.35.0":
raise ValueError(
Expand All @@ -107,6 +114,8 @@ def __init__(
self.db_path = ":memory:" if db_path is None else db_path
self.ram_cache_mb = ram_cache_mb
self.compression_level = compression_level
self.auto_vacuum = auto_vacuum
self.auto_vacuum_increment = auto_vacuum_increment

if self.name.startswith("__"):
raise ValueError("Index name cannot start with '__'")
Expand Down Expand Up @@ -150,8 +159,11 @@ def __connection(self):
self.__local_storage.db_conn.execute("PRAGMA journal_mode=WAL")
self.__local_storage.db_conn.execute("PRAGMA synchronous=NORMAL")

self.__local_storage.db_conn.execute("PRAGMA auto_vacuum=FULL")
self.__local_storage.db_conn.execute("PRAGMA auto_vacuum_increment=1000")
if self.auto_vacuum:
self.__local_storage.db_conn.execute("PRAGMA auto_vacuum=FULL")
self.__local_storage.db_conn.execute(
f"PRAGMA auto_vacuum_increment={self.auto_vacuum_increment}"
)

self.__local_storage.db_conn.execute(
f"PRAGMA cache_size=-{self.ram_cache_mb * 1024}"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
EMAIL = "[email protected]"
AUTHOR = "BEDAPUDI PRANEETH"
REQUIRES_PYTHON = ">=3.6.0"
VERSION = "0.0.3.2.dev5"
VERSION = "0.0.3.2.dev6"

# What packages are required for this module to be executed?
REQUIRED = []
Expand Down

0 comments on commit 83f5ccb

Please sign in to comment.