Skip to content
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

MRG: adjust Signature::name() to return Option<String> instead of filename() and md5sum() #3434

Merged
merged 19 commits into from
Dec 18, 2024

Conversation

ctb
Copy link
Contributor

@ctb ctb commented Dec 15, 2024

This PR adjusts Signature::name() to return None when no name is set, instead of returning first filename() or (if empty) md5sum(). It also adds name_str() which returns an empty string, to avoid too many unwrap_or scattered throughout the codebase.

Fixes #3441

Copy link

codecov bot commented Dec 15, 2024

Codecov Report

Attention: Patch coverage is 62.50000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 86.42%. Comparing base (635ffc1) to head (9f0702d).
Report is 1 commits behind head on latest.

Files with missing lines Patch % Lines
src/core/src/index/revindex/disk_revindex.rs 33.33% 2 Missing ⚠️
src/core/src/signature.rs 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           latest    #3434      +/-   ##
==========================================
- Coverage   86.44%   86.42%   -0.03%     
==========================================
  Files         137      137              
  Lines       16102    16106       +4     
  Branches     2219     2219              
==========================================
- Hits        13920    13919       -1     
- Misses       1875     1880       +5     
  Partials      307      307              
Flag Coverage Δ
hypothesis-py 25.43% <ø> (ø)
python 92.40% <ø> (ø)
rust 62.11% <62.50%> (-0.11%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -351,7 +351,15 @@ impl RevIndexOps for RevIndex {
.collection
.record_for_dataset(dataset_id)
.expect("dataset not found");
Some((row.name().into(), size))

let mut name = row.name();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is ugly - is there an idiomatic way to do this??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

@luizirber luizirber Dec 17, 2024

Choose a reason for hiding this comment

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

maybe?

let name = [row.name(), row.filename(), row.md5()]
    .into_iter()
    .skip_while(|v| v.is_empty())
    .next()
    .unwrap();  // guaranteed to succeed because `md5` always exists

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeh.... :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in 0ed80c1

@ctb ctb changed the title WIP: make Signature::name() return empty string if name is None MRG: make Signature::name() return empty string if name is None Dec 17, 2024
@ctb
Copy link
Contributor Author

ctb commented Dec 17, 2024

@luizirber @bluegenes ready for review!

@@ -448,10 +448,8 @@ impl Signature {
pub fn name(&self) -> String {
Copy link
Member

Choose a reason for hiding this comment

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

since r0.18.0 is not released yet, do we want to make this
pub fn name(&self) -> Option<String> {
instead? This wil change calls around in other places, but seems to communicate better that the name exists or not instead of getting a .name() call that might return ""

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ooh, I like it! let me give it a try 🙇

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ctb ctb changed the title MRG: make Signature::name() return empty string if name is None MRG: adjust Signature::name() to return Option<String> instead of filename() and md5sum() Dec 17, 2024
@ctb
Copy link
Contributor Author

ctb commented Dec 17, 2024

ready for review @luizirber !

@luizirber luizirber self-requested a review December 18, 2024 17:35
@ctb ctb enabled auto-merge (squash) December 18, 2024 17:51
@ctb ctb disabled auto-merge December 18, 2024 18:20
@ctb ctb merged commit f4f5187 into latest Dec 18, 2024
42 of 44 checks passed
@ctb ctb deleted the fix_intersect_manifest branch December 18, 2024 18:20
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.

Signature::name() returns filename() and then md5sum() if .name is empty.
2 participants