sparrow 1.3.0
Loading...
Searching...
No Matches
private_data.hpp
Go to the documentation of this file.
1// Copyright 2024 Man Group Operations Limited
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include <memory>
18#include <queue>
19#include <ranges>
20#include <string>
21
25
26namespace sparrow
27{
29 {
30 public:
31
33
35 {
36 m_schema = std::move(out_schema);
37 }
38
39 [[nodiscard]] ArrowSchema* schema()
40 {
41 return m_schema.get();
42 }
43
44 [[nodiscard]] const ArrowSchema* schema() const
45 {
46 return m_schema.get();
47 }
48
49 template <std::ranges::input_range R>
50 requires std::same_as<std::ranges::range_value_t<R>, ArrowArray*>
51 void import_arrays(R&& arrays)
52 {
53 for (auto&& array : arrays)
54 {
55 m_arrays.push(array_ptr(array));
56 }
57 }
58
60 {
61 m_arrays.push(std::move(array));
62 }
63
65 {
66 if (m_arrays.empty())
67 {
68 return new ArrowArray{};
69 }
70
71 ArrowArray* array = m_arrays.front().release();
72 m_arrays.pop();
73 return array;
74 }
75
76 [[nodiscard]] const std::string& get_last_error_message() const
77 {
78 return m_last_error_message;
79 }
80
81 void set_last_error_message(std::string_view message)
82 {
83 m_last_error_message = message;
84 }
85
86 private:
87
88 schema_unique_ptr m_schema;
89 std::queue<array_unique_ptr> m_arrays{};
90 std::string m_last_error_message{};
91 };
92}
Dynamically typed array encapsulating an Arrow layout.
Definition array_api.hpp:43
SPARROW_API const_reference front() const
Returns a constant reference to the first element in the container.
void import_schema(schema_unique_ptr &&out_schema)
const ArrowSchema * schema() const
const std::string & get_last_error_message() const
void import_array(array_unique_ptr &&array)
void set_last_error_message(std::string_view message)
std::unique_ptr< ArrowSchema, arrow_schema_deleter > schema_unique_ptr
std::unique_ptr< ArrowArray, arrow_array_deleter > array_unique_ptr