Skip to content

Commit

Permalink
Rename variables
Browse files Browse the repository at this point in the history
  • Loading branch information
wahajali committed Mar 19, 2024
1 parent fe6594f commit de2ab4f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
15 changes: 4 additions & 11 deletions vectordb_bench/backend/clients/pgvector/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,15 @@ def parse_metric_fun_str(self) -> str:


class HNSWConfig(PgVectorIndexConfig):
M: int
efConstruction: int
m: int
ef_construction: int
ef: int | None = None
index: IndexType = IndexType.HNSW

def index_param(self) -> dict:
return {
"metric_type": self.parse_metric(),
"index_type": self.index.value,
"params": {"M": self.M, "efConstruction": self.efConstruction},
}

def index_param(self) -> dict:
return {
"m" : self.M,
"efConstruction" : self.efConstruction,
"m" : self.m,
"ef_construction" : self.ef_construction,
"metric" : self.parse_metric()
}

Expand Down
4 changes: 2 additions & 2 deletions vectordb_bench/backend/clients/pgvector/pgvector.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ def _create_index(self):

index_param = self.case_config.index_param()
if self.case_config.index == IndexType.HNSW:
log.debug(f'Creating HNSW index. m={index_param["m"]}, ef_construction={index_param["ef_construction"]}')
log.debug(f'Creating HNSW index. m={index_param["m"]}, ef_construction={index_param["ef_construction"]}.')
self.cursor.execute(f'CREATE INDEX IF NOT EXISTS {self._index_name} ON public."{self.table_name}" USING hnsw (embedding {index_param["metric"]}) WITH (m={index_param["m"]}, ef_construction={index_param["ef_construction"]});')
elif self.case_config.index == IndexType.IVFFlat:
log.debug(f'Creating IVFFLAT index. list={index_param["lists"]}')
log.debug(f'Creating IVFFLAT index. list={index_param["lists"]}.')
self.cursor.execute(f'CREATE INDEX IF NOT EXISTS {self._index_name} ON public."{self.table_name}" USING ivfflat (embedding {index_param["metric"]}) WITH (lists={index_param["lists"]});')
else:
assert "Invalid index type {self.case_config.index}"
Expand Down

0 comments on commit de2ab4f

Please sign in to comment.