Skip to content

Commit cb76713

Browse files
committed
introducing Int32HashTable
1 parent e2f062b commit cb76713

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

pandas/_libs/hashtable.pxd

+9-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ from numpy cimport intp_t, ndarray
33
from pandas._libs.khash cimport (
44
float64_t,
55
int64_t,
6+
int32_t,
7+
uint64_t,
68
kh_float64_t,
79
kh_int64_t,
10+
kh_int32_t,
811
kh_pymap_t,
912
kh_str_t,
1013
kh_uint64_t,
11-
uint64_t,
1214
)
1315

1416
# prototypes for sharing
@@ -28,6 +30,12 @@ cdef class Int64HashTable(HashTable):
2830
cpdef get_item(self, int64_t val)
2931
cpdef set_item(self, int64_t key, Py_ssize_t val)
3032

33+
cdef class Int32HashTable(HashTable):
34+
cdef kh_int32_t *table
35+
36+
cpdef get_item(self, int32_t val)
37+
cpdef set_item(self, int32_t key, Py_ssize_t val)
38+
3139
cdef class Float64HashTable(HashTable):
3240
cdef kh_float64_t *table
3341

pandas/_libs/hashtable.pyx

+6
Original file line numberDiff line numberDiff line change
@@ -16,36 +16,42 @@ from pandas._libs cimport util
1616
from pandas._libs.khash cimport (
1717
kh_destroy_float64,
1818
kh_destroy_int64,
19+
kh_destroy_int32,
1920
kh_destroy_pymap,
2021
kh_destroy_str,
2122
kh_destroy_uint64,
2223
kh_exist_float64,
2324
kh_exist_int64,
25+
kh_exist_int32,
2426
kh_exist_pymap,
2527
kh_exist_str,
2628
kh_exist_uint64,
2729
kh_float64_t,
2830
kh_get_float64,
2931
kh_get_int64,
32+
kh_get_int32,
3033
kh_get_pymap,
3134
kh_get_str,
3235
kh_get_strbox,
3336
kh_get_uint64,
3437
kh_init_float64,
3538
kh_init_int64,
39+
kh_init_int32,
3640
kh_init_pymap,
3741
kh_init_str,
3842
kh_init_strbox,
3943
kh_init_uint64,
4044
kh_int64_t,
4145
kh_put_float64,
4246
kh_put_int64,
47+
kh_put_int32,
4348
kh_put_pymap,
4449
kh_put_str,
4550
kh_put_strbox,
4651
kh_put_uint64,
4752
kh_resize_float64,
4853
kh_resize_int64,
54+
kh_resize_int32,
4955
kh_resize_pymap,
5056
kh_resize_str,
5157
kh_resize_uint64,

pandas/_libs/hashtable_class_helper.pxi.in

+6-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ from pandas._libs.missing cimport C_NA
2121

2222
dtypes = [('Float64', 'float64', 'float64_t'),
2323
('Int64', 'int64', 'int64_t'),
24+
('Int32', 'int32', 'int32_t'),
2425
('String', 'string', 'char *'),
2526
('UInt64', 'uint64', 'uint64_t')]
2627
}}
@@ -49,6 +50,7 @@ cdef inline void append_data_{{dtype}}({{name}}VectorData *data,
4950

5051
ctypedef fused vector_data:
5152
Int64VectorData
53+
Int32VectorData
5254
UInt64VectorData
5355
Float64VectorData
5456
StringVectorData
@@ -65,7 +67,8 @@ cdef inline bint needs_resize(vector_data *data) nogil:
6567
# name, dtype, c_type
6668
dtypes = [('Float64', 'float64', 'float64_t'),
6769
('UInt64', 'uint64', 'uint64_t'),
68-
('Int64', 'int64', 'int64_t')]
70+
('Int64', 'int64', 'int64_t'),
71+
('Int32', 'int32', 'int32_t')]
6972

7073
}}
7174

@@ -256,7 +259,8 @@ cdef class HashTable:
256259
# name, dtype, float_group, default_na_value
257260
dtypes = [('Float64', 'float64', True, 'np.nan'),
258261
('UInt64', 'uint64', False, 0),
259-
('Int64', 'int64', False, 'NPY_NAT')]
262+
('Int64', 'int64', False, 'NPY_NAT'),
263+
('Int32', 'int32', False, 0)]
260264

261265
}}
262266

pandas/_libs/hashtable_func_helper.pxi.in

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ WARNING: DO NOT edit .pxi FILE directly, .pxi is generated from .pxi.in
1010
dtypes = [('float64', 'float64', 'float64_t'),
1111
('uint64', 'uint64', 'uint64_t'),
1212
('object', 'pymap', 'object'),
13-
('int64', 'int64', 'int64_t')]
13+
('int64', 'int64', 'int64_t'),
14+
('int32', 'int32', 'int32_t')]
1415

1516
}}
1617

@@ -276,6 +277,7 @@ def ismember_{{dtype}}(const {{c_type}}[:] arr, const {{c_type}}[:] values):
276277
# dtype, ctype, table_type, npy_dtype
277278
dtypes = [('float64', 'float64_t', 'float64', 'float64'),
278279
('int64', 'int64_t', 'int64', 'int64'),
280+
('int32', 'int32_t', 'int32', 'int32'),
279281
('uint64', 'uint64_t', 'uint64', 'uint64'),
280282
('object', 'object', 'pymap', 'object_')]
281283
}}

0 commit comments

Comments
 (0)