sparrow
2.4.0
C++20 idiomatic APIs for the Apache Arrow Columnar Format
Toggle main menu visibility
Loading...
Searching...
No Matches
arrow_array_schema_common_release.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 "
sparrow/arrow_interface/arrow_array/private_data.hpp
"
18
#include "
sparrow/arrow_interface/arrow_schema/private_data.hpp
"
19
#include "
sparrow/c_interface.hpp
"
20
21
namespace
sparrow
22
{
29
template
<
class
T>
30
requires
std::same_as<T, ArrowArray> || std::same_as<T, ArrowSchema>
31
void
release_common_arrow
(T& t)
32
{
33
using
private_data_type = std::
34
conditional_t<std::same_as<T, ArrowArray>,
arrow_array_private_data
,
arrow_schema_private_data
>;
35
if
(t.release ==
nullptr
)
36
{
37
return
;
38
}
39
SPARROW_ASSERT_TRUE
(t.private_data !=
nullptr
);
40
const
auto
private_data =
static_cast<
const
private_data_type*
>
(t.private_data);
41
42
if
(t.dictionary)
43
{
44
if
(private_data->has_dictionary_ownership())
45
{
46
if
(t.dictionary->release)
47
{
48
t.dictionary->release(t.dictionary);
49
}
50
delete
t.dictionary;
51
t.dictionary =
nullptr
;
52
}
53
}
54
55
if
(t.children)
56
{
57
for
(int64_t i = 0; i < t.n_children; ++i)
58
{
59
T* child = t.children[i];
60
if
(child)
61
{
62
if
(private_data->has_child_ownership(
static_cast<
std::size_t
>
(i)))
63
{
64
if
(child->release)
65
{
66
child->release(child);
67
}
68
delete
child;
69
child =
nullptr
;
70
}
71
}
72
}
73
delete
[] t.children;
74
t.children =
nullptr
;
75
}
76
t.release =
nullptr
;
77
}
78
}
private_data.hpp
private_data.hpp
c_interface.hpp
sparrow::arrow_array_private_data
Private data for ArrowArray.
Definition
private_data.hpp:38
sparrow::arrow_schema_private_data
Private data for ArrowSchema.
Definition
private_data.hpp:37
SPARROW_ASSERT_TRUE
#define SPARROW_ASSERT_TRUE(expr__)
Definition
contracts.hpp:209
sparrow
Definition
array.hpp:21
sparrow::release_common_arrow
void release_common_arrow(T &t)
Release the children and dictionnary of an ArrowArray or ArrowSchema.
Definition
arrow_array_schema_common_release.hpp:31
sparrow
arrow_interface
arrow_array_schema_common_release.hpp
Generated by
1.17.0