sparrow
2.4.0
C++20 idiomatic APIs for the Apache Arrow Columnar Format
Toggle main menu visibility
Loading...
Searching...
No Matches
c_interface.hpp
Go to the documentation of this file.
1
// Copyright 2024 Man Group Operations Limited
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#pragma once
16
17
#include <concepts>
18
#include <cstdint>
19
20
#ifndef ARROW_C_DATA_INTERFACE
21
# define ARROW_C_DATA_INTERFACE
22
23
extern
"C"
24
{
25
struct
ArrowSchema
26
{
27
// Array type description
28
const
char
*
format
;
29
const
char
*
name
;
30
const
char
*
metadata
;
31
int64_t
flags
;
32
int64_t
n_children
;
33
struct
ArrowSchema
**
children
;
34
struct
ArrowSchema
*
dictionary
;
35
36
// Release callback
37
void (*
release
)(
struct
ArrowSchema
*);
38
// Opaque producer-specific data
39
void
*
private_data
;
40
};
41
42
struct
ArrowArray
43
{
44
// Array data description
45
int64_t
length
;
46
int64_t
null_count
;
47
int64_t
offset
;
48
int64_t
n_buffers
;
49
int64_t
n_children
;
50
const
void
**
buffers
;
51
struct
ArrowArray
**
children
;
52
struct
ArrowArray
*
dictionary
;
53
54
// Release callback
55
void (*
release
)(
struct
ArrowArray
*);
56
// Opaque producer-specific data
57
void
*
private_data
;
58
};
59
60
}
// extern "C"
61
62
#endif
// ARROW_C_DATA_INTERFACE
63
64
namespace
sparrow
65
{
66
enum class
ArrowFlag
: int64_t
67
{
68
DICTIONARY_ORDERED
= 1,
// For dictionary-encoded types, whether the ordering of dictionary indices
69
// is semantically meaningful.
70
NULLABLE
= 2,
// Whether this field is semantically nullable (regardless of whether it
71
// actually has null values).
72
MAP_KEYS_SORTED
= 4
// For map types, whether the keys within each map value are sorted.
73
};
74
76
enum class
ownership
:
bool
77
{
78
not_owning
,
80
81
owning
,
84
};
85
88
struct
arrow_data_ownership
89
{
91
ownership
schema
=
ownership::not_owning
;
92
94
ownership
array
=
ownership::not_owning
;
95
};
96
98
inline
constexpr
auto
doesnt_own_arrow_data
=
arrow_data_ownership
{
99
.schema =
ownership::not_owning
,
100
.array =
ownership::not_owning
,
101
};
102
104
inline
constexpr
auto
owns_arrow_data
=
arrow_data_ownership
{
105
.schema =
ownership::owning
,
106
.array =
ownership::owning
,
107
};
108
110
template
<
class
T>
111
concept
any_arrow_c_interface
= std::same_as<std::remove_cvref_t<T>,
ArrowArray
>
112
or std::same_as<std::remove_cvref_t<T>,
ArrowSchema
>;
113
114
116
template
<
class
T>
117
concept
arrow_schema_or_ptr
= std::same_as<T, ArrowSchema>
118
or std::same_as<std::remove_reference_t<T>,
ArrowSchema
*>;
119
121
template
<
class
T>
122
concept
arrow_array_or_ptr
= std::same_as<T, ArrowArray>
123
or std::same_as<std::remove_reference_t<T>,
ArrowArray
*>;
124
125
126
}
// namespace sparrow
sparrow::any_arrow_c_interface
Matches only the C interface structs for Arrow.
Definition
c_interface.hpp:111
sparrow::arrow_array_or_ptr
Matches ArrowArray or a non-const pointer to an ArrowArray.
Definition
c_interface.hpp:122
sparrow::arrow_schema_or_ptr
Matches ArrowSchema or a non-const pointer to an ArrowSchema.
Definition
c_interface.hpp:117
sparrow
Definition
array.hpp:21
sparrow::owns_arrow_data
constexpr auto owns_arrow_data
Useful shortcut value to specify full owning of handled Arrow data.
Definition
c_interface.hpp:104
sparrow::doesnt_own_arrow_data
constexpr auto doesnt_own_arrow_data
Useful shortcut value to specify non-owning handled Arrow data.
Definition
c_interface.hpp:98
sparrow::ArrowFlag
ArrowFlag
Definition
c_interface.hpp:67
sparrow::ArrowFlag::NULLABLE
@ NULLABLE
Definition
c_interface.hpp:70
sparrow::ArrowFlag::MAP_KEYS_SORTED
@ MAP_KEYS_SORTED
Definition
c_interface.hpp:72
sparrow::ArrowFlag::DICTIONARY_ORDERED
@ DICTIONARY_ORDERED
Definition
c_interface.hpp:68
sparrow::ownership
ownership
Specifies the ownership model when passing Arrow data to another system.
Definition
c_interface.hpp:77
sparrow::ownership::owning
@ owning
The system handling the related Arrow data owns that data and is responsible for releasing it through...
Definition
c_interface.hpp:81
sparrow::ownership::not_owning
@ not_owning
The system handling the related Arrow data do not own that data, that system must not and will not re...
Definition
c_interface.hpp:78
ArrowArray
Definition
c_interface.hpp:43
ArrowArray::release
void(* release)(struct ArrowArray *)
Definition
c_interface.hpp:55
ArrowArray::private_data
void * private_data
Definition
c_interface.hpp:57
ArrowArray::n_children
int64_t n_children
Definition
c_interface.hpp:49
ArrowArray::null_count
int64_t null_count
Definition
c_interface.hpp:46
ArrowArray::children
struct ArrowArray ** children
Definition
c_interface.hpp:51
ArrowArray::offset
int64_t offset
Definition
c_interface.hpp:47
ArrowArray::dictionary
struct ArrowArray * dictionary
Definition
c_interface.hpp:52
ArrowArray::buffers
const void ** buffers
Definition
c_interface.hpp:50
ArrowArray::n_buffers
int64_t n_buffers
Definition
c_interface.hpp:48
ArrowArray::length
int64_t length
Definition
c_interface.hpp:45
ArrowSchema
Definition
c_interface.hpp:26
ArrowSchema::flags
int64_t flags
Definition
c_interface.hpp:31
ArrowSchema::metadata
const char * metadata
Definition
c_interface.hpp:30
ArrowSchema::n_children
int64_t n_children
Definition
c_interface.hpp:32
ArrowSchema::name
const char * name
Definition
c_interface.hpp:29
ArrowSchema::private_data
void * private_data
Definition
c_interface.hpp:39
ArrowSchema::format
const char * format
Definition
c_interface.hpp:28
ArrowSchema::dictionary
struct ArrowSchema * dictionary
Definition
c_interface.hpp:34
ArrowSchema::release
void(* release)(struct ArrowSchema *)
Definition
c_interface.hpp:37
ArrowSchema::children
struct ArrowSchema ** children
Definition
c_interface.hpp:33
sparrow::arrow_data_ownership
Specifies the ownership model when passing Arrow data to another system through ArrowArray and ArrowS...
Definition
c_interface.hpp:89
sparrow::arrow_data_ownership::schema
ownership schema
< Specifies if the ownership of the schema data
Definition
c_interface.hpp:91
sparrow::arrow_data_ownership::array
ownership array
Definition
c_interface.hpp:94
sparrow
c_interface.hpp
Generated by
1.17.0