Skip to content

Commit

Permalink
minor change to region search in sorted_array
Browse files Browse the repository at this point in the history
  • Loading branch information
samuel.oranyeli committed Sep 18, 2024
1 parent af7ef10 commit dc4357c
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions janitor/functions/_numba.py
Original file line number Diff line number Diff line change
Expand Up @@ -1219,10 +1219,7 @@ def _numba_non_equi_join_not_monotonic_keep_all(
_num = np.uint64(num)
region = right_regions[_num, 0]
arr = maxxes[:maxxes_counter]
posn = _numba_less_than(arr=arr, value=region)
# it is larger than the max in the maxxes array
# shove it into the last column
if posn == -1:
if region > maxxes[-1]:
posn = maxxes_counter - 1
posn_ = np.uint64(posn)
len_arr = lengths[posn_]
Expand All @@ -1232,6 +1229,7 @@ def _numba_non_equi_join_not_monotonic_keep_all(
maxxes[posn_] = region
lengths[posn_] += 1
else:
posn = _numba_less_than(arr=arr, value=region)
sorted_array, positions_array, lengths, maxxes = (
_numba_sorted_array(
sorted_array=sorted_array,
Expand Down Expand Up @@ -1341,8 +1339,7 @@ def _numba_non_equi_join_not_monotonic_keep_all(
_num = np.uint64(num)
region = right_regions[_num, 0]
arr = maxxes[:maxxes_counter]
posn = _numba_less_than(arr=arr, value=region)
if posn == -1:
if region > maxxes[-1]:
posn = maxxes_counter - 1
posn_ = np.uint64(posn)
len_arr = lengths[posn_]
Expand All @@ -1352,6 +1349,7 @@ def _numba_non_equi_join_not_monotonic_keep_all(
maxxes[posn_] = region
lengths[posn_] += 1
else:
posn = _numba_less_than(arr=arr, value=region)
sorted_array, positions_array, lengths, maxxes = (
_numba_sorted_array(
sorted_array=sorted_array,
Expand All @@ -1365,7 +1363,7 @@ def _numba_non_equi_join_not_monotonic_keep_all(
)
r_count += 1
posn_ = np.uint64(posn)
# have we reached the max size of this column?
# have we exceeded the size of this column?
# do we need to trim and move data to other columns?
check = (lengths[posn_] == (load_factor * 2)) & (
r_count < right_index.size
Expand Down Expand Up @@ -1487,8 +1485,7 @@ def _numba_non_equi_join_not_monotonic_keep_first(
_num = np.uint64(num)
region = right_regions[_num, 0]
arr = maxxes[:maxxes_counter]
posn = _numba_less_than(arr=arr, value=region)
if posn == -1:
if region > maxxes[-1]:
posn = maxxes_counter - 1
posn_ = np.uint64(posn)
len_arr = lengths[posn_]
Expand All @@ -1498,6 +1495,7 @@ def _numba_non_equi_join_not_monotonic_keep_first(
maxxes[posn_] = region
lengths[posn_] += 1
else:
posn = _numba_less_than(arr=arr, value=region)
sorted_array, positions_array, lengths, maxxes = (
_numba_sorted_array(
sorted_array=sorted_array,
Expand Down Expand Up @@ -1654,8 +1652,7 @@ def _numba_non_equi_join_not_monotonic_keep_last(
_num = np.uint64(num)
region = right_regions[_num, 0]
arr = maxxes[:maxxes_counter]
posn = _numba_less_than(arr=arr, value=region)
if posn == -1:
if region > maxxes[-1]:
posn = maxxes_counter - 1
posn_ = np.uint64(posn)
len_arr = lengths[posn_]
Expand All @@ -1665,6 +1662,7 @@ def _numba_non_equi_join_not_monotonic_keep_last(
maxxes[posn_] = region
lengths[posn_] += 1
else:
posn = _numba_less_than(arr=arr, value=region)
sorted_array, positions_array, lengths, maxxes = (
_numba_sorted_array(
sorted_array=sorted_array,
Expand Down

0 comments on commit dc4357c

Please sign in to comment.