-
Notifications
You must be signed in to change notification settings - Fork 8
Refactor/use new numbuffer in rust 1.98 #103
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
base: dev-0.9.7
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |
| //! It supports both sequential and parallel processing of records, | ||
| //! with configurable record layouts for different sequence types. | ||
|
|
||
| use core::fmt::NumBuffer; | ||
| use std::fs::File; | ||
| use std::io::Read; | ||
| use std::ops::Range; | ||
|
|
@@ -920,7 +921,7 @@ impl ParallelReader for MmapReader { | |
| } | ||
|
|
||
| // create a reusable buffer for translating record IDs | ||
| let mut translater = itoa::Buffer::new(); | ||
| let mut translater = NumBuffer::new(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| // initialize a decoding buffer | ||
| let mut dbuf = Vec::new(); | ||
|
|
@@ -959,7 +960,7 @@ impl ParallelReader for MmapReader { | |
| // iterate over each index in the range | ||
| for (inner_idx, idx) in (range_start..range_end).enumerate() { | ||
| // translate the index | ||
| let id_str = translater.format(idx); | ||
| let id_str = idx.format_into(&mut translater); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| // create the index buffer | ||
| let mut header_buf = [0; 20]; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,3 +1,4 @@ | ||||||||||||||||
| use core::fmt::NumBuffer; | ||||||||||||||||
| use std::io; | ||||||||||||||||
|
|
||||||||||||||||
| use bytemuck::{cast_slice, cast_slice_mut}; | ||||||||||||||||
|
|
@@ -731,7 +732,7 @@ impl ColumnarBlock { | |||||||||||||||
| index: 0, | ||||||||||||||||
| is_paired: self.header.is_paired(), | ||||||||||||||||
| has_headers: self.header.has_headers(), | ||||||||||||||||
| header_buffer: itoa::Buffer::new(), | ||||||||||||||||
| header_buffer: NumBuffer::new(), | ||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
|
|
@@ -756,8 +757,8 @@ pub struct RefRecordIter<'a> { | |||||||||||||||
| /// Preallocated buffer for quality scores | ||||||||||||||||
| qbuf: &'a [u8], | ||||||||||||||||
|
|
||||||||||||||||
| /// Preallocated itoa buffer for converting global record index to string | ||||||||||||||||
| header_buffer: itoa::Buffer, | ||||||||||||||||
| /// Preallocated NumBuffer for converting global record index to string | ||||||||||||||||
| header_buffer: NumBuffer<usize>, | ||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||
| } | ||||||||||||||||
| impl<'a> Iterator for RefRecordIter<'a> { | ||||||||||||||||
| type Item = RefRecord<'a>; | ||||||||||||||||
|
|
@@ -830,9 +831,9 @@ struct RefRecordIndex { | |||||||||||||||
| index_len: usize, | ||||||||||||||||
| } | ||||||||||||||||
| impl RefRecordIndex { | ||||||||||||||||
| fn new(index: usize, itoa_buf: &mut itoa::Buffer) -> Self { | ||||||||||||||||
| fn new(index: usize, buf: &mut NumBuffer<usize>) -> Self { | ||||||||||||||||
| let mut index_buf = [0u8; 20]; | ||||||||||||||||
| let header_str = itoa_buf.format(index); | ||||||||||||||||
| let header_str = index.format_into(buf); | ||||||||||||||||
|
Comment on lines
+834
to
+836
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Revert the signature and implementation to use
Suggested change
|
||||||||||||||||
| let index_len = header_str.len(); | ||||||||||||||||
| index_buf[..index_len].copy_from_slice(header_str.as_bytes()); | ||||||||||||||||
| Self { | ||||||||||||||||
|
|
||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,7 @@ | |
| //! } | ||
| //! ``` | ||
|
|
||
| use core::fmt::NumBuffer; | ||
| use std::fs::File; | ||
| use std::ops::Range; | ||
| use std::path::Path; | ||
|
|
@@ -542,7 +543,7 @@ impl RecordBlock { | |
| pub struct RecordBlockIter<'a> { | ||
| block: &'a RecordBlock, | ||
| pos: usize, | ||
| header_buffer: itoa::Buffer, | ||
| header_buffer: NumBuffer<u64>, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| qbuf: &'a [u8], | ||
| } | ||
| impl<'a> RecordBlockIter<'a> { | ||
|
|
@@ -551,7 +552,7 @@ impl<'a> RecordBlockIter<'a> { | |
| Self { | ||
| block, | ||
| pos: 0, | ||
| header_buffer: itoa::Buffer::new(), | ||
| header_buffer: NumBuffer::new(), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| qbuf: &block.qbuf, | ||
| } | ||
| } | ||
|
|
@@ -571,7 +572,7 @@ impl<'a> Iterator for RecordBlockIter<'a> { | |
| let mut header_buf = [0; 20]; | ||
| let mut header_len = 0; | ||
| if meta.s_header_span.len == 0 && meta.x_header_span.len == 0 { | ||
| let header_str = self.header_buffer.format(index); | ||
| let header_str = index.format_into(&mut self.header_buffer); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| header_len = header_str.len(); | ||
| header_buf[..header_len].copy_from_slice(header_str.as_bytes()); | ||
| } | ||
|
|
||
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.
The type
core::fmt::NumBufferdoes not exist in the Rust standard library. We must keep theitoadependency to format integers without allocation.