forked from apache/arrow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.pxd
More file actions
339 lines (213 loc) · 7.19 KB
/
lib.pxd
File metadata and controls
339 lines (213 loc) · 7.19 KB
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from pyarrow.includes.common cimport *
from pyarrow.includes.libarrow cimport *
from pyarrow.includes.libarrow cimport CStatus
from cpython cimport PyObject
from libcpp cimport nullptr
cdef extern from "Python.h":
int PySlice_Check(object)
cdef int check_status(const CStatus& status) nogil except -1
cdef class MemoryPool:
cdef:
CMemoryPool* pool
cdef void init(self, CMemoryPool* pool)
cdef CMemoryPool* maybe_unbox_memory_pool(MemoryPool memory_pool)
cdef class DataType:
cdef:
shared_ptr[CDataType] sp_type
CDataType* type
cdef void init(self, const shared_ptr[CDataType]& type)
cdef class ListType(DataType):
cdef:
const CListType* list_type
cdef class DictionaryType(DataType):
cdef:
const CDictionaryType* dict_type
cdef class TimestampType(DataType):
cdef:
const CTimestampType* ts_type
cdef class Time32Type(DataType):
cdef:
const CTime32Type* time_type
cdef class Time64Type(DataType):
cdef:
const CTime64Type* time_type
cdef class FixedSizeBinaryType(DataType):
cdef:
const CFixedSizeBinaryType* fixed_size_binary_type
cdef class DecimalType(FixedSizeBinaryType):
cdef:
const CDecimalType* decimal_type
cdef class Field:
cdef:
shared_ptr[CField] sp_field
CField* field
cdef readonly:
DataType type
cdef void init(self, const shared_ptr[CField]& field)
cdef class Schema:
cdef:
shared_ptr[CSchema] sp_schema
CSchema* schema
cdef void init(self, const vector[shared_ptr[CField]]& fields)
cdef void init_schema(self, const shared_ptr[CSchema]& schema)
cdef class Scalar:
cdef readonly:
DataType type
cdef class NAType(Scalar):
pass
cdef class ArrayValue(Scalar):
cdef:
shared_ptr[CArray] sp_array
int64_t index
cdef void init(self, DataType type,
const shared_ptr[CArray]& sp_array, int64_t index)
cdef void _set_array(self, const shared_ptr[CArray]& sp_array)
cdef class Int8Value(ArrayValue):
pass
cdef class Int64Value(ArrayValue):
pass
cdef class ListValue(ArrayValue):
cdef readonly:
DataType value_type
cdef:
CListArray* ap
cdef getitem(self, int64_t i)
cdef class StringValue(ArrayValue):
pass
cdef class FixedSizeBinaryValue(ArrayValue):
pass
cdef class Array:
cdef:
shared_ptr[CArray] sp_array
CArray* ap
cdef readonly:
DataType type
cdef void init(self, const shared_ptr[CArray]& sp_array)
cdef getitem(self, int64_t i)
cdef class Tensor:
cdef:
shared_ptr[CTensor] sp_tensor
CTensor* tp
cdef readonly:
DataType type
cdef void init(self, const shared_ptr[CTensor]& sp_tensor)
cdef class NullArray(Array):
pass
cdef class BooleanArray(Array):
pass
cdef class NumericArray(Array):
pass
cdef class IntegerArray(NumericArray):
pass
cdef class FloatingPointArray(NumericArray):
pass
cdef class Int8Array(IntegerArray):
pass
cdef class UInt8Array(IntegerArray):
pass
cdef class Int16Array(IntegerArray):
pass
cdef class UInt16Array(IntegerArray):
pass
cdef class Int32Array(IntegerArray):
pass
cdef class UInt32Array(IntegerArray):
pass
cdef class Int64Array(IntegerArray):
pass
cdef class UInt64Array(IntegerArray):
pass
cdef class FloatArray(FloatingPointArray):
pass
cdef class DoubleArray(FloatingPointArray):
pass
cdef class FixedSizeBinaryArray(Array):
pass
cdef class DecimalArray(FixedSizeBinaryArray):
pass
cdef class ListArray(Array):
pass
cdef class StringArray(Array):
pass
cdef class BinaryArray(Array):
pass
cdef class DictionaryArray(Array):
cdef:
object _indices, _dictionary
cdef wrap_array_output(PyObject* output)
cdef object box_scalar(DataType type,
const shared_ptr[CArray]& sp_array,
int64_t index)
cdef class ChunkedArray:
cdef:
shared_ptr[CChunkedArray] sp_chunked_array
CChunkedArray* chunked_array
cdef void init(self, const shared_ptr[CChunkedArray]& chunked_array)
cdef int _check_nullptr(self) except -1
cdef class Column:
cdef:
shared_ptr[CColumn] sp_column
CColumn* column
cdef void init(self, const shared_ptr[CColumn]& column)
cdef int _check_nullptr(self) except -1
cdef class Table:
cdef:
shared_ptr[CTable] sp_table
CTable* table
cdef void init(self, const shared_ptr[CTable]& table)
cdef int _check_nullptr(self) except -1
cdef class RecordBatch:
cdef:
shared_ptr[CRecordBatch] sp_batch
CRecordBatch* batch
Schema _schema
cdef void init(self, const shared_ptr[CRecordBatch]& table)
cdef int _check_nullptr(self) except -1
cdef class Buffer:
cdef:
shared_ptr[CBuffer] buffer
Py_ssize_t shape[1]
Py_ssize_t strides[1]
cdef void init(self, const shared_ptr[CBuffer]& buffer)
cdef class NativeFile:
cdef:
shared_ptr[RandomAccessFile] rd_file
shared_ptr[OutputStream] wr_file
bint is_readable
bint is_writeable
bint is_open
bint own_file
# By implementing these "virtual" functions (all functions in Cython
# extension classes are technically virtual in the C++ sense) we can expose
# the arrow::io abstract file interfaces to other components throughout the
# suite of Arrow C++ libraries
cdef read_handle(self, shared_ptr[RandomAccessFile]* file)
cdef write_handle(self, shared_ptr[OutputStream]* file)
cdef get_reader(object source, shared_ptr[RandomAccessFile]* reader)
cdef get_writer(object source, shared_ptr[OutputStream]* writer)
cdef public object pyarrow_wrap_buffer(const shared_ptr[CBuffer]& buf)
cdef public object pyarrow_wrap_data_type(const shared_ptr[CDataType]& type)
cdef public object pyarrow_wrap_field(const shared_ptr[CField]& field)
cdef public object pyarrow_wrap_schema(const shared_ptr[CSchema]& type)
cdef public object pyarrow_wrap_array(const shared_ptr[CArray]& sp_array)
cdef public object pyarrow_wrap_tensor(const shared_ptr[CTensor]& sp_tensor)
cdef public object pyarrow_wrap_column(const shared_ptr[CColumn]& ccolumn)
cdef public object pyarrow_wrap_table(const shared_ptr[CTable]& ctable)
cdef public object pyarrow_wrap_batch(const shared_ptr[CRecordBatch]& cbatch)
cdef dict box_metadata(const CKeyValueMetadata* sp_metadata)