142 template <std::ranges::input_range R>
149 if (private_data.
schema() ==
nullptr)
157 for (
const auto&
array : arrays)
161 throw std::runtime_error(
"Incompatible schema when adding array to ArrowArrayStream");
166 for (
auto&&
array : std::forward<R>(arrays))
170 swap(*array_ptr, extracted_array);
190 push(std::ranges::single_view(std::forward<A>(
array)));
210 std::variant<ArrowArrayStream*, ArrowArrayStream> m_stream;
235 void throw_if_immutable()
const;
Implementation of the Arrow C Stream Interface for streaming data exchange.
Dynamically typed array encapsulating an Arrow layout.
void import_schema(schema_unique_ptr &&out_schema)
void import_array(array_unique_ptr &&array)
arrow_array_stream_proxy(const arrow_array_stream_proxy &)=delete
arrow_array_stream_proxy(arrow_array_stream_proxy &&other) noexcept
SPARROW_API ArrowArrayStream * export_stream()
Export the stream pointer.
SPARROW_API arrow_array_stream_proxy(ArrowArrayStream &&stream)
Constructs from an existing ArrowArrayStream by taking ownership.
SPARROW_API ~arrow_array_stream_proxy()
Destructor that releases all resources.
void push(R &&arrays)
Adds a range of arrays to the stream.
SPARROW_API arrow_array_stream_proxy()
Constructs a new ArrowArrayStream producer.
SPARROW_API std::optional< array > pop()
Retrieves the next array from the stream.
arrow_array_stream_proxy & operator=(const arrow_array_stream_proxy &)=delete
arrow_array_stream_proxy & operator=(arrow_array_stream_proxy &&other) noexcept
SPARROW_API arrow_array_stream_proxy(ArrowArrayStream *stream)
Constructs from an existing ArrowArrayStream pointer by referencing it.
void push(A &&array)
Adds a single array to the stream.
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.
std::unique_ptr< ArrowSchema, arrow_schema_deleter > schema_unique_ptr
ArrowArray extract_arrow_array(A &&a)
Extracts the internal ArrowArray structure from the given Array or typed layout.
std::unique_ptr< ArrowArray, arrow_array_deleter > array_unique_ptr
bool SPARROW_API check_compatible_schema(const ArrowSchema &schema1, const ArrowSchema &schema2)
SPARROW_API void swap(ArrowArray &lhs, ArrowArray &rhs) noexcept
Swaps the contents of the two ArrowArray objects.
ArrowSchema * get_arrow_schema(A &a)
Returns a pointer to the internal ArrowSchema of the given array or layout.