sparrow-ipc 0.2.0
Loading...
Searching...
No Matches
arrow_array_schema_common_release.hpp
Go to the documentation of this file.
1
2#pragma once
3
4#include <sparrow/c_interface.hpp>
5
8
9namespace sparrow_ipc
10{
11 // TODO Find a way to use sparrow internals directly and avoid duplicated code
18 template <class T>
19 requires std::same_as<T, ArrowArray> || std::same_as<T, ArrowSchema>
21 {
22 using private_data_type = std::conditional_t<
23 std::same_as<T, ArrowArray>,
26 if (t.release == nullptr)
27 {
28 return;
29 }
30 SPARROW_ASSERT_TRUE(t.private_data != nullptr);
31 const auto private_data = static_cast<const private_data_type*>(t.private_data);
32 delete private_data;
33 t.private_data = nullptr;
34
35 if (t.dictionary)
36 {
37 if (t.dictionary->release)
38 {
39 t.dictionary->release(t.dictionary);
40 }
41 delete t.dictionary;
42 t.dictionary = nullptr;
43 }
44
45 if (t.children)
46 {
47 for (int64_t i = 0; i < t.n_children; ++i)
48 {
49 T* child = t.children[i];
50 if (child)
51 {
52 if (child->release)
53 {
54 child->release(child);
55 }
56 delete child;
57 child = nullptr;
58 }
59 }
60 delete[] t.children;
61 t.children = nullptr;
62 }
63 t.release = nullptr;
64 }
65}
void release_common_non_owning_arrow(T &t)
Release the children and dictionnary of an ArrowArray or ArrowSchema.