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