iceberg-cpp
Loading...
Searching...
No Matches
arrow_row_builder_internal.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#pragma once
21
31
32#include <cstdint>
33#include <map>
34#include <span>
35#include <string_view>
36#include <unordered_map>
37#include <vector>
38
40#include "iceberg/iceberg_export.h"
41#include "iceberg/result.h"
42#include "iceberg/type_fwd.h"
43
44namespace iceberg {
45
66class ICEBERG_EXPORT ArrowRowBuilder {
67 public:
69 static Result<ArrowRowBuilder> Make(const Schema& schema);
70
75 static Result<ArrowRowBuilder> Make(const ArrowSchema* schema);
76
77 ArrowRowBuilder(ArrowRowBuilder&& other) noexcept;
78 ArrowRowBuilder& operator=(ArrowRowBuilder&& other) noexcept;
79
80 ArrowRowBuilder(const ArrowRowBuilder&) = delete;
81 ArrowRowBuilder& operator=(const ArrowRowBuilder&) = delete;
82
84
86 int64_t num_columns() const;
87
91 ArrowArray* column(int64_t index);
92
96 Status FinishRow();
97
101 Result<ArrowArray> Finish() &&;
102
103 private:
104 ArrowRowBuilder() = default;
105 ArrowArray array_{};
106};
107
109ICEBERG_EXPORT Status AppendNull(ArrowArray* array);
110
112ICEBERG_EXPORT Status AppendBoolean(ArrowArray* array, bool value);
113
117ICEBERG_EXPORT Status AppendInt(ArrowArray* array, int64_t value);
118
120ICEBERG_EXPORT Status AppendUInt(ArrowArray* array, uint64_t value);
121
123ICEBERG_EXPORT Status AppendDouble(ArrowArray* array, double value);
124
126ICEBERG_EXPORT Status AppendString(ArrowArray* array, std::string_view value);
127
129ICEBERG_EXPORT Status AppendBytes(ArrowArray* array, std::span<const uint8_t> value);
130
132ICEBERG_EXPORT Status AppendIntList(ArrowArray* array,
133 const std::vector<int32_t>& values);
134
136ICEBERG_EXPORT Status AppendIntList(ArrowArray* array,
137 const std::vector<int64_t>& values);
138
143ICEBERG_EXPORT Status AppendStringMap(
144 ArrowArray* array, const std::unordered_map<std::string, std::string>& entries);
145
147ICEBERG_EXPORT Status AppendIntMap(ArrowArray* array,
148 const std::map<int32_t, int64_t>& entries);
149
151ICEBERG_EXPORT Status AppendBinaryMap(
152 ArrowArray* array, const std::map<int32_t, std::vector<uint8_t>>& entries);
153
154} // namespace iceberg
Movable RAII builder that materializes rows into an Arrow struct array.
Definition arrow_row_builder_internal.h:66
A schema for a Table.
Definition schema.h:51
Definition arrow_c_data.h:57
Definition arrow_c_data.h:41