-
Notifications
You must be signed in to change notification settings - Fork 70
feat: add manifest&manifest list writer #176
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
Conversation
src/iceberg/manifest_writer.cc
Outdated
| case 1: | ||
| return std::make_unique<ManifestListWriterV1>(snapshot_id, parent_snapshot_id, | ||
| std::move(writer), std::move(schema)); | ||
| case 2: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sequence_number is required for V2 manifest list, so here needs check validation for v2?
|
What about this? // Implemented by different versions with different schemas to
// append a list of `ManifestFile`s to an `ArrowArray`.
class ManifestFileAdapter {
public:
virtual Status StartAppending() const = 0;
virtual Status Append(const ManifestFile& file) const = 0;
virtual Result<ArrowArray> FinishAppending() const = 0;
int64_t size() const { return size_; }
private:
std::shared_ptr<Schema> manifest_list_schema_;
ArrowSchema schema_; // converted from manifest_list_schema_
ArrowArray array_; // array to append `ManifestFile`s
int64_t size_;
};
class ICEBERG_EXPORT ManifestListWriter {
public:
static Result<std::unique_ptr<ManifestListWriter>> Make(
std::string_view manifest_list_location, std::shared_ptr<FileIO> file_io,
const std::unordered_map<std::string, std::string>& meta);
Status AddAll(const std::vector<ManifestFile>& files) const {
for (const auto& file : files) {
Add(file);
}
return {};
}
Status Add(const ManifestFile& file) const {
if (adapter_->size() >= kBatchSize) {
ICEBERG_ASSIGN_OR_RAISE(auto array, adapter_->FinishAppending());
ICEBERG_RETURN_UNEXPECTED(writer_->Write(array));
ICEBERG_RETURN_UNEXPECTED(adapter_->StartAppending());
}
return adapter_->Append(file);
}
Status Close() const;
private:
static constexpr int64_t kBatchSize = 1024;
std::unique_ptr<Writer> writer_;
std::unique_ptr<ManifestFileAdapter> adapter_;
}; |
The latest patch add a new header for this adapter at src/iceberg/metadata_adapter.h. |
9bbfb78 to
0b17e28
Compare
wgtmac
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
Left some nits.
1 add v1v2v3 writer definition 2
bd69a16 to
6be5965
Compare
1 add v1v2v3 writer definition
2 add v1v2v3 metadata wrapper