QGIS API Documentation 3.99.0-Master (21b3aa880ba)
Loading...
Searching...
No Matches
qgsarrowiterator.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsarrowiterator.h
3 ---------------------
4 begin : November 2025
5 copyright : (C) 2025 by Dewey Dunnington
6 email : dewey at dunnington dot ca
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSARROWITERATOR_H
17#define QGSARROWITERATOR_H
18
19#include "qgis_core.h"
20#include "qgsfeatureiterator.h"
21#include "qgsvectorlayer.h"
22
23#ifndef ARROW_C_DATA_INTERFACE
24#define ARROW_C_DATA_INTERFACE
25
26#define ARROW_FLAG_DICTIONARY_ORDERED 1
27#define ARROW_FLAG_NULLABLE 2
28#define ARROW_FLAG_MAP_KEYS_SORTED 4
29
30#ifndef SIP_RUN
32struct ArrowSchema
33{
34 // Array type description
35 const char *format;
36 const char *name;
37 const char *metadata;
38 int64_t flags;
39 int64_t n_children;
40 struct ArrowSchema **children;
41 struct ArrowSchema *dictionary;
42
43 // Release callback
44 void ( *release )( struct ArrowSchema * );
45 // Opaque producer-specific data
46 void *private_data;
47};
49#endif
50
51#ifndef SIP_RUN
53struct ArrowArray
54{
55 // Array data description
56 int64_t length;
57 int64_t null_count;
58 int64_t offset;
59 int64_t n_buffers;
60 int64_t n_children;
61 const void **buffers;
62 struct ArrowArray **children;
63 struct ArrowArray *dictionary;
64
65 // Release callback
66 void ( *release )( struct ArrowArray * );
67 // Opaque producer-specific data
68 void *private_data;
69};
71#endif
72
73#endif // ARROW_C_DATA_INTERFACE
74
75#ifndef ARROW_C_STREAM_INTERFACE
76#define ARROW_C_STREAM_INTERFACE
77
78#ifndef SIP_RUN
80struct ArrowArrayStream
81{
82 // Callbacks providing stream functionality
83 int ( *get_schema )( struct ArrowArrayStream *, struct ArrowSchema *out );
84 int ( *get_next )( struct ArrowArrayStream *, struct ArrowArray *out );
85 const char *( *get_last_error )( struct ArrowArrayStream * );
86
87 // Release callback
88 void ( *release )( struct ArrowArrayStream * );
89
90 // Opaque producer-specific data
91 void *private_data;
92};
94#endif
95
96#endif // ARROW_C_STREAM_INTERFACE
97
104{
105 public:
108
115 void setGeometryColumnName( const QString &geometryColumnName );
116
123 QString geometryColumnName() const;
124
125 private:
126 QString mGeometryColumnName;
127};
128
143class CORE_EXPORT QgsArrowSchema
144{
145 public:
148
150 QgsArrowSchema( const QgsArrowSchema &other );
151
153 QgsArrowSchema &operator=( const QgsArrowSchema &other );
154
156
157#ifndef SIP_RUN
159 struct ArrowSchema *schema();
160
162 const struct ArrowSchema *schema() const;
163#endif
164
170 unsigned long long cSchemaAddress() const;
171
177 void exportToAddress( unsigned long long otherAddress );
178
180 bool isValid() const;
181
187 int geometryColumnIndex() const;
188
191
192 private:
193 struct ArrowSchema mSchema {};
194 int mGeometryColumnIndex = -1;
195};
196
208class CORE_EXPORT QgsArrowArray
209{
210 public:
212 QgsArrowArray() = default;
213
215 QgsArrowArray( const QgsArrowArray &other ) = delete;
216
217#ifndef SIP_RUN
219 QgsArrowArray( QgsArrowArray &&other );
220
223#endif
224
226
227#ifndef SIP_RUN
229 struct ArrowArray *array();
230
232 const struct ArrowArray *array() const;
233#endif
234
240 unsigned long long cArrayAddress() const;
241
247 void exportToAddress( unsigned long long otherAddress );
248
250 bool isValid() const;
251
252 private:
253 struct ArrowArray mArray {};
254
255#ifdef SIP_RUN
256 QgsArrowArray( const QgsArrowArray &other );
257#endif
258};
259
265class CORE_EXPORT QgsArrowIterator
266{
267 public:
269 QgsArrowIterator() = default;
270
272 explicit QgsArrowIterator( QgsFeatureIterator featureIterator );
273
279 void setSchema( const QgsArrowSchema &schema );
280
290
297
304
305 private:
306 QgsFeatureIterator mFeatureIterator;
307 QgsArrowSchema mSchema;
308};
309
310#endif // QGSARROWITERATOR_H
Wrapper around an ArrowArray.
QgsArrowArray()=default
Construct invalid array holder.
struct ArrowArray * array()
Access the underlying ArrowArray from C++.
QgsArrowArray & operator=(QgsArrowArray &other)=delete
bool isValid() const
Returns true if this wrapper object holds a valid ArrowArray.
QgsArrowArray(const QgsArrowArray &other)=delete
void exportToAddress(unsigned long long otherAddress)
Export this array to the address of an empty ArrowArray for export across boundaries.
unsigned long long cArrayAddress() const
Returns the address of the underlying ArrowArray for import or export across boundaries.
Options for inferring an ArrowSchema from a feature source.
void setGeometryColumnName(const QString &geometryColumnName)
Set the name that should be used to refer to the geometry column.
QgsArrowInferSchemaOptions()
Construct default options.
QString geometryColumnName() const
The name that should be used for a layer's geometry column.
static QgsArrowSchema inferSchema(const QgsVectorLayer &layer, const QgsArrowInferSchemaOptions &options=QgsArrowInferSchemaOptions())
Infer the QgsArrowSchema for a given QgsVectorLayer.
QgsArrowArray nextFeatures(int n)
Build an ArrowArray using the next n features (or fewer depending on the number of features remaining...
QgsArrowIterator()=default
Construct invalid iterator.
void setSchema(const QgsArrowSchema &schema)
Set the ArrowSchema for the output of all future batches.
Wrapper around an ArrowSchema.
int geometryColumnIndex() const
Returns the index of the column in this schema that should be populated with a feature geometry.
bool isValid() const
Returns true if this wrapper object holds a valid ArrowSchema.
unsigned long long cSchemaAddress() const
Returns the address of the underlying ArrowSchema for import or export across boundaries.
struct ArrowSchema * schema()
Access the underlying ArrowSchema from C++.
QgsArrowSchema & operator=(const QgsArrowSchema &other)
Assignment operator.
void exportToAddress(unsigned long long otherAddress)
Export this array to the address of an empty ArrowSchema for export across boundaries.
QgsArrowSchema()
Construct invalid schema holder.
void setGeometryColumnIndex(int geometryColumnIndex)
Set the index of the column in this schema that should be populated with a feature geometry.
Represents a coordinate reference system (CRS).
Defines a QGIS exception class.
Wrapper for iterator of features from vector data provider or vector layer.
Container of fields for a vector layer.
Definition qgsfields.h:46
Represents a vector layer which manages a vector based dataset.
#define SIP_THROW(name,...)
Definition qgis_sip.h:211