-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from DuanxinCao/feature-tairvector
feat: add new data structure TairVector
- Loading branch information
Showing
7 changed files
with
902 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env python | ||
from conf_examples import get_tair | ||
from tair import ResponseError | ||
|
||
# create an index | ||
# @param index_name the name of index | ||
# @param dims the dimension of vector | ||
# @return success: True, fail: False. | ||
def create_index(index_name: str, dims: str): | ||
try: | ||
tair = get_tair() | ||
index_params = { | ||
"M": 32, | ||
"ef_construct": 200, | ||
} | ||
#index_params the params of index | ||
return tair.tvs_create_index(index_name, dims,**index_params) | ||
except ResponseError as e: | ||
print(e) | ||
return None | ||
|
||
# delete an index | ||
# @param index_name the name of index | ||
# @return success: True, fail: False. | ||
def delete_index(index_name: str): | ||
try: | ||
tair = get_tair() | ||
return tair.tvs_del_index(index_name) | ||
except ResponseError as e: | ||
print(e) | ||
return False | ||
|
||
|
||
if __name__ == "__main__": | ||
create_index("test",4) | ||
delete_index("test") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.