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/master/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 // EXPERIMENTAL: C stream interface
72
73 struct ArrowArrayStream
74 {
75 // Callback to get the stream type
76 // (will be the same for all arrays in the stream).
77 //
78 // Return value: 0 if successful, an `errno`-compatible error code
79 // otherwise.
80 //
81 // If successful, the ArrowSchema must be released independently from
82 // the stream.
83 int (*get_schema)(struct ArrowArrayStream *, struct ArrowSchema *out);
84
85 // Callback to get the next array
86 // (if no error and the array is released, the stream has ended)
87 //
88 // Return value: 0 if successful, an `errno`-compatible error code
89 // otherwise.
90 //
91 // If successful, the ArrowArray must be released independently from the
92 // stream.
93 int (*get_next)(struct ArrowArrayStream *, struct ArrowArray *out);
94
95 // Callback to get optional detailed error information.
96 // This must only be called if the last stream operation failed
97 // with a non-0 return code.
98 //
99 // Return value: pointer to a null-terminated character array describing
100 // the last error, or NULL if no description is available.
101 //
102 // The returned pointer is only valid until the next operation on this
103 // stream (including release).
104 const char *(*get_last_error)(struct ArrowArrayStream *);
105
106 // Release callback: release the stream's own resources.
107 // Note that arrays returned by `get_next` must be individually
108 // released.
109 void (*release)(struct ArrowArrayStream *);
110
111 // Opaque producer-specific data
112 void *private_data;
113 };
114
115#ifdef __cplusplus
116}
117#endif
118