iceberg-cpp
Loading...
Searching...
No Matches
arrow_c_data.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#pragma once
21
29
30#include <cstdint>
31
32extern "C" {
33
34#ifndef ARROW_C_DATA_INTERFACE
35# define ARROW_C_DATA_INTERFACE
36
37# define ARROW_FLAG_DICTIONARY_ORDERED 1
38# define ARROW_FLAG_NULLABLE 2
39# define ARROW_FLAG_MAP_KEYS_SORTED 4
40
42 // Array type description
43 const char* format;
44 const char* name;
45 const char* metadata;
46 int64_t flags;
47 int64_t n_children;
48 struct ArrowSchema** children;
49 struct ArrowSchema* dictionary;
50
51 // Release callback
52 void (*release)(struct ArrowSchema*);
53 // Opaque producer-specific data
54 void* private_data;
55};
56
57struct ArrowArray {
58 // Array data description
59 int64_t length;
60 int64_t null_count;
61 int64_t offset;
62 int64_t n_buffers;
63 int64_t n_children;
64 const void** buffers;
65 struct ArrowArray** children;
66 struct ArrowArray* dictionary;
67
68 // Release callback
69 void (*release)(struct ArrowArray*);
70 // Opaque producer-specific data
71 void* private_data;
72};
73
74#endif // ARROW_C_DATA_INTERFACE
75
76#ifndef ARROW_C_STREAM_INTERFACE
77# define ARROW_C_STREAM_INTERFACE
78
80 // Callback to get the stream type
81 // (will be the same for all arrays in the stream).
82 //
83 // Return value: 0 if successful, an `errno`-compatible error code otherwise.
84 //
85 // If successful, the ArrowSchema must be released independently from the stream.
86 int (*get_schema)(struct ArrowArrayStream*, struct ArrowSchema* out);
87
88 // Callback to get the next array
89 // (if no error and the array is released, the stream has ended)
90 //
91 // Return value: 0 if successful, an `errno`-compatible error code otherwise.
92 //
93 // If successful, the ArrowArray must be released independently from the stream.
94 int (*get_next)(struct ArrowArrayStream*, struct ArrowArray* out);
95
96 // Callback to get optional detailed error information.
97 // This must only be called if the last stream operation failed
98 // with a non-0 return code.
99 //
100 // Return value: pointer to a null-terminated character array describing
101 // the last error, or NULL if no description is available.
102 //
103 // The returned pointer is only valid until the next operation on this stream
104 // (including release).
105 const char* (*get_last_error)(struct ArrowArrayStream*);
106
107 // Release callback: release the stream's own resources.
108 // Note that arrays returned by `get_next` must be individually released.
109 void (*release)(struct ArrowArrayStream*);
110
111 // Opaque producer-specific data
112 void* private_data;
113};
114
115#endif // ARROW_C_STREAM_INTERFACE
116
117} // extern "C"
Definition arrow_c_data.h:79
Definition arrow_c_data.h:57
Definition arrow_c_data.h:41