-
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.
- Loading branch information
1 parent
1a6b78d
commit 14763ba
Showing
9 changed files
with
130 additions
and
46 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1 +1 @@ | ||
pub mod similarity; | ||
pub mod similarity; |
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
pub(crate) mod fingerprint; | ||
mod index; | ||
mod search; | ||
mod index_item; | ||
pub(crate) mod fingerprint; | ||
mod search; |
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 |
---|---|---|
@@ -1,30 +1,36 @@ | ||
use bincode::{Decode, Encode}; | ||
use crate::ringo::ringo::fingerprint::Fingerprint; | ||
use bincode::{Decode, Encode}; | ||
|
||
#[derive(Debug, Encode, Decode)] | ||
pub struct IndexItem { | ||
pub position: usize, | ||
pub fingerprint: Fingerprint | ||
pub fingerprint: Fingerprint, | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use crate::ringo::ringo::fingerprint::Fingerprint; | ||
use crate::ringo::ringo::index_item::IndexItem; | ||
use bincode::config::standard; | ||
use bincode::{decode_from_slice, encode_to_vec}; | ||
use fixedbitset::FixedBitSet; | ||
use crate::ringo::ringo::index_item::IndexItem; | ||
use crate::ringo::ringo::fingerprint::Fingerprint; | ||
|
||
#[test] | ||
fn test_index_item_encode_decode() { | ||
let fp = Fingerprint(FixedBitSet::with_capacity(512)); | ||
let mut ii = IndexItem {position: 0, fingerprint: fp}; | ||
let mut ii = IndexItem { | ||
position: 0, | ||
fingerprint: fp, | ||
}; | ||
ii.position = 0; | ||
ii.fingerprint.0.set(1, true); | ||
ii.fingerprint.0.set(17, true); | ||
|
||
let encoded = encode_to_vec(&ii, standard()).unwrap(); | ||
let decoded: IndexItem = decode_from_slice(&encoded, standard()).unwrap().0; | ||
assert_eq!(decoded.fingerprint.0.ones().collect::<Vec<usize>>(), vec![1, 17]); | ||
assert_eq!( | ||
decoded.fingerprint.0.ones().collect::<Vec<usize>>(), | ||
vec![1, 17] | ||
); | ||
} | ||
} | ||
} |
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 @@ | ||
|