Skip to content

Commit ba39aca

Browse files
committed
fix comments
1 parent b6d4229 commit ba39aca

File tree

4 files changed

+46
-53
lines changed

4 files changed

+46
-53
lines changed

src/iceberg/metadata_update.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ class ICEBERG_EXPORT UpgradeFormatVersion : public MetadataUpdate {
109109
/// \brief Represents adding a new schema to the table
110110
class ICEBERG_EXPORT AddSchema : public MetadataUpdate {
111111
public:
112-
explicit AddSchema(std::shared_ptr<iceberg::Schema> schema, int32_t last_column_id)
112+
explicit AddSchema(std::shared_ptr<Schema> schema, int32_t last_column_id)
113113
: schema_(std::move(schema)), last_column_id_(last_column_id) {}
114114

115-
const std::shared_ptr<iceberg::Schema>& schema() const { return schema_; }
115+
const std::shared_ptr<Schema>& schema() const { return schema_; }
116116

117117
int32_t last_column_id() const { return last_column_id_; }
118118

@@ -125,7 +125,7 @@ class ICEBERG_EXPORT AddSchema : public MetadataUpdate {
125125
void GenerateRequirements(UpdateRequirementsContext& context) const override;
126126

127127
private:
128-
std::shared_ptr<iceberg::Schema> schema_;
128+
std::shared_ptr<Schema> schema_;
129129
int32_t last_column_id_;
130130
};
131131

@@ -151,10 +151,10 @@ class ICEBERG_EXPORT SetCurrentSchema : public MetadataUpdate {
151151
/// \brief Represents adding a new partition spec to the table
152152
class ICEBERG_EXPORT AddPartitionSpec : public MetadataUpdate {
153153
public:
154-
explicit AddPartitionSpec(std::shared_ptr<iceberg::PartitionSpec> spec)
154+
explicit AddPartitionSpec(std::shared_ptr<PartitionSpec> spec)
155155
: spec_(std::move(spec)) {}
156156

157-
const std::shared_ptr<iceberg::PartitionSpec>& spec() const { return spec_; }
157+
const std::shared_ptr<PartitionSpec>& spec() const { return spec_; }
158158

159159
std::unique_ptr<MetadataUpdate> Clone() const override {
160160
return std::make_unique<AddPartitionSpec>(spec_);
@@ -165,7 +165,7 @@ class ICEBERG_EXPORT AddPartitionSpec : public MetadataUpdate {
165165
void GenerateRequirements(UpdateRequirementsContext& context) const override;
166166

167167
private:
168-
std::shared_ptr<iceberg::PartitionSpec> spec_;
168+
std::shared_ptr<PartitionSpec> spec_;
169169
};
170170

171171
/// \brief Represents setting the default partition spec
@@ -230,10 +230,10 @@ class ICEBERG_EXPORT RemoveSchemas : public MetadataUpdate {
230230
/// \brief Represents adding a new sort order to the table
231231
class ICEBERG_EXPORT AddSortOrder : public MetadataUpdate {
232232
public:
233-
explicit AddSortOrder(std::shared_ptr<iceberg::SortOrder> sort_order)
233+
explicit AddSortOrder(std::shared_ptr<SortOrder> sort_order)
234234
: sort_order_(std::move(sort_order)) {}
235235

236-
const std::shared_ptr<iceberg::SortOrder>& sort_order() const { return sort_order_; }
236+
const std::shared_ptr<SortOrder>& sort_order() const { return sort_order_; }
237237

238238
std::unique_ptr<MetadataUpdate> Clone() const override {
239239
return std::make_unique<AddSortOrder>(sort_order_);
@@ -244,7 +244,7 @@ class ICEBERG_EXPORT AddSortOrder : public MetadataUpdate {
244244
void GenerateRequirements(UpdateRequirementsContext& context) const override;
245245

246246
private:
247-
std::shared_ptr<iceberg::SortOrder> sort_order_;
247+
std::shared_ptr<SortOrder> sort_order_;
248248
};
249249

250250
/// \brief Represents setting the default sort order
@@ -269,10 +269,10 @@ class ICEBERG_EXPORT SetDefaultSortOrder : public MetadataUpdate {
269269
/// \brief Represents adding a snapshot to the table
270270
class ICEBERG_EXPORT AddSnapshot : public MetadataUpdate {
271271
public:
272-
explicit AddSnapshot(std::shared_ptr<iceberg::Snapshot> snapshot)
272+
explicit AddSnapshot(std::shared_ptr<Snapshot> snapshot)
273273
: snapshot_(std::move(snapshot)) {}
274274

275-
const std::shared_ptr<iceberg::Snapshot>& snapshot() const { return snapshot_; }
275+
const std::shared_ptr<Snapshot>& snapshot() const { return snapshot_; }
276276

277277
std::unique_ptr<MetadataUpdate> Clone() const override {
278278
return std::make_unique<AddSnapshot>(snapshot_);
@@ -283,7 +283,7 @@ class ICEBERG_EXPORT AddSnapshot : public MetadataUpdate {
283283
void GenerateRequirements(UpdateRequirementsContext& context) const override;
284284

285285
private:
286-
std::shared_ptr<iceberg::Snapshot> snapshot_;
286+
std::shared_ptr<Snapshot> snapshot_;
287287
};
288288

289289
/// \brief Represents removing snapshots from the table

src/iceberg/table_metadata.cc

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
#include "iceberg/file_io.h"
2929
#include "iceberg/json_internal.h"
30+
#include "iceberg/metadata_update.h"
3031
#include "iceberg/partition_spec.h"
3132
#include "iceberg/result.h"
3233
#include "iceberg/schema.h"
@@ -201,47 +202,38 @@ Status TableMetadataUtil::Write(FileIO& io, const std::string& location,
201202

202203
struct TableMetadataBuilder::Impl {
203204
// Base metadata (if building from existing metadata)
204-
std::shared_ptr<const TableMetadata> base;
205+
const TableMetadata* base{nullptr};
205206

206207
// Mutable fields that will be used to build the final TableMetadata
207208
int8_t format_version;
208209
std::string table_uuid;
209210
std::string location;
210-
int64_t last_sequence_number;
211-
TimePointMs last_updated_ms;
212-
int32_t last_column_id;
211+
int64_t last_sequence_number{TableMetadata::kInitialSequenceNumber};
212+
TimePointMs last_updated_ms{std::chrono::milliseconds(0)};
213+
int32_t last_column_id{0};
213214
std::vector<std::shared_ptr<Schema>> schemas;
214215
std::optional<int32_t> current_schema_id;
215216
std::vector<std::shared_ptr<PartitionSpec>> partition_specs;
216-
int32_t default_spec_id;
217-
int32_t last_partition_id;
217+
int32_t default_spec_id{0};
218+
int32_t last_partition_id{0};
218219
std::unordered_map<std::string, std::string> properties;
219-
int64_t current_snapshot_id;
220+
int64_t current_snapshot_id{-1};
220221
std::vector<std::shared_ptr<Snapshot>> snapshots;
221222
std::vector<SnapshotLogEntry> snapshot_log;
222223
std::vector<MetadataLogEntry> metadata_log;
223224
std::vector<std::shared_ptr<SortOrder>> sort_orders;
224-
int32_t default_sort_order_id;
225+
int32_t default_sort_order_id{0};
225226
std::unordered_map<std::string, std::shared_ptr<SnapshotRef>> refs;
226227
std::vector<std::shared_ptr<StatisticsFile>> statistics;
227228
std::vector<std::shared_ptr<PartitionStatisticsFile>> partition_statistics;
228-
int64_t next_row_id;
229+
int64_t next_row_id{TableMetadata::kInitialRowId};
229230

230231
// List of changes (MetadataUpdate objects)
231232
std::vector<std::unique_ptr<MetadataUpdate>> changes;
232233

233-
explicit Impl(int8_t fmt_version)
234-
: format_version(fmt_version),
235-
last_sequence_number(TableMetadata::kInitialSequenceNumber),
236-
last_updated_ms(std::chrono::milliseconds(0)),
237-
last_column_id(0),
238-
default_spec_id(0),
239-
last_partition_id(0),
240-
current_snapshot_id(-1),
241-
default_sort_order_id(0),
242-
next_row_id(TableMetadata::kInitialRowId) {}
243-
244-
explicit Impl(const std::shared_ptr<const TableMetadata>& base_metadata)
234+
explicit Impl(int8_t fmt_version) : format_version(fmt_version) {}
235+
236+
explicit Impl(const TableMetadata* base_metadata)
245237
: base(base_metadata),
246238
format_version(base_metadata->format_version),
247239
table_uuid(base_metadata->table_uuid),
@@ -270,7 +262,7 @@ struct TableMetadataBuilder::Impl {
270262
TableMetadataBuilder::TableMetadataBuilder(int8_t format_version)
271263
: impl_(std::make_unique<Impl>(format_version)) {}
272264

273-
TableMetadataBuilder::TableMetadataBuilder(std::shared_ptr<const TableMetadata> base)
265+
TableMetadataBuilder::TableMetadataBuilder(const TableMetadata* base)
274266
: impl_(std::make_unique<Impl>(base)) {}
275267

276268
TableMetadataBuilder::~TableMetadataBuilder() = default;
@@ -280,21 +272,23 @@ TableMetadataBuilder::TableMetadataBuilder(TableMetadataBuilder&&) noexcept = de
280272
TableMetadataBuilder& TableMetadataBuilder::operator=(TableMetadataBuilder&&) noexcept =
281273
default;
282274

283-
TableMetadataBuilder TableMetadataBuilder::BuildFromEmpty(int8_t format_version) {
284-
return TableMetadataBuilder(format_version);
275+
std::unique_ptr<TableMetadataBuilder> TableMetadataBuilder::BuildFromEmpty(
276+
int8_t format_version) {
277+
return std::unique_ptr<TableMetadataBuilder>(
278+
new TableMetadataBuilder(format_version)); // NOLINT
285279
}
286280

287-
TableMetadataBuilder TableMetadataBuilder::BuildFrom(
288-
const std::shared_ptr<const TableMetadata>& base) {
289-
return TableMetadataBuilder(base);
281+
std::unique_ptr<TableMetadataBuilder> TableMetadataBuilder::BuildFrom(
282+
const TableMetadata* base) {
283+
return std::unique_ptr<TableMetadataBuilder>(new TableMetadataBuilder(base)); // NOLINT
290284
}
291285

292286
TableMetadataBuilder& TableMetadataBuilder::AssignUUID() {
293287
// TODO(gty404): Implement
294288
return *this;
295289
}
296290

297-
TableMetadataBuilder& TableMetadataBuilder::AssignUUID(const std::string& uuid) {
291+
TableMetadataBuilder& TableMetadataBuilder::AssignUUID(std::string_view uuid) {
298292
// TODO(gty404): Implement
299293
return *this;
300294
}

src/iceberg/table_metadata.h

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include <vector>
3030

3131
#include "iceberg/iceberg_export.h"
32-
#include "iceberg/metadata_update.h"
3332
#include "iceberg/type_fwd.h"
3433
#include "iceberg/util/timepoint.h"
3534

@@ -160,14 +159,14 @@ class ICEBERG_EXPORT TableMetadataBuilder {
160159
///
161160
/// \param format_version The format version for the table
162161
/// \return A new TableMetadataBuilder instance
163-
static TableMetadataBuilder BuildFromEmpty(
162+
static std::unique_ptr<TableMetadataBuilder> BuildFromEmpty(
164163
int8_t format_version = TableMetadata::kDefaultTableFormatVersion);
165164

166165
/// \brief Create a builder from existing table metadata
167166
///
168167
/// \param base The base table metadata to build from
169168
/// \return A new TableMetadataBuilder instance initialized with base metadata
170-
static TableMetadataBuilder BuildFrom(const std::shared_ptr<const TableMetadata>& base);
169+
static std::unique_ptr<TableMetadataBuilder> BuildFrom(const TableMetadata* base);
171170

172171
/// \brief Assign a UUID to the table
173172
///
@@ -179,7 +178,7 @@ class ICEBERG_EXPORT TableMetadataBuilder {
179178
///
180179
/// \param uuid The UUID string to assign
181180
/// \return Reference to this builder for method chaining
182-
TableMetadataBuilder& AssignUUID(const std::string& uuid);
181+
TableMetadataBuilder& AssignUUID(std::string_view uuid);
183182

184183
/// \brief Upgrade the format version of the table
185184
///
@@ -192,7 +191,7 @@ class ICEBERG_EXPORT TableMetadataBuilder {
192191
/// \param schema The schema to set as current
193192
/// \param new_last_column_id The highest column ID in the schema
194193
/// \return Reference to this builder for method chaining
195-
TableMetadataBuilder& SetCurrentSchema(std::shared_ptr<iceberg::Schema> schema,
194+
TableMetadataBuilder& SetCurrentSchema(std::shared_ptr<Schema> schema,
196195
int32_t new_last_column_id);
197196

198197
/// \brief Set the current schema by schema ID
@@ -205,14 +204,13 @@ class ICEBERG_EXPORT TableMetadataBuilder {
205204
///
206205
/// \param schema The schema to add
207206
/// \return Reference to this builder for method chaining
208-
TableMetadataBuilder& AddSchema(std::shared_ptr<iceberg::Schema> schema);
207+
TableMetadataBuilder& AddSchema(std::shared_ptr<Schema> schema);
209208

210209
/// \brief Set the default partition spec for the table
211210
///
212211
/// \param spec The partition spec to set as default
213212
/// \return Reference to this builder for method chaining
214-
TableMetadataBuilder& SetDefaultPartitionSpec(
215-
std::shared_ptr<iceberg::PartitionSpec> spec);
213+
TableMetadataBuilder& SetDefaultPartitionSpec(std::shared_ptr<PartitionSpec> spec);
216214

217215
/// \brief Set the default partition spec by spec ID
218216
///
@@ -224,7 +222,7 @@ class ICEBERG_EXPORT TableMetadataBuilder {
224222
///
225223
/// \param spec The partition spec to add
226224
/// \return Reference to this builder for method chaining
227-
TableMetadataBuilder& AddPartitionSpec(std::shared_ptr<iceberg::PartitionSpec> spec);
225+
TableMetadataBuilder& AddPartitionSpec(std::shared_ptr<PartitionSpec> spec);
228226

229227
/// \brief Remove partition specs from the table
230228
///
@@ -242,7 +240,7 @@ class ICEBERG_EXPORT TableMetadataBuilder {
242240
///
243241
/// \param order The sort order to set as default
244242
/// \return Reference to this builder for method chaining
245-
TableMetadataBuilder& SetDefaultSortOrder(std::shared_ptr<iceberg::SortOrder> order);
243+
TableMetadataBuilder& SetDefaultSortOrder(std::shared_ptr<SortOrder> order);
246244

247245
/// \brief Set the default sort order by order ID
248246
///
@@ -254,13 +252,13 @@ class ICEBERG_EXPORT TableMetadataBuilder {
254252
///
255253
/// \param order The sort order to add
256254
/// \return Reference to this builder for method chaining
257-
TableMetadataBuilder& AddSortOrder(std::shared_ptr<iceberg::SortOrder> order);
255+
TableMetadataBuilder& AddSortOrder(std::shared_ptr<SortOrder> order);
258256

259257
/// \brief Add a snapshot to the table
260258
///
261259
/// \param snapshot The snapshot to add
262260
/// \return Reference to this builder for method chaining
263-
TableMetadataBuilder& AddSnapshot(std::shared_ptr<iceberg::Snapshot> snapshot);
261+
TableMetadataBuilder& AddSnapshot(std::shared_ptr<Snapshot> snapshot);
264262

265263
/// \brief Set a branch to point to a specific snapshot
266264
///
@@ -335,7 +333,7 @@ class ICEBERG_EXPORT TableMetadataBuilder {
335333
explicit TableMetadataBuilder(int8_t format_version);
336334

337335
/// \brief Private constructor for building from existing metadata
338-
explicit TableMetadataBuilder(std::shared_ptr<const TableMetadata> base);
336+
explicit TableMetadataBuilder(const TableMetadata* base);
339337

340338
/// Internal state members
341339
struct Impl;

src/iceberg/update_requirement.cc

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

2020
#include "iceberg/update_requirement.h"
2121

22+
#include "iceberg/snapshot.h"
2223
#include "iceberg/table_metadata.h"
2324
#include "iceberg/util/string_util.h"
2425

0 commit comments

Comments
 (0)