-
Notifications
You must be signed in to change notification settings - Fork 1
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
Dev igd #9
base: dev
Are you sure you want to change the base?
Dev igd #9
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.
Wrote down some thoughts, but this is awesome!
genimtools/src/igd/create.rs
Outdated
use crate::vocab::consts; | ||
|
||
|
||
pub const maxCount: i64 = 268435456; //16* = 4GB memory // original code had this as i32 |
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.
What about a u32
? RAM can never be negative, right?
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.
Yeah, we should be able to just use u32 instead.
genimtools/src/igd/create.rs
Outdated
// og C code: | ||
// int32_t *nr = calloc(n_files, sizeof(int32_t)); | ||
// double *avg = calloc(n_files, sizeof(double)); | ||
let mut avg: Vec<i32> = Vec::with_capacity(n_files); |
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.
Curious - whats the difference between a Vec::with_capacity
and array
? Is an array only useful when you know the size at compile time?
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.
We actually discussed this (partially) yesterday! I ended up having to use the vec!
macro in some instances because Vec::with_capacity
was not creating vectors of desired lengths. It was simply allocating memory for how large the vector is expected to be come at run time:
The capacity of a vector is the amount of space allocated for any future elements that will be added onto the vector. This is not to be confused with the length of a vector, which specifies the number of actual elements within the vector. If a vector's length exceeds its capacity, its capacity will automatically be increased, but its elements will have to be reallocated.
For example, a vector with capacity 10 and length 0 would be an empty vector with space for 10 more elements. Pushing 10 or fewer elements onto the vector will not change its capacity or cause reallocation to occur. However, if the vector's length is increased to 11, it will have to reallocate, which can be slow. For this reason, it is recommended to use Vec::with_capacity whenever possible to specify how big the vector is expected to get.
…v_igd # Conflicts: # genimtools/src/lib.rs # gtars/src/main.rs
… issue during creation
Works toward: #28 |
This is a draft to aid in discussing work done to convert our IGD tool from C to Rust:
https://github.com/databio/IGD
https://doi.org/10.1093/bioinformatics/btaa1062