-
Notifications
You must be signed in to change notification settings - Fork 77
feat: add partition summary and write added/existing/deleted entries to manifest writer #317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ | |
| # under the License. | ||
|
|
||
| build/ | ||
| cmake-build/ | ||
| cmake-build-debug/ | ||
| cmake-build-release/ | ||
| .DS_Store | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -19,16 +19,17 @@ | |||||||
|
|
||||||||
| #include "iceberg/manifest_adapter.h" | ||||||||
|
|
||||||||
| #include <memory> | ||||||||
| #include <utility> | ||||||||
|
|
||||||||
| #include <nanoarrow/nanoarrow.h> | ||||||||
|
|
||||||||
| #include "iceberg/arrow/nanoarrow_status_internal.h" | ||||||||
| #include "iceberg/manifest_entry.h" | ||||||||
| #include "iceberg/manifest_list.h" | ||||||||
| #include "iceberg/partition_summary_internal.h" | ||||||||
| #include "iceberg/result.h" | ||||||||
| #include "iceberg/schema.h" | ||||||||
| #include "iceberg/schema_internal.h" | ||||||||
| #include "iceberg/util/checked_cast.h" | ||||||||
| #include "iceberg/util/macros.h" | ||||||||
|
|
||||||||
|
|
@@ -141,10 +142,12 @@ Result<ArrowArray*> ManifestAdapter::FinishAppending() { | |||||||
| return &array_; | ||||||||
| } | ||||||||
|
|
||||||||
| ManifestEntryAdapter::ManifestEntryAdapter(std::shared_ptr<PartitionSpec> partition_spec, | ||||||||
| ManifestEntryAdapter::ManifestEntryAdapter(std::optional<int64_t> snapshot_id_, | ||||||||
| std::shared_ptr<PartitionSpec> partition_spec, | ||||||||
| std::shared_ptr<Schema> current_schema, | ||||||||
| ManifestContent content) | ||||||||
| : partition_spec_(std::move(partition_spec)), | ||||||||
| : snapshot_id_(snapshot_id_), | ||||||||
| partition_spec_(std::move(partition_spec)), | ||||||||
| current_schema_(std::move(current_schema)), | ||||||||
| content_(content) { | ||||||||
| if (!partition_spec_) { | ||||||||
|
|
@@ -161,6 +164,27 @@ ManifestEntryAdapter::~ManifestEntryAdapter() { | |||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| Result<ManifestFile> ManifestEntryAdapter::ToManifestFile() const { | ||||||||
| ManifestFile manifest_file; | ||||||||
wgtmac marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||
| manifest_file.partition_spec_id = partition_spec_->spec_id(); | ||||||||
| manifest_file.content = content_; | ||||||||
| // sequence_number and min_sequence_number with kInvalidSequenceNumber will be | ||||||||
| // replace with real sequence number in `ManifestListWriter`. | ||||||||
| manifest_file.sequence_number = TableMetadata::kInvalidSequenceNumber; | ||||||||
| manifest_file.min_sequence_number = | ||||||||
| min_sequence_number_.value_or(TableMetadata::kInvalidSequenceNumber); | ||||||||
| manifest_file.existing_files_count = existing_files_count_; | ||||||||
| manifest_file.added_files_count = add_files_count_; | ||||||||
| manifest_file.existing_files_count = existing_files_count_; | ||||||||
| manifest_file.deleted_files_count = delete_files_count_; | ||||||||
| manifest_file.added_rows_count = add_rows_count_; | ||||||||
| manifest_file.existing_rows_count = existing_rows_count_; | ||||||||
| manifest_file.deleted_rows_count = delete_rows_count_; | ||||||||
| ICEBERG_ASSIGN_OR_RAISE(auto partition_summary, partition_summary_->Summaries()); | ||||||||
| manifest_file.partitions = std::move(partition_summary); | ||||||||
|
||||||||
| ICEBERG_ASSIGN_OR_RAISE(auto partition_summary, partition_summary_->Summaries()); | |
| manifest_file.partitions = std::move(partition_summary); | |
| ICEBERG_ASSIGN_OR_RAISE(manifest_file.partitions, partition_summary_->Summaries()); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,17 +72,17 @@ struct ICEBERG_EXPORT PartitionFieldSummary { | |
| static const StructType& Type(); | ||
| }; | ||
|
|
||
| /// \brief The type of files tracked by the manifest, either data or delete files; 0 for | ||
| /// all v1 manifests | ||
| enum class ManifestContent { | ||
wgtmac marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /// The manifest content is data. | ||
| kData = 0, | ||
| /// The manifest content is deletes. | ||
| kDeletes = 1, | ||
| }; | ||
|
|
||
| /// \brief Entry in a manifest list. | ||
| struct ICEBERG_EXPORT ManifestFile { | ||
| /// \brief The type of files tracked by the manifest, either data or delete files; 0 for | ||
| /// all v1 manifests | ||
| enum class Content { | ||
| /// The manifest content is data. | ||
| kData = 0, | ||
| /// The manifest content is deletes. | ||
| kDeletes = 1, | ||
| }; | ||
|
|
||
| /// Field id: 500 | ||
| /// Location of the manifest file | ||
| std::string manifest_path; | ||
|
|
@@ -96,7 +96,7 @@ struct ICEBERG_EXPORT ManifestFile { | |
| /// Field id: 517 | ||
| /// The type of files tracked by the manifest, either data or delete files; 0 for all v1 | ||
| /// manifests | ||
| Content content = Content::kData; | ||
| ManifestContent content = ManifestContent::kData; | ||
| /// Field id: 515 | ||
| /// The sequence number when the manifest was added to the table; use 0 when reading v1 | ||
| /// manifest lists | ||
|
|
@@ -218,21 +218,21 @@ struct ICEBERG_EXPORT ManifestList { | |
| }; | ||
|
|
||
| /// \brief Get the relative manifest content type name | ||
| ICEBERG_EXPORT constexpr std::string_view ToString(ManifestFile::Content type) noexcept { | ||
| ICEBERG_EXPORT constexpr std::string_view ToString(ManifestContent type) noexcept { | ||
|
||
| switch (type) { | ||
| case ManifestFile::Content::kData: | ||
| case ManifestContent::kData: | ||
| return "data"; | ||
| case ManifestFile::Content::kDeletes: | ||
| case ManifestContent::kDeletes: | ||
| return "deletes"; | ||
| } | ||
| std::unreachable(); | ||
| } | ||
|
|
||
| /// \brief Get the relative manifest content type from name | ||
| ICEBERG_EXPORT constexpr Result<ManifestFile::Content> ManifestFileContentFromString( | ||
| ICEBERG_EXPORT constexpr Result<ManifestContent> ManifestContentFromString( | ||
|
||
| std::string_view str) noexcept { | ||
| if (str == "data") return ManifestFile::Content::kData; | ||
| if (str == "deletes") return ManifestFile::Content::kDeletes; | ||
| if (str == "data") return ManifestContent::kData; | ||
| if (str == "deletes") return ManifestContent::kDeletes; | ||
| return InvalidArgument("Invalid manifest content type: {}", str); | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.