Skip to content

Merge take_snapshot and take_partial_snapshot methods#6232

Merged
ffuugoo merged 4 commits intodevfrom
refactor-take-partial-snapshot
Mar 26, 2025
Merged

Merge take_snapshot and take_partial_snapshot methods#6232
ffuugoo merged 4 commits intodevfrom
refactor-take-partial-snapshot

Conversation

@ffuugoo
Copy link
Contributor

@ffuugoo ffuugoo commented Mar 24, 2025

This PR merges ShardReplicaSet::take_snapshot and ShardReplicaSet::take_partial_snapshot methods. They are very similar to each other, and it's easier (on the HTTP API level) to call a single method instead of two separate ones.

This PR adds manifest parameter to take_snapshot and logic that creates a partial snapshot (instead of a regular one) based on this parameter, but it's not yet propagated into take_snapshot (it will be done in yet another PR, that will add partial snapshot API endpoints), so it always creates a regular snapshot.

All Submissions:

  • Contributions should target the dev branch. Did you create your branch from dev?
  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  1. Does your submission pass tests?
  2. Have you formatted your code locally using cargo +nightly fmt --all command prior to submission?
  3. Have you checked your code using cargo clippy --all --all-features command?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@ffuugoo ffuugoo requested review from generall and timvisee March 24, 2025 15:51
@coderabbitai

This comment was marked as resolved.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
lib/collection/src/collection_manager/holders/proxy_segment.rs (1)

1302-1332: Ensure partial snapshot logic and error handling are clear.

This new take_snapshot implementation straightforwardly delegates to both wrapped_segment and write_segment. Consider these points:

  • If snapshot creation fails for one segment, there is no fallback or rollback mechanism.
  • Currently, partial snapshot is not fully implemented (consistent with PR objectives).
  • You may want additional logs or error-handling steps to clarify partial snapshot progress and potential failures.
lib/segment/src/segment/snapshot.rs (1)

129-218: get_segment_manifest: versioning logic is thorough.

  1. Collects and version-tags files meticulously, ensuring unversioned entries do not override versioned entries.
  2. Inserts “”unversioned” placeholders for RocksDB references.
  3. Includes a TODO for RocksDB versioning, which may be worth exploring soon to ensure complete partial snapshot coverage.

Overall, the logic is clear and consistent, though be mindful of the performance impact if the file set is large.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9a445a7 and ef854be.

📒 Files selected for processing (10)
  • lib/collection/src/collection_manager/holders/proxy_segment.rs (4 hunks)
  • lib/collection/src/collection_manager/holders/segment_holder.rs (2 hunks)
  • lib/segment/src/data_types/segment_manifest.rs (2 hunks)
  • lib/segment/src/entry/entry_point.rs (2 hunks)
  • lib/segment/src/entry/mod.rs (1 hunks)
  • lib/segment/src/entry/snapshot_entry.rs (1 hunks)
  • lib/segment/src/segment/entry.rs (2 hunks)
  • lib/segment/src/segment/mod.rs (3 hunks)
  • lib/segment/src/segment/partial_snapshot.rs (0 hunks)
  • lib/segment/src/segment/snapshot.rs (2 hunks)
💤 Files with no reviewable changes (1)
  • lib/segment/src/segment/partial_snapshot.rs
🧰 Additional context used
🧬 Code Definitions (4)
lib/segment/src/data_types/segment_manifest.rs (4)
lib/collection/src/collection_manager/holders/segment_holder.rs (3)
  • get (99-104)
  • get (308-312)
  • is_empty (178-180)
lib/collection/src/collection_manager/holders/proxy_segment.rs (2)
  • is_empty (930-932)
  • is_empty (1380-1382)
lib/segment/src/entry/entry_point.rs (1)
  • is_empty (218-218)
lib/segment/src/segment/entry.rs (1)
  • is_empty (428-430)
lib/collection/src/collection_manager/holders/proxy_segment.rs (5)
lib/segment/src/segment/snapshot.rs (1)
  • take_snapshot (29-100)
lib/segment/src/entry/snapshot_entry.rs (1)
  • take_snapshot (16-23)
