2626#include " iceberg/v1_metadata.h"
2727#include " iceberg/v2_metadata.h"
2828#include " iceberg/v3_metadata.h"
29- #include " iceberg/v4_metadata.h"
3029
3130namespace iceberg {
3231
@@ -67,14 +66,6 @@ class ManifestWriterImpl : public ManifestWriter {
6766 std::unique_ptr<ManifestEntryAdapter> adapter_;
6867};
6968
70- std::shared_ptr<Schema> ParseSchema (std::shared_ptr<Schema> partition_schema) {
71- auto manifest_entry_schema =
72- ManifestEntry::TypeFromPartitionType (std::move (partition_schema));
73- auto fields_span = manifest_entry_schema->fields ();
74- std::vector<SchemaField> fields (fields_span.begin (), fields_span.end ());
75- return std::make_shared<Schema>(fields);
76- }
77-
7869Result<std::unique_ptr<Writer>> OpenFileWriter (std::string_view location,
7970 const std::shared_ptr<Schema> schema,
8071 std::shared_ptr<FileIO> file_io) {
@@ -89,7 +80,12 @@ Result<std::unique_ptr<Writer>> OpenFileWriter(std::string_view location,
8980Result<std::unique_ptr<ManifestWriter>> ManifestWriter::MakeV1Writer (
9081 std::optional<int64_t > snapshot_id, std::string_view manifest_location,
9182 std::shared_ptr<FileIO> file_io, std::shared_ptr<Schema> partition_schema) {
92- auto schema = ParseSchema (partition_schema);
83+ // TODO(xiao.dong) parse v1 schema
84+ auto manifest_entry_schema =
85+ ManifestEntry::TypeFromPartitionType (std::move (partition_schema));
86+ auto fields_span = manifest_entry_schema->fields ();
87+ std::vector<SchemaField> fields (fields_span.begin (), fields_span.end ());
88+ auto schema = std::make_shared<Schema>(fields);
9389 ICEBERG_ASSIGN_OR_RAISE (auto writer,
9490 OpenFileWriter (manifest_location, schema, std::move (file_io)));
9591 auto adapter = std::make_unique<ManifestEntryAdapterV1>(snapshot_id, std::move (schema));
@@ -99,7 +95,12 @@ Result<std::unique_ptr<ManifestWriter>> ManifestWriter::MakeV1Writer(
9995Result<std::unique_ptr<ManifestWriter>> ManifestWriter::MakeV2Writer (
10096 std::optional<int64_t > snapshot_id, std::string_view manifest_location,
10197 std::shared_ptr<FileIO> file_io, std::shared_ptr<Schema> partition_schema) {
102- auto schema = ParseSchema (partition_schema);
98+ // TODO(xiao.dong) parse v2 schema
99+ auto manifest_entry_schema =
100+ ManifestEntry::TypeFromPartitionType (std::move (partition_schema));
101+ auto fields_span = manifest_entry_schema->fields ();
102+ std::vector<SchemaField> fields (fields_span.begin (), fields_span.end ());
103+ auto schema = std::make_shared<Schema>(fields);
103104 ICEBERG_ASSIGN_OR_RAISE (auto writer,
104105 OpenFileWriter (manifest_location, schema, std::move (file_io)));
105106 auto adapter = std::make_unique<ManifestEntryAdapterV2>(snapshot_id, std::move (schema));
@@ -110,26 +111,19 @@ Result<std::unique_ptr<ManifestWriter>> ManifestWriter::MakeV3Writer(
110111 std::optional<int64_t > snapshot_id, std::optional<int64_t > first_row_id,
111112 std::string_view manifest_location, std::shared_ptr<FileIO> file_io,
112113 std::shared_ptr<Schema> partition_schema) {
113- auto schema = ParseSchema (partition_schema);
114+ // TODO(xiao.dong) parse v3 schema
115+ auto manifest_entry_schema =
116+ ManifestEntry::TypeFromPartitionType (std::move (partition_schema));
117+ auto fields_span = manifest_entry_schema->fields ();
118+ std::vector<SchemaField> fields (fields_span.begin (), fields_span.end ());
119+ auto schema = std::make_shared<Schema>(fields);
114120 ICEBERG_ASSIGN_OR_RAISE (auto writer,
115121 OpenFileWriter (manifest_location, schema, std::move (file_io)));
116122 auto adapter = std::make_unique<ManifestEntryAdapterV3>(snapshot_id, first_row_id,
117123 std::move (schema));
118124 return std::make_unique<ManifestWriterImpl>(std::move (writer), std::move (adapter));
119125}
120126
121- Result<std::unique_ptr<ManifestWriter>> ManifestWriter::MakeV4Writer (
122- std::optional<int64_t > snapshot_id, std::optional<int64_t > first_row_id,
123- std::string_view manifest_location, std::shared_ptr<FileIO> file_io,
124- std::shared_ptr<Schema> partition_schema) {
125- auto schema = ParseSchema (partition_schema);
126- ICEBERG_ASSIGN_OR_RAISE (auto writer,
127- OpenFileWriter (manifest_location, schema, std::move (file_io)));
128- auto adapter = std::make_unique<ManifestEntryAdapterV4>(snapshot_id, first_row_id,
129- std::move (schema));
130- return std::make_unique<ManifestWriterImpl>(std::move (writer), std::move (adapter));
131- }
132-
133127// / \brief Write manifest files to a manifest list file.
134128class ManifestListWriterImpl : public ManifestListWriter {
135129 public:
@@ -170,6 +164,7 @@ class ManifestListWriterImpl : public ManifestListWriter {
170164Result<std::unique_ptr<ManifestListWriter>> ManifestListWriter::MakeV1Writer (
171165 int64_t snapshot_id, std::optional<int64_t > parent_snapshot_id,
172166 std::string_view manifest_list_location, std::shared_ptr<FileIO> file_io) {
167+ // TODO(xiao.dong) parse v1 schema
173168 std::vector<SchemaField> fields (ManifestFile::Type ().fields ().begin (),
174169 ManifestFile::Type ().fields ().end ());
175170 auto schema = std::make_shared<Schema>(fields);
@@ -184,6 +179,7 @@ Result<std::unique_ptr<ManifestListWriter>> ManifestListWriter::MakeV2Writer(
184179 int64_t snapshot_id, std::optional<int64_t > parent_snapshot_id,
185180 int64_t sequence_number, std::string_view manifest_list_location,
186181 std::shared_ptr<FileIO> file_io) {
182+ // TODO(xiao.dong) parse v2 schema
187183 std::vector<SchemaField> fields (ManifestFile::Type ().fields ().begin (),
188184 ManifestFile::Type ().fields ().end ());
189185 auto schema = std::make_shared<Schema>(fields);
@@ -198,6 +194,7 @@ Result<std::unique_ptr<ManifestListWriter>> ManifestListWriter::MakeV3Writer(
198194 int64_t snapshot_id, std::optional<int64_t > parent_snapshot_id,
199195 int64_t sequence_number, std::optional<int64_t > first_row_id,
200196 std::string_view manifest_list_location, std::shared_ptr<FileIO> file_io) {
197+ // TODO(xiao.dong) parse v3 schema
201198 std::vector<SchemaField> fields (ManifestFile::Type ().fields ().begin (),
202199 ManifestFile::Type ().fields ().end ());
203200 auto schema = std::make_shared<Schema>(fields);
@@ -208,18 +205,4 @@ Result<std::unique_ptr<ManifestListWriter>> ManifestListWriter::MakeV3Writer(
208205 return std::make_unique<ManifestListWriterImpl>(std::move (writer), std::move (adapter));
209206}
210207
211- Result<std::unique_ptr<ManifestListWriter>> ManifestListWriter::MakeV4Writer (
212- int64_t snapshot_id, std::optional<int64_t > parent_snapshot_id,
213- int64_t sequence_number, std::optional<int64_t > first_row_id,
214- std::string_view manifest_list_location, std::shared_ptr<FileIO> file_io) {
215- std::vector<SchemaField> fields (ManifestFile::Type ().fields ().begin (),
216- ManifestFile::Type ().fields ().end ());
217- auto schema = std::make_shared<Schema>(fields);
218- ICEBERG_ASSIGN_OR_RAISE (
219- auto writer, OpenFileWriter (manifest_list_location, schema, std::move (file_io)));
220- auto adapter = std::make_unique<ManifestFileAdapterV4>(
221- snapshot_id, parent_snapshot_id, sequence_number, first_row_id, std::move (schema));
222- return std::make_unique<ManifestListWriterImpl>(std::move (writer), std::move (adapter));
223- }
224-
225208} // namespace iceberg
0 commit comments