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

fix: Workaround Non-Threadsafe Use of Rc in bam::record::Record #345

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jch-13
Copy link
Contributor

@jch-13 jch-13 commented Feb 2, 2022

Hey all, this is an attempt to work around #293 (for context please see the discussion there).

I simply removed the reference counted reference to HeaderView from BAM Records and impl'ed genome::AbstractInterval on a wrapper type around &Record and &HeaderView. This wrapper type can be constructed like this:

let header = bam_reader.header().clone();
for record in bam_reader.records() {
    let mut rec = record.unwrap();
    // `.contig()` is a member of the `genome::AbstractInterval` trait
    let contig = rec.supply_header(&header).contig();
}

This is not exactly elegant and I don't know the use cases that made references to headers necessary in the first place, so please let me know if this workaround is viable at all.

Edit: I've removed Rc wrappers around HeaderViews as well since I doubt they were actually needed. unsafe Send impls for Reader and Writer had to be removed too because they were unsound.
I hope this does not break a lot of code and I'm not missing anything obvious here... :)

@coveralls
Copy link

coveralls commented Feb 2, 2022

Pull Request Test Coverage Report for Build 1789725128

  • 13 of 21 (61.9%) changed or added relevant lines in 3 files are covered.
  • 6 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.03%) to 94.766%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/bam/buffer.rs 5 8 62.5%
src/bam/record.rs 0 5 0.0%
Files with Coverage Reduction New Missed Lines %
src/bam/record.rs 6 79.68%
Totals Coverage Status
Change from base Build 1484386366: -0.03%
Covered Lines: 11515
Relevant Lines: 12151

💛 - Coveralls

@jch-13 jch-13 changed the title Workaround Non-Threadsafe Use of Rc in bam::record::Record Fix: Workaround Non-Threadsafe Use of Rc in bam::record::Record Feb 3, 2022
@jch-13 jch-13 changed the title Fix: Workaround Non-Threadsafe Use of Rc in bam::record::Record fix: Workaround Non-Threadsafe Use of Rc in bam::record::Record Feb 3, 2022
@johanneskoester
Copy link
Contributor

The use case was to make it convenient to conduct header-requiring operations without having the reader at hand (e.g. in a larger codebase, where passing on the reader would make things unnecessarily complicated). @jch-13, you thing Arc would be an alternative?

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.

3 participants