Skip to content

Commit

Permalink
feat: add from_file API
Browse files Browse the repository at this point in the history
  • Loading branch information
yankun1992 committed Dec 4, 2023
1 parent 3d57d80 commit 465fca5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
1 change: 1 addition & 0 deletions fastbloom-rs/src/bloom.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::cmp::min;
use std::fs::{File, OpenOptions};
use std::fs;
use std::io::{Write, Read};
use std::ptr::slice_from_raw_parts;

Expand Down
13 changes: 3 additions & 10 deletions fastbloom-rs/src/vec.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use core::slice;
use std::{fs::File, os::windows::fs::FileExt};
use std::{fs::File, io::{Read, Seek}};

use crate::builder::SUFFIX;

Expand Down Expand Up @@ -49,15 +49,8 @@ impl BloomBitVec {
slice::from_raw_parts_mut(buf, bytes_len.try_into().unwrap())
};

let mut cursor = seek;
let mut read = 0u64;

while read < bytes_len {
let size = file.seek_read(&mut buf[read as usize ..], cursor).unwrap() as u64;
read = read + size;
cursor += size;
}

file.seek(std::io::SeekFrom::Start(seek)).unwrap();
file.read_exact(buf).unwrap();

BloomBitVec {
storage,
Expand Down

0 comments on commit 465fca5

Please sign in to comment.