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