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#ifdef __cplusplus
29extern "C"
30{
31#endif
32
33#define ARROW_FLAG_DICTIONARY_ORDERED 1
34#define ARROW_FLAG_NULLABLE 2
35#define ARROW_FLAG_MAP_KEYS_SORTED 4
36
37 struct ArrowSchema
38 {
39 // Array type description
40 const char *format;
41 const char *name;
42 const char *metadata;
43 int64_t flags;
44 int64_t n_children;
45 struct ArrowSchema **children;
46 struct ArrowSchema *dictionary;
47
48 // Release callback
49 void (*release)(struct ArrowSchema *);
50 // Opaque producer-specific data
51 void *private_data;
52 };
53
54 struct ArrowArray
55 {
56 // Array data description
57 int64_t length;
58 int64_t null_count;
59 int64_t offset;
60 int64_t n_buffers;
61 int64_t n_children;
62 const void **buffers;
63 struct ArrowArray **children;
64 struct ArrowArray *dictionary;
65
66 // Release callback
67 void (*release)(struct ArrowArray *);
68 // Opaque producer-specific data
69 void *private_data;
70 };
71
72 // EXPERIMENTAL: C stream interface
73
74 struct ArrowArrayStream
75 {
76 // Callback to get the stream type
77 // (will be the same for all arrays in the stream).
78 //
79 // Return value: 0 if successful, an `errno`-compatible error code
80 // otherwise.
81 //
82 // If successful, the ArrowSchema must be released independently from
83 // the stream.
84 int (*get_schema)(struct ArrowArrayStream *, struct ArrowSchema *out);
85
86 // Callback to get the next array
87 // (if no error and the array is released, the stream has ended)
88 //
89 // Return value: 0 if successful, an `errno`-compatible error code
90 // otherwise.
91 //
92 // If successful, the ArrowArray must be released independently from the
93 // 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
104 // stream (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
109 // released.
110 void (*release)(struct ArrowArrayStream *);
111
112 // Opaque producer-specific data
113 void *private_data;
114 };
115
116#ifdef __cplusplus
117}
118#endif
119