88
99
1010class Index :
11+ """
12+ Open a Vector index
13+
14+ Parameters
15+ ----------
16+ uri: str
17+ URI of the index
18+ config: Optional[Mapping[str, Any]]
19+ config dictionary, defaults to None
20+ """
1121 def __init__ (
1222 self ,
13- uri ,
23+ uri : str ,
1424 config : Optional [Mapping [str , Any ]] = None ,
1525 ):
1626 # If the user passes a tiledb python Config object convert to a dictionary
@@ -26,14 +36,14 @@ def __init__(
2636 self .index_version = self .group .meta .get ("index_version" , "" )
2737
2838
29- def query (self , targets : np .ndarray , k , ** kwargs ):
39+ def query (self , queries : np .ndarray , k , ** kwargs ):
3040 # TODO merge results based on scores and use higher k to improve retrieval
3141 updated_ids = set (self .read_updated_ids ())
32- internal_results = self .query_internal (targets , k , ** kwargs )
42+ internal_results = self .query_internal (queries , k , ** kwargs )
3343 if self .update_arrays_uri is None :
3444 return internal_results
35- addition_results = self .query_additions (targets , k )
36- merged_results = np .zeros ((targets .shape [0 ], k ), dtype = np .uint64 )
45+ addition_results = self .query_additions (queries , k )
46+ merged_results = np .zeros ((queries .shape [0 ], k ), dtype = np .uint64 )
3747 query_id = 0
3848 for query in internal_results :
3949 res_id = 0
@@ -48,17 +58,17 @@ def query(self, targets: np.ndarray, k, **kwargs):
4858 query_id += 1
4959 return merged_results
5060
51- def query_internal (self , targets : np .ndarray , k , ** kwargs ):
61+ def query_internal (self , queries : np .ndarray , k , ** kwargs ):
5262 raise NotImplementedError
5363
54- def query_additions (self , targets : np .ndarray , k ):
55- assert targets .dtype == np .float32
64+ def query_additions (self , queries : np .ndarray , k ):
65+ assert queries .dtype == np .float32
5666
5767 additions_vectors , additions_external_ids = self .read_additions ()
58- targets_m = array_to_matrix (np .transpose (targets ))
68+ queries_m = array_to_matrix (np .transpose (queries ))
5969 r = query_vq_heap_pyarray (
6070 array_to_matrix (np .transpose (additions_vectors ).astype (self .dtype )),
61- targets_m ,
71+ queries_m ,
6272 StdVector_u64 (additions_external_ids ),
6373 k ,
6474 8 )
0 commit comments