Skip to content

Commit 6c7f8bf

Browse files
committed
refactor: update Snapshot structure to remove default initializations for optional fields
1 parent bf64a12 commit 6c7f8bf

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/iceberg/snapshot.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,19 +390,19 @@ struct ICEBERG_EXPORT Snapshot {
390390
/// A unique long ID.
391391
int64_t snapshot_id;
392392
/// The snapshot ID of the snapshot's parent. Omitted for any snapshot with no parent.
393-
std::optional<int64_t> parent_snapshot_id = std::nullopt;
393+
std::optional<int64_t> parent_snapshot_id;
394394
/// A monotonically increasing long that tracks the order of changes to a table.
395-
int64_t sequence_number = 0;
395+
int64_t sequence_number;
396396
/// A timestamp when the snapshot was created, used for garbage collection and table
397397
/// inspection.
398-
TimePointMs timestamp_ms{};
398+
TimePointMs timestamp_ms;
399399
/// The location of a manifest list for this snapshot that tracks manifest files with
400400
/// additional metadata.
401401
std::string manifest_list;
402402
/// A string map that summaries the snapshot changes, including operation.
403403
std::unordered_map<std::string, std::string> summary;
404404
/// ID of the table's current schema when the snapshot was created.
405-
std::optional<int32_t> schema_id = std::nullopt;
405+
std::optional<int32_t> schema_id;
406406

407407
/// \brief Create a new Snapshot instance with validation on the inputs.
408408
static Result<std::unique_ptr<Snapshot>> Make(

src/iceberg/test/table_update_test.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,9 +379,12 @@ TEST(TableUpdateTest, SetSnapshotRefApplyUpdate) {
379379
// Add a snapshot that the ref will point to
380380
auto snapshot = std::make_shared<Snapshot>(
381381
Snapshot{.snapshot_id = 123456789,
382+
.parent_snapshot_id = std::nullopt,
382383
.sequence_number = 1,
383384
.timestamp_ms = TimePointMsFromUnixMs(1000000),
384-
.manifest_list = "s3://bucket/manifest-list.avro"});
385+
.manifest_list = "s3://bucket/manifest-list.avro",
386+
.summary = {},
387+
.schema_id = std::nullopt});
385388
builder->AddSnapshot(snapshot);
386389

387390
// Apply SetSnapshotRef update for a branch
@@ -414,9 +417,12 @@ TEST(TableUpdateTest, SetSnapshotRefApplyUpdate) {
414417
// Add a snapshot that the ref will point to
415418
auto snapshot = std::make_shared<Snapshot>(
416419
Snapshot{.snapshot_id = 987654321,
420+
.parent_snapshot_id = std::nullopt,
417421
.sequence_number = 1,
418422
.timestamp_ms = TimePointMsFromUnixMs(2000000),
419-
.manifest_list = "s3://bucket/manifest-list.avro"});
423+
.manifest_list = "s3://bucket/manifest-list.avro",
424+
.summary = {},
425+
.schema_id = std::nullopt});
420426
builder->AddSnapshot(snapshot);
421427

422428
// Apply SetSnapshotRef update for a tag

0 commit comments

Comments
 (0)