Code Duplication    Length = 22-23 lines in 2 locations

tests/milvus_groundtruth/milvus_ground_truth.py 2 locations

@@ 90-112 (lines=23) @@
87
    return dist
88
89
90
def get_ground_truth_l2(topk, idx, vct_nq):
91
    filenames = os.listdir(BASE_FOLDER_NAME)
92
    filenames.sort()
93
    no_dist = {}
94
    k = 0
95
    for filename in filenames:
96
        vec_list = load_vec_list(BASE_FOLDER_NAME + '/' + filename)
97
        for j in range(len(vec_list)):
98
            dist = calEuclideanDistance(vct_nq, vec_list[j])
99
            num_j = "%01d%03d%06d" % (8, k, j)
100
            if k==0 and j<topk :
101
                no_dist[num_j] = dist
102
            else:
103
                # sorted by values
104
                max_key = max(no_dist, key=no_dist.get)
105
                max_value = no_dist[max_key]
106
                if dist < max_value:
107
                    m = no_dist.pop(max_key)
108
                    no_dist[num_j] = dist
109
        k += 1
110
    no_dist = sorted(no_dist.items(), key=lambda x: x[1])
111
    print(no_dist)
112
    save_gt_file(no_dist, idx)
113
114
115
def get_ground_truth_ip(topk, idx, vct_nq):
@@ 115-136 (lines=22) @@
112
    save_gt_file(no_dist, idx)
113
114
115
def get_ground_truth_ip(topk, idx, vct_nq):
116
    filenames = os.listdir(BASE_FOLDER_NAME)  # get the whole file names
117
    filenames.sort()
118
    no_dist = {}
119
    k = 0
120
    for filename in filenames:
121
        vec_list = load_vec_list(BASE_FOLDER_NAME + '/' + filename)
122
        for j in range(len(vec_list)):
123
            dist = calInnerDistance(vct_nq, vec_list[j])
124
            num_j = "%03d%06d" % (k, j)
125
            if k==0 and j<topk :
126
                no_dist[num_j] = dist
127
            else:
128
                min_key = min(no_dist, key=no_dist.get)
129
                min_value = no_dist[min_key]
130
                if dist > min_value:
131
                    m = no_dist.pop(min_key)
132
                    no_dist[num_j] = dist
133
        k += 1
134
    no_dist = sorted(no_dist.items(), key=lambda x: x[1], reverse=True)
135
    print(no_dist)
136
    save_gt_file(no_dist, idx)
137
138
139
def get_ground_truth_tanimoto(topk, idx, vec_nq):