GDAL
ogr_recordbatch.h
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
18// This file is an extract
19// https://github.com/apache/arrow/blob/main/cpp/src/arrow/c/abi.h WARNING: DO
20// NOT MODIFY the content as it would break interoperability !
21
22#pragma once
23
26#include <stdint.h>
27
28// Spec and documentation: https://arrow.apache.org/docs/format/CDataInterface.html
29
30#ifdef __cplusplus
31extern "C"
32{
33#endif
34
35#ifndef ARROW_C_DATA_INTERFACE
36#define ARROW_C_DATA_INTERFACE
37
38#define ARROW_FLAG_DICTIONARY_ORDERED 1
39#define ARROW_FLAG_NULLABLE 2
40#define ARROW_FLAG_MAP_KEYS_SORTED 4
41
42 struct ArrowSchema
43 {
44 // Array type description
45 const char *format;
46 const char *name;
47 const char *metadata;
48 int64_t flags;
49 int64_t n_children;
50 struct ArrowSchema **children;
51 struct ArrowSchema *dictionary;
52
53 // Release callback
54 void (*release)(struct ArrowSchema *);
55 // Opaque producer-specific data
56 void *private_data;
57 };
58
59 struct ArrowArray
60 {
61 // Array data description
62 int64_t length;
63 int64_t null_count;
64 int64_t offset;
65 int64_t n_buffers;
66 int64_t n_children;
67 const void **buffers;
68 struct ArrowArray **children;
69 struct ArrowArray *dictionary;
70
71 // Release callback
72 void (*release)(struct ArrowArray *);
73 // Opaque producer-specific data
74 void *private_data;
75 };
76
77#endif // ARROW_C_DATA_INTERFACE
78
79#ifndef ARROW_C_STREAM_INTERFACE
80#define ARROW_C_STREAM_INTERFACE
81
82 struct ArrowArrayStream
83 {
84 // Callback to get the stream type
85 // (will be the same for all arrays in the stream).
86 //
87 // Return value: 0 if successful, an `errno`-compatible error code otherwise.
88 //
89 // If successful, the ArrowSchema must be released independently from the stream.
90 int (*get_schema)(struct ArrowArrayStream *, struct ArrowSchema *out);
91
92 // Callback to get the next array
93 // (if no error and the array is released, the stream has ended)
94 //
95 // Return value: 0 if successful, an `errno`-compatible error code otherwise.
96 //
97 // If successful, the ArrowArray must be released independently from the stream.
98 int (*get_next)(struct ArrowArrayStream *, struct ArrowArray *out);
99
100 // Callback to get optional detailed error information.
101 // This must only be called if the last stream operation failed
102 // with a non-0 return code.
103 //
104 // Return value: pointer to a null-terminated character array describing
105 // the last error, or NULL if no description is available.
106 //
107 // The returned pointer is only valid until the next operation on this stream
108 // (including release).
109 const char *(*get_last_error)(struct ArrowArrayStream *);
110
111 // Release callback: release the stream's own resources.
112 // Note that arrays returned by `get_next` must be individually released.
113 void (*release)(struct ArrowArrayStream *);
114
115 // Opaque producer-specific data
116 void *private_data;
117 };
118
119#endif // ARROW_C_STREAM_INTERFACE
120
121#ifdef __cplusplus
122}
123#endif
124