lib/collection/src/collection_manager/optimizers/indexing_optimizer.rs (1)
  • temp_path (247-249)
lib/collection/src/collection_manager/optimizers/vacuum_optimizer.rs (1)
  • temp_path (174-176)
lib/collection/src/collection_manager/optimizers/config_mismatch_optimizer.rs (1)
  • temp_path (223-225)
lib/segment/src/segment/mod.rs (1)
lib/segment/src/common/operation_error.rs (1)
  • service_error (84-89)
lib/segment/src/segment/snapshot.rs (10)
lib/segment/src/vector_storage/vector_storage_base.rs (2)
  • files (85-85)
  • files (723-749)
lib/collection/src/collection_manager/holders/proxy_segment.rs (4)
  • take_snapshot (1303-1332)
  • collect_segment_manifests (1334-1346)
  • version (355-360)
  • version (1411-1416)
lib/segment/src/entry/snapshot_entry.rs (2)
  • take_snapshot (16-23)
  • collect_segment_manifests (25-25)
lib/segment/src/data_types/segment_manifest.rs (1)
  • version (12-16)
lib/segment/src/index/vector_index_base.rs (2)
  • files (37-37)
  • files (194-208)
lib/segment/src/id_tracker/id_tracker_base.rs (2)
  • files (163-163)
  • files (390-397)
lib/segment/src/index/payload_index_base.rs (1)
  • files (151-151)
lib/segment/src/payload_storage/payload_storage_base.rs (1)
  • files (76-76)
lib/segment/src/vector_storage/quantized/quantized_vectors.rs (1)
  • files (202-215)
lib/segment/src/segment/entry.rs (1)
  • version (35-37)
⏰ Context from checks skipped due to timeout of 90000ms (13)
  • GitHub Check: Basic TLS/HTTPS tests
  • GitHub Check: test-snapshot-operations-s3-minio
  • GitHub Check: test-shard-snapshot-api-s3-minio
  • GitHub Check: test-low-resources
  • GitHub Check: test-consistency
  • GitHub Check: test (macos-latest)
  • GitHub Check: test
  • GitHub Check: test (windows-latest)
  • GitHub Check: test-consensus
  • GitHub Check: test-consensus-compose
  • GitHub Check: test (ubuntu-latest)
  • GitHub Check: test
  • GitHub Check: test
🔇 Additional comments (28)
lib/segment/src/entry/mod.rs (2)

2-2: Module renaming looks good.

The change from partial_snapshot_entry to snapshot_entry reflects the consolidation of snapshot functionality described in the PR objectives.


4-5: Appropriate public exports added.

Good addition of public exports for SegmentEntry and SnapshotEntry, making them directly accessible from the entry module. This improves the API's usability.

lib/collection/src/collection_manager/holders/segment_holder.rs (2)

21-21: Added necessary import for SegmentManifests.

Good addition of the import for SegmentManifests, which is required for the updated snapshot method signature.


1358-1364: Method call updated with the new parameter.

The take_snapshot method call has been updated to include a default SegmentManifests instance, aligning with the method signature changes. This is a good implementation of the PR's objective to merge the snapshot methods.

lib/segment/src/data_types/segment_manifest.rs (3)

36-38: Method reordering looks good.

The get method has been reordered within the implementation. The functionality remains unchanged, which is appropriate.


40-42: Useful helper method added.

The is_empty method provides a convenient way to check if there are any manifests present. This is a good addition that will help with conditional logic in the snapshot implementation.


53-59: Good utility method for creating empty manifests.

The empty method provides a clean way to create an empty manifest with a specified segment ID. This will be useful for initializing new manifests without redundant code.

lib/segment/src/entry/snapshot_entry.rs (3)

10-10: Good trait renaming.

Renaming from PartialSnapshotEntry to SnapshotEntry reflects the consolidation of snapshot functionality as described in the PR objectives.


11-16: Clear and comprehensive documentation.

The added documentation clearly explains the purpose and functionality of the take_snapshot method. This is particularly important given the method signature changes.


20-22: Method signature updated correctly with new parameters.

The method signature has been updated to include the format and manifest parameters, properly implementing the PR's objective to merge the snapshot methods.

