]> git.proxmox.com Git - ceph.git/blame - ceph/src/arrow/python/pyarrow/cffi.py
import quincy 17.2.0
[ceph.git] / ceph / src / arrow / python / pyarrow / cffi.py
CommitLineData
1d09f67e
TL
1# Licensed to the Apache Software Foundation (ASF) under one
2# or more contributor license agreements. See the NOTICE file
3# distributed with this work for additional information
4# regarding copyright ownership. The ASF licenses this file
5# to you under the Apache License, Version 2.0 (the
6# "License"); you may not use this file except in compliance
7# with the License. You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing,
12# software distributed under the License is distributed on an
13# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14# KIND, either express or implied. See the License for the
15# specific language governing permissions and limitations
16# under the License.
17
18from __future__ import absolute_import
19
20import cffi
21
22c_source = """
23 struct ArrowSchema {
24 // Array type description
25 const char* format;
26 const char* name;
27 const char* metadata;
28 int64_t flags;
29 int64_t n_children;
30 struct ArrowSchema** children;
31 struct ArrowSchema* dictionary;
32
33 // Release callback
34 void (*release)(struct ArrowSchema*);
35 // Opaque producer-specific data
36 void* private_data;
37 };
38
39 struct ArrowArray {
40 // Array data description
41 int64_t length;
42 int64_t null_count;
43 int64_t offset;
44 int64_t n_buffers;
45 int64_t n_children;
46 const void** buffers;
47 struct ArrowArray** children;
48 struct ArrowArray* dictionary;
49
50 // Release callback
51 void (*release)(struct ArrowArray*);
52 // Opaque producer-specific data
53 void* private_data;
54 };
55
56 struct ArrowArrayStream {
57 int (*get_schema)(struct ArrowArrayStream*, struct ArrowSchema* out);
58 int (*get_next)(struct ArrowArrayStream*, struct ArrowArray* out);
59
60 const char* (*get_last_error)(struct ArrowArrayStream*);
61
62 // Release callback
63 void (*release)(struct ArrowArrayStream*);
64 // Opaque producer-specific data
65 void* private_data;
66 };
67 """
68
69# TODO use out-of-line mode for faster import and avoid C parsing
70ffi = cffi.FFI()
71ffi.cdef(c_source)