18 const org::apache::arrow::flatbuf::RecordBatch& record_batch,
19 std::span<const uint8_t> body,
20 std::string_view name,
21 const std::optional<std::vector<sparrow::metadata_pair>>& metadata,
28 constexpr std::size_t sizeof_decimal =
sizeof(
typename T::integer_type);
29 std::string format_str =
"d:" + std::to_string(precision) +
"," + std::to_string(scale);
30 if constexpr (sizeof_decimal != 16)
33 format_str +=
"," + std::to_string(sizeof_decimal * 8);
37 std::optional<std::unordered_set<sparrow::ArrowFlag>> flags;
40 flags = std::unordered_set<sparrow::ArrowFlag>{sparrow::ArrowFlag::NULLABLE};
53 const auto compression = record_batch.compression();
54 std::vector<arrow_array_private_data::optionally_owned_buffer> buffers;
67 std::visit([&buffers](
auto&& arg) {
68 using variant_type = std::decay_t<
decltype(arg)>;
69 if constexpr (std::is_same_v<variant_type, sparrow::buffer<std::uint8_t>>)
72 buffers.emplace_back(std::move(arg));
77 sparrow::buffer<std::uint8_t> aligned_buffer(arg.begin(), arg.end(), sparrow::buffer<std::uint8_t>::default_allocator());
78 buffers.emplace_back(std::move(aligned_buffer));
80 }, std::move(decompressed_data));
84 buffers.emplace_back(validity_buffer_span);
85 sparrow::buffer<std::uint8_t> data_buffer_copy(data_buffer_span.begin(), data_buffer_span.end(), sparrow::buffer<std::uint8_t>::default_allocator());
86 buffers.emplace_back(std::move(data_buffer_copy));
95 record_batch.length(),
103 sparrow::arrow_proxy ap{std::move(array), std::move(schema)};
104 return sparrow::decimal_array<T>(std::move(ap));
std::span< const uint8_t > get_buffer(const org::apache::arrow::flatbuf::RecordBatch &record_batch, std::span< const uint8_t > body, size_t &buffer_index)
Extracts a buffer from a RecordBatch's body.
std::variant< sparrow::buffer< std::uint8_t >, std::span< const std::uint8_t > > get_decompressed_buffer(std::span< const uint8_t > buffer_span, const org::apache::arrow::flatbuf::BodyCompression *compression)
Retrieves a decompressed buffer or a view of the original buffer.
std::pair< std::uint8_t *, int64_t > get_bitmap_pointer_and_null_count(std::span< const uint8_t > validity_buffer_span, const int64_t length)
Extracts bitmap pointer and null count from a validity buffer span.
sparrow::decimal_array< T > deserialize_non_owning_decimal(const org::apache::arrow::flatbuf::RecordBatch &record_batch, std::span< const uint8_t > body, std::string_view name, const std::optional< std::vector< sparrow::metadata_pair > > &metadata, bool nullable, size_t &buffer_index, int32_t scale, int32_t precision)
ArrowSchema make_non_owning_arrow_schema(std::string_view format, const char *name, std::optional< M > metadata, std::optional< std::unordered_set< sparrow::ArrowFlag > > flags, size_t children_count, ArrowSchema **children, ArrowSchema *dictionary)
ArrowArray make_arrow_array(int64_t length, int64_t null_count, int64_t offset, size_t children_count, ArrowArray **children, ArrowArray *dictionary, Arg &&private_data_arg)