@@ -839,11 +839,16 @@ def asof_join_nearest_on_X_by_Y(numeric_t[:] left_values,
839839 by_t[:] left_by_values ,
840840 by_t[:] right_by_values ,
841841 bint allow_exact_matches = True ,
842- tolerance = None ):
842+ tolerance = None ,
843+ bint use_hashtable = True ):
843844
844845 cdef:
845846 ndarray[intp_t] bli, bri, fli, fri
846847
848+ ndarray[intp_t] left_indexer, right_indexer
849+ Py_ssize_t left_size, i
850+ numeric_t bdiff, fdiff
851+
847852 # search both forward and backward
848853 bli, bri = asof_join_backward_on_X_by_Y(
849854 left_values,
@@ -852,6 +857,7 @@ def asof_join_nearest_on_X_by_Y(numeric_t[:] left_values,
852857 right_by_values,
853858 allow_exact_matches,
854859 tolerance,
860+ use_hashtable
855861 )
856862 fli, fri = asof_join_forward_on_X_by_Y(
857863 left_values,
@@ -860,26 +866,11 @@ def asof_join_nearest_on_X_by_Y(numeric_t[:] left_values,
860866 right_by_values,
861867 allow_exact_matches,
862868 tolerance,
869+ use_hashtable
863870 )
864871
865- return _choose_smaller_timestamp(left_values, right_values, bli, bri, fli, fri)
866-
867-
868- cdef _choose_smaller_timestamp(
869- numeric_t[:] left_values,
870- numeric_t[:] right_values,
871- ndarray[intp_t] bli,
872- ndarray[intp_t] bri,
873- ndarray[intp_t] fli,
874- ndarray[intp_t] fri,
875- ):
876- cdef:
877- ndarray[intp_t] left_indexer, right_indexer
878- Py_ssize_t left_size, i
879- numeric_t bdiff, fdiff
880-
872+ # choose the smaller timestamp
881873 left_size = len (left_values)
882-
883874 left_indexer = np.empty(left_size, dtype = np.intp)
884875 right_indexer = np.empty(left_size, dtype = np.intp)
885876
@@ -894,55 +885,3 @@ cdef _choose_smaller_timestamp(
894885 left_indexer[i] = bli[i]
895886
896887 return left_indexer, right_indexer
897-
898-
899- # ----------------------------------------------------------------------
900- # asof_join
901- # ----------------------------------------------------------------------
902-
903- def asof_join_backward (numeric_t[:] left_values ,
904- numeric_t[:] right_values ,
905- bint allow_exact_matches = True ,
906- tolerance = None ):
907-
908- return asof_join_backward_on_X_by_Y(
909- left_values,
910- right_values,
911- None ,
912- None ,
913- allow_exact_matches = allow_exact_matches,
914- tolerance = tolerance,
915- use_hashtable = False ,
916- )
917-
918-
919- def asof_join_forward (numeric_t[:] left_values ,
920- numeric_t[:] right_values ,
921- bint allow_exact_matches = True ,
922- tolerance = None ):
923- return asof_join_forward_on_X_by_Y(
924- left_values,
925- right_values,
926- None ,
927- None ,
928- allow_exact_matches = allow_exact_matches,
929- tolerance = tolerance,
930- use_hashtable = False ,
931- )
932-
933-
934- def asof_join_nearest (numeric_t[:] left_values ,
935- numeric_t[:] right_values ,
936- bint allow_exact_matches = True ,
937- tolerance = None ):
938-
939- cdef:
940- ndarray[intp_t] bli, bri, fli, fri
941-
942- # search both forward and backward
943- bli, bri = asof_join_backward(left_values, right_values,
944- allow_exact_matches, tolerance)
945- fli, fri = asof_join_forward(left_values, right_values,
946- allow_exact_matches, tolerance)
947-
948- return _choose_smaller_timestamp(left_values, right_values, bli, bri, fli, fri)
0 commit comments