sparrow 0.6.0
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
20namespace sparrow
21{
22 /*
23 * Class for tracking ownership of the dictionary of an `ArrowArray` or
24 * an `ArrowSchema` allocated by sparrow.
25 */
27 {
28 public:
29
31 [[nodiscard]] bool has_dictionary_ownership() const;
32
33 protected:
34
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 */
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
void set_children_ownership(const CHILDREN_OWNERSHIP &children_ownership_values)
bool has_child_ownership(std::size_t child) const
children_ownership(std::size_t size=0)
void resize_children(std::size_t size)
std::size_t children_size() const noexcept
void set_child_ownership(std::size_t child, bool ownership)
void set_dictionary_ownership(bool ownership)
bool has_dictionary_ownership() const
ownership
Specifies the ownership model when passing Arrow data to another system.