Skip to content

Commit

Permalink
Fixed bug with distance override
Browse files Browse the repository at this point in the history
  • Loading branch information
randersenYB committed Jul 25, 2024
1 parent 1e05ec1 commit 5b91b95
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions aerospike/aerospikehdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,8 @@ def __init__(self, runtimeArgs: argparse.Namespace, actions: OperationActions):
self._query_latencies : List[float] = None
self._query_produce_resultfile : bool = not runtimeArgs.noresultfile
self._query_distance_no_adjustments = runtimeArgs.dontadustdistance

if runtimeArgs.distancecalc is None or not runtimeArgs.distancecalc:
self._query_distancecalc = self._ann_distance
else:
self._query_distancecalc = runtimeArgs.distancecalc

self._query_distancecalc = runtimeArgs.distancecalc

if runtimeArgs.searchparams is None or len(runtimeArgs.searchparams) == 0:
self._query_hnswparams = None
else:
Expand Down Expand Up @@ -349,19 +345,18 @@ async def get_dataset(self) -> None:
self._pks) = load_and_transform_dataset(self._datasetname, self._hdf_file)

distance = distance.lower()
if self._ann_distance is None:
self._ann_distance = distance
elif distance != self._ann_distance:
self.print_log(f"ANN distance types do not match! Found: {distance} Provided: {self._ann_distance}. Distance calculations could be wrong!", logging.WARN)

if self._idx_distance is None:
self._idx_distance = DistanceMaps.get(distance)
else:
idxdistance = DistanceMaps.get(distance)
if idxdistance.name != self._idx_distance.name:
self.print_log(f"ANN distance and Idx types do not match! Found: {distance} Idx: {self._idx_distance.name}. Using {self._idx_distance.name}!", logging.WARN)
self._ann_distance = DistanceMapsAnn.get(self._idx_distance.name)

self._ann_distance = distance

if self._query_distancecalc is None or not self._query_distancecalc:
self._query_distancecalc = self._ann_distance
if self._idx_distance is None:
self._idx_distance = DistanceMaps.get(self._query_distancecalc)
else:
idxdistance = DistanceMaps.get(self._query_distancecalc)
if idxdistance.name != self._idx_distance.name:
self.print_log(f"ANN distance and Idx types do not match! Found: {self._query_distancecalc} Idx: {self._idx_distance.name}. Using {self._idx_distance.name}!", logging.WARN)
self._query_distancecalc = DistanceMapsAnn.get(self._idx_distance.name)

if self._idx_distance is None or not self._idx_distance:
raise ValueError(f"Distance Map '{distance}' was not found.")

Expand Down

0 comments on commit 5b91b95

Please sign in to comment.