fmt
This commit is contained in:
parent
7c27a20ebd
commit
17446a6318
23
src/db.rs
23
src/db.rs
@ -190,7 +190,9 @@ where
|
||||
let tab_pos: u64 = (index * LEN_SIZE).try_into().str_err()?;
|
||||
let mut pos_curr_data: [u8; LEN_SIZE] = [0; LEN_SIZE];
|
||||
let cur_pos = self.input.stream_position().str_err()? as i64;
|
||||
self.input.seek_relative((tab_pos as i64) - cur_pos).str_err()?;
|
||||
self.input
|
||||
.seek_relative((tab_pos as i64) - cur_pos)
|
||||
.str_err()?;
|
||||
|
||||
self.input.read_exact(&mut pos_curr_data).str_err()?;
|
||||
LSize::from_le_bytes(pos_curr_data)
|
||||
@ -220,7 +222,6 @@ where
|
||||
pub fn iter(&mut self) -> ReaderIter<'_, T> {
|
||||
ReaderIter::new(self)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pub struct ReaderIter<'a, T>
|
||||
@ -316,14 +317,19 @@ mod test {
|
||||
}
|
||||
|
||||
fn gen_data(count: usize) -> impl Iterator<Item = TestData> {
|
||||
(0..count).into_iter().map(|i| TestData{ num: i as u64})
|
||||
(0..count).into_iter().map(|i| TestData { num: i as u64 })
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_write_read() {
|
||||
let dir = tempdir().expect("tempdir");
|
||||
let tmpfile = dir.path().join("test.tmp");
|
||||
let opts = WriterOpts { compress_lvl: 1, data_buf_size: 10 * 1024 * 1024, out_buf_size: 10 * 1024 * 1024, current_buf_size: 4096 };
|
||||
let opts = WriterOpts {
|
||||
compress_lvl: 1,
|
||||
data_buf_size: 10 * 1024 * 1024,
|
||||
out_buf_size: 10 * 1024 * 1024,
|
||||
current_buf_size: 4096,
|
||||
};
|
||||
let mut writer: Writer<TestData> = Writer::new(&tmpfile, opts).expect("new writer");
|
||||
|
||||
let items_iter = gen_data(5);
|
||||
@ -335,7 +341,7 @@ mod test {
|
||||
let mut reader: Reader<TestData> = Reader::new(&tmpfile, 2048).expect("new reader");
|
||||
assert_eq!(items.len(), reader.len());
|
||||
|
||||
for (idx,item) in items.iter().enumerate() {
|
||||
for (idx, item) in items.iter().enumerate() {
|
||||
let ritem = reader.get(idx).expect("get");
|
||||
assert_eq!(*item, ritem);
|
||||
}
|
||||
@ -345,7 +351,12 @@ mod test {
|
||||
fn test_write_read_iter() {
|
||||
let dir = tempdir().expect("tempdir");
|
||||
let tmpfile = dir.path().join("test.tmp");
|
||||
let opts = WriterOpts { compress_lvl: 1, data_buf_size: 10 * 1024 * 1024, out_buf_size: 10 * 1024 * 1024, current_buf_size: 4096 };
|
||||
let opts = WriterOpts {
|
||||
compress_lvl: 1,
|
||||
data_buf_size: 10 * 1024 * 1024,
|
||||
out_buf_size: 10 * 1024 * 1024,
|
||||
current_buf_size: 4096,
|
||||
};
|
||||
let mut writer: Writer<TestData> = Writer::new(&tmpfile, opts).expect("new writer");
|
||||
|
||||
let items_iter = gen_data(10);
|
||||
|
Loading…
Reference in New Issue
Block a user