|
22 | 22 | #include <functional> |
23 | 23 | #include <memory> |
24 | 24 | #include <optional> |
| 25 | +#include <span> |
25 | 26 | #include <string> |
26 | 27 | #include <unordered_map> |
27 | 28 | #include <unordered_set> |
28 | 29 | #include <vector> |
29 | 30 |
|
30 | 31 | #include "iceberg/iceberg_export.h" |
31 | | -#include "iceberg/manifest/manifest_list.h" |
32 | | -#include "iceberg/manifest/manifest_writer.h" |
33 | | -#include "iceberg/manifest/rolling_manifest_writer.h" |
34 | 32 | #include "iceberg/result.h" |
35 | 33 | #include "iceberg/snapshot.h" |
36 | | -#include "iceberg/table.h" |
37 | | -#include "iceberg/transaction.h" |
38 | 34 | #include "iceberg/type_fwd.h" |
39 | 35 | #include "iceberg/update/pending_update.h" |
40 | 36 |
|
@@ -107,75 +103,23 @@ class ICEBERG_EXPORT SnapshotUpdate : public PendingUpdate { |
107 | 103 |
|
108 | 104 | /// \brief Write data manifests for the given data files |
109 | 105 | /// |
110 | | - /// \tparam Iterator Iterator type that dereferences to std::shared_ptr<DataFile> |
111 | | - /// \param begin Iterator to the beginning of the data files range |
112 | | - /// \param end Iterator to the end of the data files range |
| 106 | + /// \param files Data files to write |
113 | 107 | /// \param spec The partition spec to use |
114 | 108 | /// \param data_sequence_number Optional data sequence number for the files |
115 | 109 | /// \return A vector of manifest files |
116 | | - // TODO(xxx): write manifests in parallel |
117 | | - template <typename Iterator> |
118 | 110 | Result<std::vector<ManifestFile>> WriteDataManifests( |
119 | | - Iterator begin, Iterator end, const std::shared_ptr<PartitionSpec>& spec, |
120 | | - std::optional<int64_t> data_sequence_number = std::nullopt) { |
121 | | - if (begin == end) { |
122 | | - return std::vector<ManifestFile>{}; |
123 | | - } |
124 | | - |
125 | | - ICEBERG_ASSIGN_OR_RAISE(auto current_schema, base().Schema()); |
126 | | - RollingManifestWriter rolling_writer( |
127 | | - [this, spec, schema = std::move(current_schema), |
128 | | - snapshot_id = SnapshotId()]() -> Result<std::unique_ptr<ManifestWriter>> { |
129 | | - return ManifestWriter::MakeWriter(base().format_version, snapshot_id, |
130 | | - ManifestPath(), transaction_->table()->io(), |
131 | | - std::move(spec), std::move(schema), |
132 | | - ManifestContent::kData, |
133 | | - /*first_row_id=*/base().next_row_id); |
134 | | - }, |
135 | | - target_manifest_size_bytes_); |
136 | | - |
137 | | - for (auto it = begin; it != end; ++it) { |
138 | | - ICEBERG_RETURN_UNEXPECTED( |
139 | | - rolling_writer.WriteAddedEntry(*it, data_sequence_number)); |
140 | | - } |
141 | | - ICEBERG_RETURN_UNEXPECTED(rolling_writer.Close()); |
142 | | - return rolling_writer.ToManifestFiles(); |
143 | | - } |
| 111 | + std::span<const std::shared_ptr<DataFile>> files, |
| 112 | + const std::shared_ptr<PartitionSpec>& spec, |
| 113 | + std::optional<int64_t> data_sequence_number = std::nullopt); |
144 | 114 |
|
145 | 115 | /// \brief Write delete manifests for the given delete files |
146 | 116 | /// |
147 | | - /// \tparam Iterator Iterator type that dereferences to std::shared_ptr<DataFile> |
148 | | - /// \param begin Iterator to the beginning of the delete files range |
149 | | - /// \param end Iterator to the end of the delete files range |
| 117 | + /// \param files Delete files to write |
150 | 118 | /// \param spec The partition spec to use |
151 | 119 | /// \return A vector of manifest files |
152 | | - // TODO(xxx): write manifests in parallel |
153 | | - template <typename Iterator> |
154 | 120 | Result<std::vector<ManifestFile>> WriteDeleteManifests( |
155 | | - Iterator begin, Iterator end, const std::shared_ptr<PartitionSpec>& spec) { |
156 | | - if (begin == end) { |
157 | | - return std::vector<ManifestFile>{}; |
158 | | - } |
159 | | - |
160 | | - ICEBERG_ASSIGN_OR_RAISE(auto current_schema, base().Schema()); |
161 | | - RollingManifestWriter rolling_writer( |
162 | | - [this, spec, schema = std::move(current_schema), |
163 | | - snapshot_id = SnapshotId()]() -> Result<std::unique_ptr<ManifestWriter>> { |
164 | | - return ManifestWriter::MakeWriter(base().format_version, snapshot_id, |
165 | | - ManifestPath(), transaction_->table()->io(), |
166 | | - std::move(spec), std::move(schema), |
167 | | - ManifestContent::kDeletes); |
168 | | - }, |
169 | | - target_manifest_size_bytes_); |
170 | | - |
171 | | - for (auto it = begin; it != end; ++it) { |
172 | | - /// FIXME: Java impl wrap it with `PendingDeleteFile` and deals with |
173 | | - /// (*it)->data_sequenece_number |
174 | | - ICEBERG_RETURN_UNEXPECTED(rolling_writer.WriteAddedEntry(*it)); |
175 | | - } |
176 | | - ICEBERG_RETURN_UNEXPECTED(rolling_writer.Close()); |
177 | | - return rolling_writer.ToManifestFiles(); |
178 | | - } |
| 121 | + std::span<const std::shared_ptr<DataFile>> files, |
| 122 | + const std::shared_ptr<PartitionSpec>& spec); |
179 | 123 |
|
180 | 124 | Status SetTargetBranch(const std::string& branch); |
181 | 125 | const std::string& target_branch() const { return target_branch_; } |
|
0 commit comments