lib/segment/src/segment/entry.rs (2)

2-2: Remove unused import for efficiency

It appears that only PathBuf is needed here, so removing other std::path imports helps keep the module focused and free of clutter.


28-28: Add new imports for extended type usage

Importing VectorDataInfo, VectorName, and others aligns with their usage in the segment implementation. This change keeps the code organized.

lib/segment/src/segment/mod.rs (4)

10-10: Expose snapshot module publicly

Changing mod snapshot to pub mod snapshot makes snapshot functionality available outside this module. This is beneficial for broader integration.


17-17: Import both Path and PathBuf

Adding Path is a sensible change, enabling direct usage in functions that manipulate filesystem paths.


27-27: Update imports to include OperationError

Importing OperationError enables clearer error handling practices within this module.


120-130: Introduce destroy_rocksdb function

This function cleanly destroys a RocksDB instance at a given path and translates any failure into OperationError. Consider ensuring it’s only called when the DB is no longer in use to avoid concurrency issues.

lib/segment/src/entry/entry_point.rs (4)

2-2: Import only PathBuf

Restricting the import to PathBuf helps keep imports minimal and consistent with usage in this file.


15-15: Use the new SnapshotEntry trait

Switching from PartialSnapshotEntry to SnapshotEntry aligns with the consolidated snapshot logic across the codebase.


22-23: Refine import list for type usage

Including the newly introduced or reorganized types supports the updated snapshot-based workflow.


29-29: Adopt unified snapshot approach

Having SegmentEntry directly extend SnapshotEntry centralizes the snapshot functionality and makes future enhancements more straightforward.

lib/collection/src/collection_manager/holders/proxy_segment.rs (1)

21-21: Import for implementing the SnapshotEntry trait.

This import is necessary for the subsequent implementation of the SnapshotEntry trait and looks correct.

lib/segment/src/segment/snapshot.rs (7)

1-21: Imports for snapshot functionality and dependencies.

These new imports (including HashMap, HashSet, Deref, and SnapshotFormat) are appropriate for the snapshot implementation and appear consistent with the rest of the file.


28-101: Review the newly introduced take_snapshot method.

  1. The logic correctly prevents multiple snapshots of the same segment by using snapshotted_segments.
  2. The segment is flushed before snapshotting to ensure a consistent state.
  3. The partial snapshot path starts to appear if manifest is not empty—even though partial logic is still evolving, this is a suitable placeholder.
  4. The Ancient format is explicitly unsupported with a debug assertion and returns a helpful error.

Overall, this method effectively handles fundamental snapshot creation. In the future, consider concurrency and performance implications of synchronous flushes for large segments.


102-106: Simple collect_segment_manifests function.

This function adds the segment’s manifest into the provided SegmentManifests map. The approach is minimal and matches the trait's requirement.


108-127: segment_id for extracting UUID from path.

Validates the segment directory name as a UUID and returns an error if not. This check is robust and prevents ambiguous or invalid segment naming.


220-238: Comprehensive file gathering in files.

This enumerates vector data, index data, payloads, and the ID tracker to generate a complete file list. The approach is straightforward and essential for snapshot consistency.


240-258: versioned_files aligns well with the unversioned files method.

Mirrors the logic of files, but incorporates specific version tracking from each component. This design fosters future partial snapshot enhancements.


368-397: updated_files method for partial snapshot detection.

Compares file versions between the old manifest and the current one to detect changes. This is crucial for deciding which files to include in partial snapshots. The logic is clear and well-structured.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
lib/segment/tests/integration/segment_on_disk_snapshot.rs (1)

158-166: Consider adding a test for partial snapshots.

While the current implementation uses SegmentManifests::default() for regular snapshots, it would be beneficial to add a test case that exercises the partial snapshot functionality once it's implemented.

