1 | //===----------------------------------------------------------------------===// |
2 | // DuckDB |
3 | // |
4 | // duckdb/common/arrow/arrow.hpp |
5 | // |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #ifndef ARROW_FLAG_DICTIONARY_ORDERED |
10 | |
11 | #include <stdint.h> |
12 | |
13 | #ifdef __cplusplus |
14 | extern "C" { |
15 | #endif |
16 | |
17 | #ifndef ARROW_C_DATA_INTERFACE |
18 | #define ARROW_C_DATA_INTERFACE |
19 | |
20 | #define ARROW_FLAG_DICTIONARY_ORDERED 1 |
21 | #define ARROW_FLAG_NULLABLE 2 |
22 | #define ARROW_FLAG_MAP_KEYS_SORTED 4 |
23 | |
24 | struct ArrowSchema { |
25 | // Array type description |
26 | const char *format; |
27 | const char *name; |
28 | const char *metadata; |
29 | int64_t flags; |
30 | int64_t n_children; |
31 | struct ArrowSchema **children; |
32 | struct ArrowSchema *dictionary; |
33 | |
34 | // Release callback |
35 | void (*release)(struct ArrowSchema *); |
36 | // Opaque producer-specific data |
37 | void *private_data; |
38 | }; |
39 | |
40 | struct ArrowArray { |
41 | // Array data description |
42 | int64_t length; |
43 | int64_t null_count; |
44 | int64_t offset; |
45 | int64_t n_buffers; |
46 | int64_t n_children; |
47 | const void **buffers; |
48 | struct ArrowArray **children; |
49 | struct ArrowArray *dictionary; |
50 | |
51 | // Release callback |
52 | void (*release)(struct ArrowArray *); |
53 | // Opaque producer-specific data |
54 | void *private_data; |
55 | }; |
56 | #endif |
57 | |
58 | #ifndef ARROW_C_STREAM_INTERFACE |
59 | #define ARROW_C_STREAM_INTERFACE |
60 | // EXPERIMENTAL |
61 | struct ArrowArrayStream { |
62 | // Callback to get the stream type |
63 | // (will be the same for all arrays in the stream). |
64 | // Return value: 0 if successful, an `errno`-compatible error code otherwise. |
65 | int (*get_schema)(struct ArrowArrayStream *, struct ArrowSchema *out); |
66 | // Callback to get the next array |
67 | // (if no error and the array is released, the stream has ended) |
68 | // Return value: 0 if successful, an `errno`-compatible error code otherwise. |
69 | int (*get_next)(struct ArrowArrayStream *, struct ArrowArray *out); |
70 | |
71 | // Callback to get optional detailed error information. |
72 | // This must only be called if the last stream operation failed |
73 | // with a non-0 return code. The returned pointer is only valid until |
74 | // the next operation on this stream (including release). |
75 | // If unavailable, NULL is returned. |
76 | const char *(*get_last_error)(struct ArrowArrayStream *); |
77 | |
78 | // Release callback: release the stream's own resources. |
79 | // Note that arrays returned by `get_next` must be individually released. |
80 | void (*release)(struct ArrowArrayStream *); |
81 | // Opaque producer-specific data |
82 | void *private_data; |
83 | }; |
84 | #endif |
85 | |
86 | #ifdef __cplusplus |
87 | } |
88 | #endif |
89 | |
90 | #endif |
91 | |