-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add sequence cache #26
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Some suggestions on a way to avoid an extra db lookup. I think the lookup use of String
will lead to a refactor down the line using this method if we're passing a sequence we want ot reuse from the caller.
pub fn lookup( | ||
sequence_cache: &mut SequenceCache<'a>, | ||
sequence_type: &'a str, | ||
sequence: String, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this will result in ownership issues where String is moved here but not returned out. &String can resolve that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was actually fighting the compiler about this yesterday. I couldn't get it to work with &str. I tried with &String just now and got the same problem, which is that the sequence cache exists outside the for loop that's processing the VCF records. The sequence that's being cached gets created inside that for loop, so any reference to it is transient (could go away from one iteration of the for loop to the next), so the sequence reference can't get added to the cache.
src/main.rs
Outdated
.sequence_type("DNA") | ||
.sequence(&sequence) | ||
.save(sequence_cache.conn); | ||
let new_sequence = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think you can actually do this w/o the additional lookup by using the build
part of the builder to get the sequence object. So you would have the builder object as a var, call save
to get the hash, and build
to get the sequence object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, done!
5f240fb
to
9ea0369
Compare
No description provided.