Skip to content

Commit

Permalink
increase size of compression buffer on very large arrays
Browse files Browse the repository at this point in the history
closes #12
  • Loading branch information
brentp committed Feb 26, 2022
1 parent c7cc03f commit 8f7596f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
v0.1.3
======
+ exit with error on multi-allelics (previously, only first allele was used) ( #11)
+ more docs on conf file (thanks @m-pauper)
+ fix compression error for very dense regions (#12)

v0.1.2
======
+ fix #8. bug introduced for string values.
Expand Down
16 changes: 15 additions & 1 deletion src/commands/encoder_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ pub fn encoder_main(vpaths: Vec<&str>, opath: &str, jpath: &str) {
)
.ok();

let mut compressed = vec![0u8; 50_000_000]; // TODO: set this based on values.len
let mut compressed = vec![0u8; 50_000_000];
let mut last_rid: i32 = -1;
let mut last_mod: i64 = 0;

Expand Down Expand Up @@ -284,6 +284,13 @@ pub fn encoder_main(vpaths: Vec<&str>, opath: &str, jpath: &str) {
zipf.start_file(fname, options)
.expect("error starting file");
sort_by_indices(values, indexes.clone());
if compressed.len() < 5 * values.len() {
eprintln!(
"[echtvar] resizing compressed array to: {}",
5 * values.len()
);
compressed.resize(5 * values.len(), 0x0);
}
write_bits(values, false, &mut zipf, &mut compressed);
values.clear();
}
Expand Down Expand Up @@ -396,6 +403,13 @@ pub fn encoder_main(vpaths: Vec<&str>, opath: &str, jpath: &str) {
zipf.start_file(fname, options)
.expect("error starting file");
sort_by_indices(values, indexes.clone());
if compressed.len() < 5 * values.len() {
eprintln!(
"[echtvar] resizing compressed array to: {}",
5 * values.len()
);
compressed.resize(5 * values.len(), 0x0);
}
write_bits(values, false, &mut zipf, &mut compressed);
values.clear();
}
Expand Down

0 comments on commit 8f7596f

Please sign in to comment.