1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
from numpy cimport (
    intp_t,
    ndarray,
)
 
from pandas._libs.khash cimport (
    complex64_t,
    complex128_t,
    float32_t,
    float64_t,
    int8_t,
    int16_t,
    int32_t,
    int64_t,
    kh_complex64_t,
    kh_complex128_t,
    kh_float32_t,
    kh_float64_t,
    kh_int8_t,
    kh_int16_t,
    kh_int32_t,
    kh_int64_t,
    kh_pymap_t,
    kh_str_t,
    kh_uint8_t,
    kh_uint16_t,
    kh_uint32_t,
    kh_uint64_t,
    khcomplex64_t,
    khcomplex128_t,
    uint8_t,
    uint16_t,
    uint32_t,
    uint64_t,
)
 
# prototypes for sharing
 
cdef class HashTable:
    pass
 
cdef class UInt64HashTable(HashTable):
    cdef kh_uint64_t *table
    cdef int64_t na_position
    cdef bint uses_mask
 
    cpdef get_item(self, uint64_t val)
    cpdef set_item(self, uint64_t key, Py_ssize_t val)
    cpdef get_na(self)
    cpdef set_na(self, Py_ssize_t val)
 
cdef class Int64HashTable(HashTable):
    cdef kh_int64_t *table
    cdef int64_t na_position
    cdef bint uses_mask
 
    cpdef get_item(self, int64_t val)
    cpdef set_item(self, int64_t key, Py_ssize_t val)
    cpdef get_na(self)
    cpdef set_na(self, Py_ssize_t val)
 
cdef class UInt32HashTable(HashTable):
    cdef kh_uint32_t *table
    cdef int64_t na_position
    cdef bint uses_mask
 
    cpdef get_item(self, uint32_t val)
    cpdef set_item(self, uint32_t key, Py_ssize_t val)
    cpdef get_na(self)
    cpdef set_na(self, Py_ssize_t val)
 
cdef class Int32HashTable(HashTable):
    cdef kh_int32_t *table
    cdef int64_t na_position
    cdef bint uses_mask
 
    cpdef get_item(self, int32_t val)
    cpdef set_item(self, int32_t key, Py_ssize_t val)
    cpdef get_na(self)
    cpdef set_na(self, Py_ssize_t val)
 
cdef class UInt16HashTable(HashTable):
    cdef kh_uint16_t *table
    cdef int64_t na_position
    cdef bint uses_mask
 
    cpdef get_item(self, uint16_t val)
    cpdef set_item(self, uint16_t key, Py_ssize_t val)
    cpdef get_na(self)
    cpdef set_na(self, Py_ssize_t val)
 
cdef class Int16HashTable(HashTable):
    cdef kh_int16_t *table
    cdef int64_t na_position
    cdef bint uses_mask
 
    cpdef get_item(self, int16_t val)
    cpdef set_item(self, int16_t key, Py_ssize_t val)
    cpdef get_na(self)
    cpdef set_na(self, Py_ssize_t val)
 
cdef class UInt8HashTable(HashTable):
    cdef kh_uint8_t *table
    cdef int64_t na_position
    cdef bint uses_mask
 
    cpdef get_item(self, uint8_t val)
    cpdef set_item(self, uint8_t key, Py_ssize_t val)
    cpdef get_na(self)
    cpdef set_na(self, Py_ssize_t val)
 
cdef class Int8HashTable(HashTable):
    cdef kh_int8_t *table
    cdef int64_t na_position
    cdef bint uses_mask
 
    cpdef get_item(self, int8_t val)
    cpdef set_item(self, int8_t key, Py_ssize_t val)
    cpdef get_na(self)
    cpdef set_na(self, Py_ssize_t val)
 
cdef class Float64HashTable(HashTable):
    cdef kh_float64_t *table
    cdef int64_t na_position
    cdef bint uses_mask
 
    cpdef get_item(self, float64_t val)
    cpdef set_item(self, float64_t key, Py_ssize_t val)
    cpdef get_na(self)
    cpdef set_na(self, Py_ssize_t val)
 
cdef class Float32HashTable(HashTable):
    cdef kh_float32_t *table
    cdef int64_t na_position
    cdef bint uses_mask
 
    cpdef get_item(self, float32_t val)
    cpdef set_item(self, float32_t key, Py_ssize_t val)
    cpdef get_na(self)
    cpdef set_na(self, Py_ssize_t val)
 
cdef class Complex64HashTable(HashTable):
    cdef kh_complex64_t *table
    cdef int64_t na_position
    cdef bint uses_mask
 
    cpdef get_item(self, complex64_t val)
    cpdef set_item(self, complex64_t key, Py_ssize_t val)
    cpdef get_na(self)
    cpdef set_na(self, Py_ssize_t val)
 
cdef class Complex128HashTable(HashTable):
    cdef kh_complex128_t *table
    cdef int64_t na_position
    cdef bint uses_mask
 
    cpdef get_item(self, complex128_t val)
    cpdef set_item(self, complex128_t key, Py_ssize_t val)
    cpdef get_na(self)
    cpdef set_na(self, Py_ssize_t val)
 
cdef class PyObjectHashTable(HashTable):
    cdef kh_pymap_t *table
 
    cpdef get_item(self, object val)
    cpdef set_item(self, object key, Py_ssize_t val)
 
 
cdef class StringHashTable(HashTable):
    cdef kh_str_t *table
 
    cpdef get_item(self, str val)
    cpdef set_item(self, str key, Py_ssize_t val)
 
cdef struct Int64VectorData:
    int64_t *data
    Py_ssize_t n, m
 
cdef class Vector:
    cdef bint external_view_exists
 
cdef class Int64Vector(Vector):
    cdef Int64VectorData *data
    cdef ndarray ao
 
    cdef resize(self)
    cpdef ndarray to_array(self)
    cdef void append(self, int64_t x)
    cdef extend(self, int64_t[:] x)