Skip to content

CLN: Use signed integers in khash maps for signed integer keys #38882

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 26 additions & 26 deletions pandas/_libs/khash.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -16,56 +16,56 @@ from numpy cimport (
cdef extern from "khash_python.h":
const int KHASH_TRACE_DOMAIN

ctypedef uint32_t khint_t
ctypedef khint_t khiter_t
ctypedef uint32_t khuint_t
ctypedef khuint_t khiter_t

ctypedef struct kh_pymap_t:
khint_t n_buckets, size, n_occupied, upper_bound
khuint_t n_buckets, size, n_occupied, upper_bound
uint32_t *flags
PyObject **keys
size_t *vals

kh_pymap_t* kh_init_pymap()
void kh_destroy_pymap(kh_pymap_t*)
void kh_clear_pymap(kh_pymap_t*)
khint_t kh_get_pymap(kh_pymap_t*, PyObject*)
void kh_resize_pymap(kh_pymap_t*, khint_t)
khint_t kh_put_pymap(kh_pymap_t*, PyObject*, int*)
void kh_del_pymap(kh_pymap_t*, khint_t)
khuint_t kh_get_pymap(kh_pymap_t*, PyObject*)
void kh_resize_pymap(kh_pymap_t*, khuint_t)
khuint_t kh_put_pymap(kh_pymap_t*, PyObject*, int*)
void kh_del_pymap(kh_pymap_t*, khuint_t)

bint kh_exist_pymap(kh_pymap_t*, khiter_t)

ctypedef struct kh_pyset_t:
khint_t n_buckets, size, n_occupied, upper_bound
khuint_t n_buckets, size, n_occupied, upper_bound
uint32_t *flags
PyObject **keys
size_t *vals

kh_pyset_t* kh_init_pyset()
void kh_destroy_pyset(kh_pyset_t*)
void kh_clear_pyset(kh_pyset_t*)
khint_t kh_get_pyset(kh_pyset_t*, PyObject*)
void kh_resize_pyset(kh_pyset_t*, khint_t)
khint_t kh_put_pyset(kh_pyset_t*, PyObject*, int*)
void kh_del_pyset(kh_pyset_t*, khint_t)
khuint_t kh_get_pyset(kh_pyset_t*, PyObject*)
void kh_resize_pyset(kh_pyset_t*, khuint_t)
khuint_t kh_put_pyset(kh_pyset_t*, PyObject*, int*)
void kh_del_pyset(kh_pyset_t*, khuint_t)

bint kh_exist_pyset(kh_pyset_t*, khiter_t)

ctypedef char* kh_cstr_t

ctypedef struct kh_str_t:
khint_t n_buckets, size, n_occupied, upper_bound
khuint_t n_buckets, size, n_occupied, upper_bound
uint32_t *flags
kh_cstr_t *keys
size_t *vals

kh_str_t* kh_init_str() nogil
void kh_destroy_str(kh_str_t*) nogil
void kh_clear_str(kh_str_t*) nogil
khint_t kh_get_str(kh_str_t*, kh_cstr_t) nogil
void kh_resize_str(kh_str_t*, khint_t) nogil
khint_t kh_put_str(kh_str_t*, kh_cstr_t, int*) nogil
void kh_del_str(kh_str_t*, khint_t) nogil
khuint_t kh_get_str(kh_str_t*, kh_cstr_t) nogil
void kh_resize_str(kh_str_t*, khuint_t) nogil
khuint_t kh_put_str(kh_str_t*, kh_cstr_t, int*) nogil
void kh_del_str(kh_str_t*, khuint_t) nogil

bint kh_exist_str(kh_str_t*, khiter_t) nogil

Expand All @@ -74,27 +74,27 @@ cdef extern from "khash_python.h":
int starts[256]

kh_str_starts_t* kh_init_str_starts() nogil
khint_t kh_put_str_starts_item(kh_str_starts_t* table, char* key,
int* ret) nogil
khint_t kh_get_str_starts_item(kh_str_starts_t* table, char* key) nogil
khuint_t kh_put_str_starts_item(kh_str_starts_t* table, char* key,
int* ret) nogil
khuint_t kh_get_str_starts_item(kh_str_starts_t* table, char* key) nogil
void kh_destroy_str_starts(kh_str_starts_t*) nogil
void kh_resize_str_starts(kh_str_starts_t*, khint_t) nogil
void kh_resize_str_starts(kh_str_starts_t*, khuint_t) nogil

# sweep factorize

ctypedef struct kh_strbox_t:
khint_t n_buckets, size, n_occupied, upper_bound
khuint_t n_buckets, size, n_occupied, upper_bound
uint32_t *flags
kh_cstr_t *keys
PyObject **vals

kh_strbox_t* kh_init_strbox() nogil
void kh_destroy_strbox(kh_strbox_t*) nogil
void kh_clear_strbox(kh_strbox_t*) nogil
khint_t kh_get_strbox(kh_strbox_t*, kh_cstr_t) nogil
void kh_resize_strbox(kh_strbox_t*, khint_t) nogil
khint_t kh_put_strbox(kh_strbox_t*, kh_cstr_t, int*) nogil
void kh_del_strbox(kh_strbox_t*, khint_t) nogil
khuint_t kh_get_strbox(kh_strbox_t*, kh_cstr_t) nogil
void kh_resize_strbox(kh_strbox_t*, khuint_t) nogil
khuint_t kh_put_strbox(kh_strbox_t*, kh_cstr_t, int*) nogil
void kh_del_strbox(kh_strbox_t*, khuint_t) nogil

bint kh_exist_strbox(kh_strbox_t*, khiter_t) nogil

Expand Down
10 changes: 5 additions & 5 deletions pandas/_libs/khash_for_primitive_helper.pxi.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ primitive_types = [('int64', 'int64_t'),

cdef extern from "khash_python.h":
ctypedef struct kh_{{name}}_t:
khint_t n_buckets, size, n_occupied, upper_bound
khuint_t n_buckets, size, n_occupied, upper_bound
uint32_t *flags
{{c_type}} *keys
size_t *vals

kh_{{name}}_t* kh_init_{{name}}() nogil
void kh_destroy_{{name}}(kh_{{name}}_t*) nogil
void kh_clear_{{name}}(kh_{{name}}_t*) nogil
khint_t kh_get_{{name}}(kh_{{name}}_t*, {{c_type}}) nogil
void kh_resize_{{name}}(kh_{{name}}_t*, khint_t) nogil
khint_t kh_put_{{name}}(kh_{{name}}_t*, {{c_type}}, int*) nogil
void kh_del_{{name}}(kh_{{name}}_t*, khint_t) nogil
khuint_t kh_get_{{name}}(kh_{{name}}_t*, {{c_type}}) nogil
void kh_resize_{{name}}(kh_{{name}}_t*, khuint_t) nogil
khuint_t kh_put_{{name}}(kh_{{name}}_t*, {{c_type}}, int*) nogil
void kh_del_{{name}}(kh_{{name}}_t*, khuint_t) nogil

bint kh_exist_{{name}}(kh_{{name}}_t*, khiter_t) nogil

Expand Down
Loading