sparrow
2.4.0
C++20 idiomatic APIs for the Apache Arrow Columnar Format
Toggle main menu visibility
Loading...
Searching...
No Matches
private_data_ownership.hpp
Go to the documentation of this file.
1
//
2
// Licensed under the Apache License, Version 2.0 (the "License");
3
// you may not use this file except in compliance with the License.
4
// You may obtain a copy of the License at
5
//
6
// http://www.apache.org/licenses/LICENSE-2.0
7
//
8
// Unless required by applicable law or agreed to in writing, software
9
// distributed under the License is distributed on an "AS IS" BASIS,
10
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
// See the License for the specific language governing permissions and
12
// limitations under the License.
13
14
#pragma once
15
16
#include <cstddef>
17
#include <ranges>
18
#include <vector>
19
20
namespace
sparrow
21
{
22
/*
23
* Class for tracking ownership of the dictionary of an `ArrowArray` or
24
* an `ArrowSchema` allocated by sparrow.
25
*/
26
class
dictionary_ownership
27
{
28
public
:
29
30
void
set_dictionary_ownership
(
bool
ownership
)
noexcept
;
31
[[nodiscard]]
bool
has_dictionary_ownership
() const noexcept;
32
33
protected:
34
35
explicit
dictionary_ownership
(
bool
ownership
) noexcept
36
: m_has_ownership(
ownership
)
37
{
38
}
39
40
private
:
41
42
bool
m_has_ownership =
true
;
43
};
44
45
/*
46
* Class for tracking ownership of children of an `ArrowArray` or
47
* an `ArrowSchema` allocated by sparrow.
48
*/
49
class
children_ownership
50
{
51
public
:
52
53
[[nodiscard]] std::size_t
children_size
() const noexcept;
54
void
set_child_ownership
(
std
::
size_t
child,
bool
ownership
);
55
template <
std
::
ranges
::input_range CHILDREN_OWNERSHIP>
56
void
set_children_ownership
(const CHILDREN_OWNERSHIP& children_ownership_values);
57
[[nodiscard]]
bool
has_child_ownership
(
std
::
size_t
child) const;
58
59
void
resize_children
(
std
::
size_t
size);
60
61
protected:
62
63
explicit
children_ownership
(
std
::
size_t
size = 0);
64
65
template <
std
::
ranges
::input_range CHILDREN_OWNERSHIP>
66
requires
std
::is_same_v<
std
::
ranges
::range_value_t<CHILDREN_OWNERSHIP>,
bool
>
67
constexpr explicit
children_ownership
(const CHILDREN_OWNERSHIP& children_ownership_values)
68
: m_children(children_ownership_values.begin(), children_ownership_values.end())
69
{
70
}
71
72
private
:
73
74
using
children_owner_list = std::vector<bool>;
// TODO : replace by a dynamic_bitset
75
children_owner_list m_children = {};
76
};
77
78
79
}
// namespace sparrow
sparrow::children_ownership::set_children_ownership
void set_children_ownership(const CHILDREN_OWNERSHIP &children_ownership_values)
sparrow::children_ownership::has_child_ownership
bool has_child_ownership(std::size_t child) const
sparrow::children_ownership::children_ownership
children_ownership(std::size_t size=0)
sparrow::children_ownership::resize_children
void resize_children(std::size_t size)
sparrow::children_ownership::children_size
std::size_t children_size() const noexcept
sparrow::children_ownership::set_child_ownership
void set_child_ownership(std::size_t child, bool ownership)
sparrow::dictionary_ownership::set_dictionary_ownership
void set_dictionary_ownership(bool ownership) noexcept
sparrow::dictionary_ownership::has_dictionary_ownership
bool has_dictionary_ownership() const noexcept
sparrow::dictionary_ownership::dictionary_ownership
dictionary_ownership(bool ownership) noexcept
Definition
private_data_ownership.hpp:35
sparrow::ranges
Definition
ranges.hpp:88
sparrow
Definition
array.hpp:21
sparrow::ownership
ownership
Specifies the ownership model when passing Arrow data to another system.
Definition
c_interface.hpp:77
std
Extensions to the C++ standard library.
Definition
float16_t.hpp:1916
sparrow
arrow_interface
private_data_ownership.hpp
Generated by
1.17.0