Skip to content

Commit

Permalink
use vectorlite for embedding search
Browse files Browse the repository at this point in the history
Signed-off-by: Praneeth Bedapudi <[email protected]>
  • Loading branch information
bedapudi6788 committed Oct 21, 2024
1 parent 9b60ef3 commit 4dbd14d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions liteindex/kv_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,9 @@ def update(self, items, reverse_order=False):
key_hashes,
).fetchone()[0]

if total_old_size is None:
total_old_size = 0

conn.execute(
"UPDATE kv_index_num_metadata SET num = num + ? WHERE key = ?",
(
Expand Down Expand Up @@ -554,7 +557,8 @@ def __run_eviction(self, conn):
if self.eviction.max_size_in_mb:
s = time.time()
current_size_in_mb = conn.execute(
"SELECT num FROM kv_index_num_metadata WHERE key = current_size_in_mb"
"SELECT num FROM kv_index_num_metadata WHERE key = ?",
("current_size_in_mb",),
).fetchone()[0]

if current_size_in_mb >= self.eviction.max_size_in_mb:
Expand All @@ -570,6 +574,8 @@ def __run_eviction(self, conn):

if number_of_rows_to_evict == 0:
return

print('----', number_of_rows_to_evict, self.eviction.policy, self.eviction.max_size_in_mb, self.eviction.max_number_of_items)

if not self.eviction.max_size_in_mb:
if self.eviction.policy == EvictionCfg.EvictLRU:
Expand Down Expand Up @@ -629,10 +635,7 @@ def popitem(self, reverse=True):
def clear(self):
with self.__connection as conn:
conn.execute("DELETE FROM kv_index")
conn.execute(
"UPDATE kv_index_num_metadata SET num = 0 WHERE key = ?",
("current_size_in_mb",),
)
conn.execute("UPDATE kv_index_num_metadata SET num = 0 WHERE key = ?", ("current_size_in_mb",))

def create_trigger(
self,
Expand Down

0 comments on commit 4dbd14d

Please sign in to comment.