-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
in-memory index creation with loading
- Loading branch information
Showing
12 changed files
with
281 additions
and
131 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pub mod bits_reader; | ||
pub mod bits_writer; | ||
pub mod terms_reader; | ||
pub mod terms_writer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use std::{ | ||
fs::File, | ||
io::{BufReader, Read}, | ||
}; | ||
|
||
pub struct TermsReader { | ||
file: BufReader<File>, | ||
} | ||
|
||
impl TermsReader { | ||
pub fn new(filename: &str) -> TermsReader { | ||
TermsReader { | ||
file: BufReader::new(File::open(filename).expect("can not open input file")), | ||
} | ||
} | ||
|
||
pub fn read_to_string(&mut self) -> String { | ||
let mut buffer = String::new(); | ||
self.file | ||
.read_to_string(&mut buffer) | ||
.expect("error while reading to string"); | ||
buffer | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use std::{ | ||
fs::File, | ||
io::{BufWriter, Write}, | ||
}; | ||
|
||
pub struct TermsWriter { | ||
file: BufWriter<File>, | ||
} | ||
|
||
impl TermsWriter { | ||
pub fn new(filename: &str) -> TermsWriter { | ||
TermsWriter { | ||
file: BufWriter::new(File::create(filename).expect("Can not create output file")), | ||
} | ||
} | ||
|
||
pub fn write_term(&mut self, term: &str) { | ||
self.file | ||
.write_all(term.as_bytes()) | ||
.expect("error while writing term to file"); | ||
} | ||
|
||
pub fn flush(&mut self) { | ||
self.file | ||
.flush() | ||
.expect("error while flushing BufWriter buffer"); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.