@@ -123,12 +123,10 @@ def _get_conn(self, config: RepoConfig):
123123 if not self ._conn :
124124 db_path = self ._get_db_path (config )
125125 self ._conn = _initialize_conn (db_path )
126- online_store = config .online_store
127- if not isinstance (online_store , SqliteOnlineStoreConfig ):
128- raise ValueError ("online_store must be SqliteOnlineStoreConfig" )
129- if sys .version_info [0 :2 ] == (3 , 10 ) and online_store .vector_enabled :
126+ if sys .version_info [0 :2 ] == (3 , 10 ) and config .online_store .vector_enabled :
130127 import sqlite_vec # noqa: F401
131- db = sqlite3 .Connection (':memory:' )
128+
129+ db = sqlite3 .Connection (":memory:" )
132130 db .enable_load_extension (True )
133131 sqlite_vec .load (db )
134132 return db
@@ -149,9 +147,6 @@ def online_write_batch(
149147 ],
150148 progress : Optional [Callable [[int ], Any ]],
151149 ) -> None :
152- online_store = config .online_store
153- if not isinstance (online_store , SqliteOnlineStoreConfig ):
154- raise ValueError ("online_store must be SqliteOnlineStoreConfig" )
155150 conn = self ._get_conn (config )
156151
157152 project = config .project
@@ -168,13 +163,9 @@ def online_write_batch(
168163
169164 table_name = _table_id (project , table )
170165 for feature_name , val in values .items ():
171- online_store = config .online_store
172- if not isinstance (online_store , SqliteOnlineStoreConfig ):
173- raise ValueError ("online_store must be SqliteOnlineStoreConfig" )
174- if online_store .vector_enabled and online_store .vector_len :
166+ if config .online_store .vector_enabled :
175167 vector_bin = serialize_f32 (
176- val .float_list_val .val ,
177- online_store .vector_len ,
168+ val .float_list_val .val , config .online_store .vector_len
178169 ) # type: ignore
179170 conn .execute (
180171 f"""
@@ -371,28 +362,22 @@ def retrieve_online_documents(
371362 Returns:
372363 List of tuples containing the event timestamp, the document feature, the vector value, and the distance
373364 """
374- online_store = config .online_store
375- if not isinstance (online_store , SqliteOnlineStoreConfig ):
376- raise ValueError ("online_store must be SqliteOnlineStoreConfig" )
377- if not online_store .vector_enabled :
365+ project = config .project
366+
367+ if not config .online_store .vector_enabled :
378368 raise ValueError ("sqlite-vss is not enabled in the online store config" )
379369
380370 conn = self ._get_conn (config )
381371 cur = conn .cursor ()
382372
373+ query_embedding_bin = serialize_f32 (embedding , config .online_store .vector_len )
374+ table_name = _table_id (project , table )
383375 # Convert the embedding to a binary format instead of using SerializeToString()
384- online_store = config .online_store
385- if not isinstance (online_store , SqliteOnlineStoreConfig ):
386- raise ValueError ("online_store must be SqliteOnlineStoreConfig" )
387- if not online_store .vector_len :
388- raise ValueError ("vector_len is not configured in the online store config" )
389- query_embedding_bin = serialize_f32 (embedding , online_store .vector_len ) # type: ignore
390- table_name = _table_id (config .project , table )
391376
392377 cur .execute (
393378 f"""
394379 CREATE VIRTUAL TABLE vec_example using vec0(
395- vector_value float[{ online_store .vector_len } ]
380+ vector_value float[{ config . online_store .vector_len } ]
396381 );
397382 """
398383 )
0 commit comments