@@ -29,13 +29,14 @@ def inner_join(const int64_t[:] left, const int64_t[:] right,
29
29
left_sorter, left_count = groupsort_indexer(left, max_groups)
30
30
right_sorter, right_count = groupsort_indexer(right, max_groups)
31
31
32
- # First pass, determine size of result set, do not use the NA group
33
- for i in range (1 , max_groups + 1 ):
34
- lc = left_count[i]
35
- rc = right_count[i]
32
+ with nogil:
33
+ # First pass, determine size of result set, do not use the NA group
34
+ for i in range (1 , max_groups + 1 ):
35
+ lc = left_count[i]
36
+ rc = right_count[i]
36
37
37
- if rc > 0 and lc > 0 :
38
- count += lc * rc
38
+ if rc > 0 and lc > 0 :
39
+ count += lc * rc
39
40
40
41
# exclude the NA group
41
42
left_pos = left_count[0 ]
@@ -44,19 +45,20 @@ def inner_join(const int64_t[:] left, const int64_t[:] right,
44
45
left_indexer = np.empty(count, dtype = np.int64)
45
46
right_indexer = np.empty(count, dtype = np.int64)
46
47
47
- for i in range (1 , max_groups + 1 ):
48
- lc = left_count[i]
49
- rc = right_count[i]
50
-
51
- if rc > 0 and lc > 0 :
52
- for j in range (lc):
53
- offset = position + j * rc
54
- for k in range (rc):
55
- left_indexer[offset + k] = left_pos + j
56
- right_indexer[offset + k] = right_pos + k
57
- position += lc * rc
58
- left_pos += lc
59
- right_pos += rc
48
+ with nogil:
49
+ for i in range (1 , max_groups + 1 ):
50
+ lc = left_count[i]
51
+ rc = right_count[i]
52
+
53
+ if rc > 0 and lc > 0 :
54
+ for j in range (lc):
55
+ offset = position + j * rc
56
+ for k in range (rc):
57
+ left_indexer[offset + k] = left_pos + j
58
+ right_indexer[offset + k] = right_pos + k
59
+ position += lc * rc
60
+ left_pos += lc
61
+ right_pos += rc
60
62
61
63
return (_get_result_indexer(left_sorter, left_indexer),
62
64
_get_result_indexer(right_sorter, right_indexer))
@@ -79,12 +81,13 @@ def left_outer_join(const int64_t[:] left, const int64_t[:] right,
79
81
left_sorter, left_count = groupsort_indexer(left, max_groups)
80
82
right_sorter, right_count = groupsort_indexer(right, max_groups)
81
83
82
- # First pass, determine size of result set, do not use the NA group
83
- for i in range (1 , max_groups + 1 ):
84
- if right_count[i] > 0 :
85
- count += left_count[i] * right_count[i]
86
- else :
87
- count += left_count[i]
84
+ with nogil:
85
+ # First pass, determine size of result set, do not use the NA group
86
+ for i in range (1 , max_groups + 1 ):
87
+ if right_count[i] > 0 :
88
+ count += left_count[i] * right_count[i]
89
+ else :
90
+ count += left_count[i]
88
91
89
92
# exclude the NA group
90
93
left_pos = left_count[0 ]
@@ -93,24 +96,25 @@ def left_outer_join(const int64_t[:] left, const int64_t[:] right,
93
96
left_indexer = np.empty(count, dtype = np.int64)
94
97
right_indexer = np.empty(count, dtype = np.int64)
95
98
96
- for i in range (1 , max_groups + 1 ):
97
- lc = left_count[i]
98
- rc = right_count[i]
99
+ with nogil:
100
+ for i in range (1 , max_groups + 1 ):
101
+ lc = left_count[i]
102
+ rc = right_count[i]
99
103
100
- if rc == 0 :
101
- for j in range (lc):
102
- left_indexer[position + j] = left_pos + j
103
- right_indexer[position + j] = - 1
104
- position += lc
105
- else :
106
- for j in range (lc):
107
- offset = position + j * rc
108
- for k in range (rc):
109
- left_indexer[offset + k] = left_pos + j
110
- right_indexer[offset + k] = right_pos + k
111
- position += lc * rc
112
- left_pos += lc
113
- right_pos += rc
104
+ if rc == 0 :
105
+ for j in range (lc):
106
+ left_indexer[position + j] = left_pos + j
107
+ right_indexer[position + j] = - 1
108
+ position += lc
109
+ else :
110
+ for j in range (lc):
111
+ offset = position + j * rc
112
+ for k in range (rc):
113
+ left_indexer[offset + k] = left_pos + j
114
+ right_indexer[offset + k] = right_pos + k
115
+ position += lc * rc
116
+ left_pos += lc
117
+ right_pos += rc
114
118
115
119
left_indexer = _get_result_indexer(left_sorter, left_indexer)
116
120
right_indexer = _get_result_indexer(right_sorter, right_indexer)
@@ -149,15 +153,16 @@ def full_outer_join(const int64_t[:] left, const int64_t[:] right,
149
153
left_sorter, left_count = groupsort_indexer(left, max_groups)
150
154
right_sorter, right_count = groupsort_indexer(right, max_groups)
151
155
152
- # First pass, determine size of result set, do not use the NA group
153
- for i in range (1 , max_groups + 1 ):
154
- lc = left_count[i]
155
- rc = right_count[i]
156
+ with nogil:
157
+ # First pass, determine size of result set, do not use the NA group
158
+ for i in range (1 , max_groups + 1 ):
159
+ lc = left_count[i]
160
+ rc = right_count[i]
156
161
157
- if rc > 0 and lc > 0 :
158
- count += lc * rc
159
- else :
160
- count += lc + rc
162
+ if rc > 0 and lc > 0 :
163
+ count += lc * rc
164
+ else :
165
+ count += lc + rc
161
166
162
167
# exclude the NA group
163
168
left_pos = left_count[0 ]
@@ -166,29 +171,30 @@ def full_outer_join(const int64_t[:] left, const int64_t[:] right,
166
171
left_indexer = np.empty(count, dtype = np.int64)
167
172
right_indexer = np.empty(count, dtype = np.int64)
168
173
169
- for i in range (1 , max_groups + 1 ):
170
- lc = left_count[i]
171
- rc = right_count[i]
172
-
173
- if rc == 0 :
174
- for j in range (lc):
175
- left_indexer[position + j] = left_pos + j
176
- right_indexer[position + j] = - 1
177
- position += lc
178
- elif lc == 0 :
179
- for j in range (rc):
180
- left_indexer[position + j] = - 1
181
- right_indexer[position + j] = right_pos + j
182
- position += rc
183
- else :
184
- for j in range (lc):
185
- offset = position + j * rc
186
- for k in range (rc):
187
- left_indexer[offset + k] = left_pos + j
188
- right_indexer[offset + k] = right_pos + k
189
- position += lc * rc
190
- left_pos += lc
191
- right_pos += rc
174
+ with nogil:
175
+ for i in range (1 , max_groups + 1 ):
176
+ lc = left_count[i]
177
+ rc = right_count[i]
178
+
179
+ if rc == 0 :
180
+ for j in range (lc):
181
+ left_indexer[position + j] = left_pos + j
182
+ right_indexer[position + j] = - 1
183
+ position += lc
184
+ elif lc == 0 :
185
+ for j in range (rc):
186
+ left_indexer[position + j] = - 1
187
+ right_indexer[position + j] = right_pos + j
188
+ position += rc
189
+ else :
190
+ for j in range (lc):
191
+ offset = position + j * rc
192
+ for k in range (rc):
193
+ left_indexer[offset + k] = left_pos + j
194
+ right_indexer[offset + k] = right_pos + k
195
+ position += lc * rc
196
+ left_pos += lc
197
+ right_pos += rc
192
198
193
199
return (_get_result_indexer(left_sorter, left_indexer),
194
200
_get_result_indexer(right_sorter, right_indexer))
0 commit comments