// Example test case to add in the future:
#[test]
fn test_partial_snapshot() {
    // Setup similar to existing tests
    
    // Create a non-default manifest for partial snapshot
    let partial_manifest = SegmentManifests::new_partial(...);
    
    // Take a partial snapshot
    segment.take_snapshot(
        temp_dir.path(),
        &tar,
        format,
        &partial_manifest,
        &mut HashSet::new(),
    ).unwrap();
    
    // Verify partial snapshot behavior
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 557b9d5 and 0311f59.

📒 Files selected for processing (2)
  • lib/segment/src/segment/tests.rs (2 hunks)
  • lib/segment/tests/integration/segment_on_disk_snapshot.rs (2 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
lib/segment/tests/integration/segment_on_disk_snapshot.rs (1)
lib/segment/src/segment_constructor/segment_builder.rs (1)
  • new (76-157)
⏰ Context from checks skipped due to timeout of 90000ms (13)
  • GitHub Check: test-snapshot-operations-s3-minio
  • GitHub Check: test-low-resources
  • GitHub Check: test-shard-snapshot-api-s3-minio
  • GitHub Check: Basic TLS/HTTPS tests
  • GitHub Check: test-consistency
  • GitHub Check: test-consensus-compose
  • GitHub Check: test (macos-latest)
  • GitHub Check: test
  • GitHub Check: test (windows-latest)
  • GitHub Check: test-consensus
  • GitHub Check: test
  • GitHub Check: test (ubuntu-latest)
  • GitHub Check: test
🔇 Additional comments (6)
lib/segment/src/segment/tests.rs (3)

15-15: LGTM: New import for SegmentManifests is correctly added.

This import aligns with the PR objective of unifying take_snapshot and take_partial_snapshot methods by introducing a manifest parameter.


17-17: LGTM: Correctly importing SnapshotEntry trait.

Using the underscore suffix in the import statement is the proper way to import a trait solely for its methods.


211-216: LGTM: Updated method call with the new manifest parameter.

The take_snapshot method call is correctly updated to include the new &SegmentManifests::default() parameter. This aligns with the PR objective of unifying the snapshot methods.

lib/segment/tests/integration/segment_on_disk_snapshot.rs (3)

9-9: LGTM: Appropriate import for SegmentManifests added.

Added the necessary import for the SegmentManifests type which is now required for the updated take_snapshot method.


12-12: LGTM: Correctly importing SnapshotEntry trait.

The use of the underscore suffix in use segment::entry::snapshot_entry::SnapshotEntry as _; properly imports the trait methods.


159-165: LGTM: Updated take_snapshot method call with manifest parameter.

The method call has been correctly updated to include the new &SegmentManifests::default() parameter, consistent with the PR objective of unifying the snapshot methods.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
lib/segment/src/segment/snapshot.rs (2)

80-85: Consider removing debug_assert for unsupported format

The debug_assert!(false, ...) pattern is unusual here. Since the code already returns an error for unsupported formats, the assertion adds little value and could be removed.

 match format {
     SnapshotFormat::Ancient => {
-        debug_assert!(false, "Unsupported snapshot format: {format:?}");
         return Err(OperationError::service_error(format!(
             "Unsupported snapshot format: {format:?}"
         )));
     }

206-211:

Details

❓ Verification inconclusive

Consider addressing RocksDB versioning TODO

There's a TODO indicating RocksDB versioning is needed, but the code adds RocksDB files with FileVersion::Unversioned. While this works for now, it might be worth creating a more structured roadmap for implementing proper RocksDB versioning in the future.


🏁 Script executed:

#!/bin/bash
# Check if there are any other TODOs or discussions about RocksDB versioning
rg -i "version.*rocksdb|rocksdb.*version" --type rust

Length of output: 906


Action: Plan a structured roadmap for RocksDB versioning

In lib/segment/src/segment/snapshot.rs (lines 206–211), the code assigns FileVersion::Unversioned to RocksDB virtual files and leaves a TODO regarding versioning. Although this temporary solution works, it’s advisable to outline a clear roadmap for implementing proper RocksDB versioning in the future—especially since similar versioning-related discussions exist in other modules (e.g., common/rocksdb_wrapper.rs and some id tracker files).

  • Verify if a dedicated issue or roadmap exists for RocksDB versioning.
  • If not, consider opening an issue to track and plan the transition to a versioned approach.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0311f59 and 3cf94f6.

📒 Files selected for processing (12)
  • lib/collection/src/collection_manager/holders/proxy_segment.rs (4 hunks)
  • lib/collection/src/collection_manager/holders/segment_holder.rs (2 hunks)
  • lib/segment/src/data_types/segment_manifest.rs (2 hunks)
  • lib/segment/src/entry/entry_point.rs (2 hunks)
  • lib/segment/src/entry/mod.rs (1 hunks)
  • lib/segment/src/entry/snapshot_entry.rs (1 hunks)
  • lib/segment/src/segment/entry.rs (2 hunks)
  • lib/segment/src/segment/mod.rs (3 hunks)
  • lib/segment/src/segment/partial_snapshot.rs (0 hunks)
  • lib/segment/src/segment/snapshot.rs (2 hunks)
  • lib/segment/src/segment/tests.rs (2 hunks)
  • lib/segment/tests/integration/segment_on_disk_snapshot.rs (2 hunks)
💤 Files with no reviewable changes (1)
  • lib/segment/src/segment/partial_snapshot.rs
🚧 Files skipped from review as they are similar to previous changes (6)
  • lib/segment/src/entry/mod.rs
  • lib/segment/src/data_types/segment_manifest.rs
  • lib/collection/src/collection_manager/holders/segment_holder.rs
  • lib/segment/src/segment/tests.rs
  • lib/segment/src/entry/snapshot_entry.rs
  • lib/segment/tests/integration/segment_on_disk_snapshot.rs
🧰 Additional context used
🧬 Code Definitions (2)
lib/collection/src/collection_manager/holders/proxy_segment.rs (1)
lib/segment/src/entry/snapshot_entry.rs (1)
  • take_snapshot (16-23)
lib/segment/src/segment/mod.rs (1)
lib/segment/src/common/operation_error.rs (1)
  • service_error (84-89)
⏰ Context from checks skipped due to timeout of 90000ms (13)
  • GitHub Check: Basic TLS/HTTPS tests
  • GitHub Check: test-snapshot-operations-s3-minio
  • GitHub Check: test-shard-snapshot-api-s3-minio
  • GitHub Check: test-low-resources
  • GitHub Check: test-consistency
  • GitHub Check: test (macos-latest)
  • GitHub Check: test-consensus
  • GitHub Check: test (windows-latest)
  • GitHub Check: test-consensus-compose
  • GitHub Check: test (ubuntu-latest)
  • GitHub Check: test
  • GitHub Check: test
  • GitHub Check: test
🔇 Additional comments (21)
lib/segment/src/segment/entry.rs (1)

2-2: Appropriate removal of unused Path import.

The import of Path is no longer needed as the take_snapshot method (that used &Path in its signature) has been removed from this implementation as part of consolidating snapshot functionality.

lib/segment/src/segment/mod.rs (4)

10-10: Exposing the snapshot module as public is well-aligned with the PR goal.

Making the snapshot module public is necessary to allow external code to access the consolidated snapshot implementation, which supports the PR objective of merging the snapshot methods.


17-17: Appropriate import change to include Path.

Adding Path to the import is necessary for the new destroy_rocksdb function parameter.


27-27: Good addition of OperationError import.

This import is needed for the new destroy_rocksdb function to create and return operation errors.


121-130: Well-implemented utility function for RocksDB cleanup.

The destroy_rocksdb function provides a clean way to handle RocksDB instance cleanup, which is likely used in the new snapshot implementation. The error handling is robust, converting RocksDB errors to operation errors with descriptive messages.

lib/segment/src/entry/entry_point.rs (3)

2-2: Appropriate removal of Path import.

The Path import is no longer needed since the take_snapshot method (which used this type) has been removed from the SegmentEntry trait.


15-15: Good transition from PartialSnapshotEntry to SnapshotEntry.

Updating the import to use SnapshotEntry instead of PartialSnapshotEntry supports the PR goal of consolidating snapshot functionality.


29-29: Well-designed trait inheritance change.

Changing the trait inheritance from PartialSnapshotEntry to SnapshotEntry centralizes the snapshot functionality in a single trait, which aligns perfectly with the PR goal of merging the snapshot methods.

lib/collection/src/collection_manager/holders/proxy_segment.rs (7)

21-21: Good update to import SnapshotEntry instead of PartialSnapshotEntry.

This change correctly updates the import to match the new trait inheritance structure, supporting the consolidated snapshot approach.


1308-1309: Well-implemented trait change from PartialSnapshotEntry to SnapshotEntry.

The implementation correctly transitions from implementing PartialSnapshotEntry to implementing SnapshotEntry, which is necessary for the consolidated snapshot functionality.


1310-1316: Successfully updated method signature to include manifest parameter.

The take_snapshot method signature has been properly updated to include the new manifest parameter, as required by the PR objectives.


1317-1318: Good addition of logging for improved debugging.

Adding a log message at the beginning of the method provides useful context for debugging snapshot operations on proxy segments.


1319-1326: Correctly passing manifest to wrapped segment.

The implementation properly passes the new manifest parameter to the wrapped segment's take_snapshot method, ensuring consistent snapshot behavior.


1328-1336: Correctly passing manifest to write segment.

The implementation properly passes the new manifest parameter to the write segment's take_snapshot method, ensuring consistent snapshot behavior across all components.


1888-1888: Tests correctly updated to include manifest parameter.

The test cases have been properly updated to include the &SegmentManifests::default() parameter when calling take_snapshot, ensuring that the tests continue to work with the new method signature.

Also applies to: 1897-1897

lib/segment/src/segment/snapshot.rs (6)

34-35: Good addition of the manifest parameter for supporting partial snapshots

The implementation aligns with the PR objectives to merge take_snapshot and take_partial_snapshot methods. The new manifest parameter allows for conditional file inclusion based on file versions, which is essential for partial snapshots.


49-69: Well-implemented conditional file inclusion logic

This code elegantly handles both regular and partial snapshots through the same method. When manifest is empty, it creates a regular snapshot with all files. Otherwise, it determines which files have changed since the previous snapshot by comparing file versions, enabling the partial snapshot functionality.


102-105: Good implementation of manifest collection

The collect_segment_manifests method is a clean and straightforward implementation that builds upon the existing get_segment_manifest functionality. This helps maintain a consistent approach to manifest handling throughout the codebase.


109-127: Well-structured segment_id extraction with validation

The method correctly extracts the segment ID from the path with proper error handling. The debug assertion validates that the ID is a valid UUID, which is a good safeguard against potential issues. Consider adding this validation in production builds too.


136-142: Excellent documentation for versioning logic

The implementation includes detailed comments explaining the complex versioning logic, which makes the code much more maintainable. These comments clearly document the expected behavior and edge cases, which is particularly valuable for this critical component.

Also applies to: 165-173


368-397: Well-implemented file comparison logic

The updated_files function provides a clear implementation for determining which files should be included in a partial snapshot. The detailed comments explaining the inclusion criteria make the logic easy to understand. The comparison of different version types (unversioned vs. versioned) is handled elegantly.

Comment on lines +71 to +74
let mut empty_manifest = None;
let request_manifest = manifest
.get(segment_id)
.unwrap_or_else(|| empty_manifest.insert(SegmentManifest::empty(segment_id)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really get how this works. Shouldn't we take out the empty_manifest in between changing it to:

                let request_manifest = manifest
                    .get(segment_id)
                    .unwrap_or_else(|| SegmentManifest::empty(segment_id));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

manifest is Option<&SegmentManifest>. We can't return &SegmentManifest::empty(...) from unwrap_or_else, so we either have to clone manifest or use this trick to conditionally initialize empty manifest (into empty_manifest variable) and return reference to this empty manifest from unwrap_or_else call.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I get it, it's because of the reference.

Construction of SegmentManifest::empty(segment_id) is cheap though, it's only a &str -> String.

@ffuugoo ffuugoo merged commit 553bce4 into dev Mar 26, 2025
17 checks passed
@ffuugoo ffuugoo deleted the refactor-take-partial-snapshot branch March 26, 2025 15:46
@coderabbitai coderabbitai bot mentioned this pull request Mar 26, 2025
9 tasks
@ffuugoo ffuugoo added this to the Partial Snapshots milestone May 30, 2025
This was referenced Oct 14, 2025
This was referenced Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants