Skip to content

Commit ca748bc

Browse files
committed
fix review
1 parent 40b3f71 commit ca748bc

File tree

6 files changed

+19
-29
lines changed

6 files changed

+19
-29
lines changed

src/iceberg/inheritable_metadata.cc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
#include <cassert>
2323
#include <utility>
2424

25-
#include <iceberg/result.h>
26-
2725
#include "iceberg/manifest_entry.h"
2826

2927
namespace iceberg {
@@ -36,7 +34,7 @@ BaseInheritableMetadata::BaseInheritableMetadata(int32_t spec_id, int64_t snapsh
3634
sequence_number_(sequence_number),
3735
manifest_location_(std::move(manifest_location)) {}
3836

39-
Result<ManifestEntry> BaseInheritableMetadata::Apply(ManifestEntry entry) {
37+
Result<ManifestEntry> BaseInheritableMetadata::Apply(ManifestEntry& entry) {
4038
if (!entry.snapshot_id.has_value()) {
4139
entry.snapshot_id = snapshot_id_;
4240
}
@@ -64,14 +62,14 @@ Result<ManifestEntry> BaseInheritableMetadata::Apply(ManifestEntry entry) {
6462
return entry;
6563
}
6664

67-
Result<ManifestEntry> EmptyInheritableMetadata::Apply(ManifestEntry entry) {
65+
Result<ManifestEntry> EmptyInheritableMetadata::Apply(ManifestEntry& entry) {
6866
return entry;
6967
}
7068

7169
CopyInheritableMetadata::CopyInheritableMetadata(int64_t snapshot_id)
7270
: snapshot_id_(snapshot_id) {}
7371

74-
Result<ManifestEntry> CopyInheritableMetadata::Apply(ManifestEntry entry) {
72+
Result<ManifestEntry> CopyInheritableMetadata::Apply(ManifestEntry& entry) {
7573
if (!entry.snapshot_id.has_value()) {
7674
entry.snapshot_id = snapshot_id_;
7775
}

src/iceberg/inheritable_metadata.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ class ICEBERG_EXPORT InheritableMetadata {
4444
virtual ~InheritableMetadata() = default;
4545

4646
/// \brief Apply inheritable metadata to a manifest entry.
47-
/// \param entry The manifest entry to modify.
47+
/// \param entry The manifest entry to modify in-place.
4848
/// \return The modified manifest entry with inherited metadata applied.
49-
virtual Result<ManifestEntry> Apply(ManifestEntry entry) = 0;
49+
virtual Result<ManifestEntry> Apply(ManifestEntry& entry) = 0;
5050
};
5151

5252
/// \brief Base implementation of InheritableMetadata that handles standard inheritance
@@ -62,9 +62,9 @@ class ICEBERG_EXPORT BaseInheritableMetadata : public InheritableMetadata {
6262
std::string manifest_location);
6363

6464
/// \brief Apply inheritance rules to a manifest entry.
65-
/// \param entry The manifest entry to modify.
65+
/// \param entry The manifest entry to modify in-place.
6666
/// \return The modified manifest entry.
67-
Result<ManifestEntry> Apply(ManifestEntry entry) override;
67+
Result<ManifestEntry> Apply(ManifestEntry& entry) override;
6868

6969
private:
7070
int32_t spec_id_;
@@ -77,7 +77,9 @@ class ICEBERG_EXPORT BaseInheritableMetadata : public InheritableMetadata {
7777
class ICEBERG_EXPORT EmptyInheritableMetadata : public InheritableMetadata {
7878
public:
7979
/// \brief Apply no inheritance - returns the entry unchanged.
80-
Result<ManifestEntry> Apply(ManifestEntry entry) override;
80+
/// \param entry The manifest entry (unchanged).
81+
/// \return The manifest entry.
82+
Result<ManifestEntry> Apply(ManifestEntry& entry) override;
8183
};
8284

8385
/// \brief Metadata inheritance for copying manifests before commit.
@@ -88,7 +90,9 @@ class ICEBERG_EXPORT CopyInheritableMetadata : public InheritableMetadata {
8890
explicit CopyInheritableMetadata(int64_t snapshot_id);
8991

9092
/// \brief Apply copy inheritance rules.
91-
Result<ManifestEntry> Apply(ManifestEntry entry) override;
93+
/// \param entry The manifest entry to modify in-place.
94+
/// \return The modified manifest entry.
95+
Result<ManifestEntry> Apply(ManifestEntry& entry) override;
9296

9397
private:
9498
int64_t snapshot_id_;

src/iceberg/manifest_reader.cc

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919

2020
#include "iceberg/manifest_reader.h"
2121

22-
#include "iceberg/file_reader.h"
22+
#include <iceberg/schema_internal.h>
23+
2324
#include "iceberg/manifest_entry.h"
2425
#include "iceberg/manifest_list.h"
2526
#include "iceberg/manifest_reader_internal.h"
@@ -31,16 +32,10 @@ namespace iceberg {
3132
Result<std::unique_ptr<ManifestReader>> ManifestReader::Make(
3233
const ManifestFile& manifest, std::shared_ptr<FileIO> file_io,
3334
std::shared_ptr<Schema> partition_schema) {
34-
// Validate manifest content type - only DATA manifests are supported by ManifestReader
35-
if (manifest.content != ManifestFile::Content::kData) {
36-
return InvalidArgument("Cannot read a delete manifest with a ManifestReader: {}",
37-
manifest.manifest_path);
38-
}
39-
4035
auto manifest_entry_schema = ManifestEntry::TypeFromPartitionType(partition_schema);
41-
auto fields_span = manifest_entry_schema->fields();
42-
std::vector<SchemaField> fields(fields_span.begin(), fields_span.end());
43-
auto schema = std::make_shared<Schema>(fields);
36+
auto schema_unique = FromStructType(std::move(*manifest_entry_schema), std::nullopt);
37+
auto schema = std::shared_ptr<Schema>(std::move(schema_unique));
38+
4439
ICEBERG_ASSIGN_OR_RAISE(
4540
auto reader,
4641
ReaderFactoryRegistry::Open(FileFormatType::kAvro, {.path = manifest.manifest_path,

src/iceberg/manifest_reader.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include <memory>
2626
#include <vector>
2727

28-
#include "iceberg/file_reader.h"
2928
#include "iceberg/iceberg_export.h"
3029
#include "iceberg/manifest_list.h"
3130
#include "iceberg/type_fwd.h"

src/iceberg/manifest_reader_internal.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919

2020
#include "manifest_reader_internal.h"
2121

22-
#include <array>
23-
2422
#include <nanoarrow/nanoarrow.h>
2523

2624
#include "iceberg/arrow_c_data_guard_internal.h"
@@ -30,7 +28,6 @@
3028
#include "iceberg/schema.h"
3129
#include "iceberg/type.h"
3230
#include "iceberg/util/macros.h"
33-
#include "iceberg/util/visit_type.h"
3431

3532
namespace iceberg {
3633

@@ -547,7 +544,7 @@ Result<std::vector<ManifestEntry>> ManifestReaderImpl::Entries() const {
547544

548545
// Apply inheritance to all entries
549546
for (auto& entry : manifest_entries) {
550-
ICEBERG_ASSIGN_OR_RAISE(entry, inheritable_metadata_->Apply(std::move(entry)));
547+
ICEBERG_ASSIGN_OR_RAISE(entry, inheritable_metadata_->Apply(entry));
551548
}
552549

553550
return manifest_entries;

src/iceberg/manifest_reader_internal.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ class ManifestReaderImpl : public ManifestReader {
3838
reader_(std::move(reader)),
3939
inheritable_metadata_(std::move(inheritable_metadata)) {}
4040

41-
ManifestReaderImpl() = default;
42-
4341
Result<std::vector<ManifestEntry>> Entries() const override;
4442

4543
private:
@@ -54,7 +52,6 @@ class ManifestListReaderImpl : public ManifestListReader {
5452
explicit ManifestListReaderImpl(std::unique_ptr<Reader> reader,
5553
std::shared_ptr<Schema> schema)
5654
: schema_(std::move(schema)), reader_(std::move(reader)) {}
57-
ManifestListReaderImpl() = default;
5855

5956
Result<std::vector<ManifestFile>> Files() const override;
6057

0 commit comments

Comments
 (0)