23#include <unordered_set>
28#if defined(__cpp_lib_format)
63 template <
class F,
class N, input_metadata_container M = std::vector<metadata_pair>, std::ranges::input_range CHILDREN_OWNERSHIP>
64 requires std::constructible_from<arrow_schema_private_data::FormatType, F>
65 && std::constructible_from<arrow_schema_private_data::NameType, N>
66 && std::is_same_v<std::ranges::range_value_t<CHILDREN_OWNERSHIP>,
bool>
70 std::optional<M> metadata,
71 std::optional<std::unordered_set<ArrowFlag>> flags,
72 ArrowSchema** children,
74 ArrowSchema* dictionary,
89 template <
class F,
class N, input_metadata_container M = std::vector<metadata_pair>, std::ranges::input_range CHILDREN_OWNERSHIP>
90 requires std::constructible_from<arrow_schema_private_data::FormatType, F>
91 && std::constructible_from<arrow_schema_private_data::NameType, N>
92 && std::is_same_v<std::ranges::range_value_t<CHILDREN_OWNERSHIP>,
bool>
97 std::optional<M> metadata,
98 std::optional<std::unordered_set<ArrowFlag>> flags,
117 if (flags.has_value())
119 for (
const auto& flag : *flags)
121 schema.
flags |=
static_cast<int64_t
>(flag);
126 std::optional<std::string> metadata_str = metadata.has_value()
127 ? std::make_optional(
135 std::move(metadata_str),
141 schema.
format = private_data->format_ptr();
142 schema.
name = private_data->name_ptr();
143 schema.
metadata = private_data->metadata_ptr();
149 template <
class F,
class N, input_metadata_container M, std::ranges::input_range CHILDREN_OWNERSHIP>
150 requires std::constructible_from<arrow_schema_private_data::FormatType, F>
151 && std::constructible_from<arrow_schema_private_data::NameType, N>
152 && std::is_same_v<std::ranges::range_value_t<CHILDREN_OWNERSHIP>,
bool>
156 std::optional<M> metadata,
157 std::optional<std::unordered_set<ArrowFlag>> flags,
192 using namespace std::literals;
199 std::array<bool, 0>{},
236 swap(source, target);
237 source.release(&source);
251#if defined(__cpp_lib_format)
256 constexpr auto parse(std::format_parse_context& ctx)
261 auto format(
const ArrowSchema& obj, std::format_context& ctx)
const
263 std::string children_str = std::format(
"{}",
static_cast<void*
>(obj.
children));
266 children_str += std::format(
"\n-{}",
static_cast<void*
>(obj.
children[i]));
269 const std::string format = obj.
format ? obj.
format :
"nullptr";
270 const std::string name = obj.
name ? obj.
name :
"nullptr";
273 return std::format_to(
275 "ArrowSchema - ptr address: {}\n- format: {}\n- name: {}\n- metadata: {}\n- flags: {}\n- n_children: {}\n- children: {}\n- dictionary: {}\n- release: {}\n- private_data: {}\n",
276 static_cast<const void*
>(&obj),
284 static_cast<const void*
>(std::addressof(obj.
release)),
292 os << std::format(
"{}", value);
Private data for ArrowSchema.
#define SPARROW_ASSERT_TRUE(expr__)
#define SPARROW_ASSERT_FALSE(expr__)
ArrowSchema make_arrow_schema(F format, N name, std::optional< M > metadata, std::optional< std::unordered_set< ArrowFlag > > flags, ArrowSchema **children, const CHILDREN_OWNERSHIP &children_ownership, ArrowSchema *dictionary, bool dictionary_ownership)
Creates an ArrowSchema owned by a unique_ptr and holding the provided data.
SPARROW_API void copy_schema(const ArrowSchema &source, ArrowSchema &target)
Fills the target ArrowSchema with a deep copy of the data from the source ArrowSchema.
SPARROW_API void release_arrow_schema(ArrowSchema *schema)
Release function to use for the ArrowSchema.release member.
SPARROW_API void swap(ArrowArray &lhs, ArrowArray &rhs)
Swaps the contents of the two ArrowArray objects.
std::string get_metadata_from_key_values(const T &metadata)
Converts a container of key-value pairs to binary metadata format.
SPARROW_API void empty_release_arrow_schema(ArrowSchema *schema)
Empty release function to use for the ArrowSchema.release member.
ArrowSchema move_schema(ArrowSchema &&source)
Moves the content of source into a stack-allocated array, and reset the source to an empty ArrowSchem...
void fill_arrow_schema(ArrowSchema &schema, F format, N name, std::optional< M > metadata, std::optional< std::unordered_set< ArrowFlag > > flags, ArrowSchema **children, const CHILDREN_OWNERSHIP &children_ownership, ArrowSchema *dictionary, bool dictionary_ownership)
ArrowSchema make_empty_arrow_schema()
std::ostream & operator<<(std::ostream &os, const sparrow::nullval_t &)
struct ArrowSchema * dictionary
void(* release)(struct ArrowSchema *)
struct ArrowSchema ** children