Skip to content

Commit

Permalink
Merge pull request milvus-io#49 from XuanYang-cn/branch-0.3.1
Browse files Browse the repository at this point in the history
[ISSUE - milvus-io#47] Branch 0.3.1
  • Loading branch information
JinHai-CN authored Jul 5, 2019
2 parents 98dd934 + 721aae0 commit a3c6ec7
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions examples/AdvancedExample.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,6 @@ def generate_vectors():
return records


# Decorator to calculate function running time
def time_it(func):
def inner(*args, **kwargs):
start = time.time()
ret = func(*args, **kwargs)
end = time.time()
return ret, end - start
return inner


class ConnectionHandler(object):
"""Handler connection with the server
Expand Down Expand Up @@ -160,7 +150,6 @@ def add_vectors(records):
print(status.message)


@time_it
@api.connect
def search_vectors(q_records):

Expand All @@ -174,7 +163,10 @@ def search_vectors(q_records):
# Search vector
status, results = api.client.search_vectors(**param)
if status.OK():
print('Searching {} nearest vectors from table `{}` ... \n'.format(TOPK, TABLE_NAME))

print('Get a vector from table `{}`. '
'Searching its {} nearest vectors from table `{}` ... \n'.
format(TABLE_NAME, TOPK, TABLE_NAME))
print(HEADER)
print('-' * 28 + '+' + '-'*27)
for result in results:
Expand Down Expand Up @@ -217,10 +209,7 @@ def delete_table():
q_record = [records[0]]

# Search vectors
_, b = search_vectors(q_record)
search_vectors(q_record)

# Delete table
delete_table()

# Print time of searching vectors
print('Time of search 1 vector of top{} in table `{}`: {}s'.format(TOPK, TABLE_NAME, b))

0 comments on commit a3c6ec7

Please sign in to comment.