-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First working version of the heed based reader
- Loading branch information
1 parent
10c661c
commit cf7f551
Showing
7 changed files
with
121 additions
and
28 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,3 +1,5 @@ | ||
Cargo.lock | ||
/target | ||
/assets/test.tree | ||
*.out | ||
*.tree |
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,11 @@ | ||
#! /bin/bash | ||
|
||
# Runs the classic and heed-based version of Annoy and compare them side-by-side. | ||
# Very useful when you make sure to log the same things in both programs. | ||
|
||
set -v | ||
|
||
cargo run --bin classic > classic.out | ||
cargo run --bin heed > heed.out | ||
|
||
diff --side-by-side classic.out heed.out |
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,17 @@ | ||
use arroy::{ArroyReader, DistanceType}; | ||
|
||
fn main() -> std::io::Result<()> { | ||
let dimensions = 40; | ||
let distance_type = DistanceType::Angular; | ||
let tree = std::fs::read("test.tree").unwrap(); | ||
|
||
let arroy = ArroyReader::new(&tree[..], dimensions, distance_type); | ||
// dbg!(&arroy); | ||
let v = arroy.item_vector(0).unwrap(); | ||
let results = arroy.nns_by_item(0, 3, None).unwrap(); | ||
|
||
println!("{v:?}"); | ||
println!("{results:?}"); | ||
|
||
Ok(()) | ||
} |
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,29 @@ | ||
use arroy::{DistanceType, HeedReader}; | ||
use heed::EnvOpenOptions; | ||
|
||
const TWENTY_HUNDRED_MIB: usize = 200 * 1024 * 1024; | ||
|
||
fn main() -> heed::Result<()> { | ||
let dimensions = 40; | ||
let distance_type = DistanceType::Angular; | ||
let tree = std::fs::read("test.tree").unwrap(); | ||
|
||
let dir = tempfile::tempdir()?; | ||
let env = EnvOpenOptions::new().map_size(TWENTY_HUNDRED_MIB).open(dir.path())?; | ||
|
||
// we will open the default unnamed database | ||
let mut wtxn = env.write_txn()?; | ||
let database = env.create_database(&mut wtxn, None)?; | ||
HeedReader::load_from_tree(&mut wtxn, database, dimensions, distance_type, &tree)?; | ||
wtxn.commit()?; | ||
|
||
let rtxn = env.read_txn()?; | ||
let arroy = HeedReader::new(&rtxn, database, dimensions, distance_type)?; | ||
let v = arroy.item_vector(&rtxn, 0)?.unwrap(); | ||
let results = arroy.nns_by_item(&rtxn, 0, 3, None)?.unwrap(); | ||
|
||
println!("{v:?}"); | ||
println!("{results:?}"); | ||
|
||
Ok(()) | ||
} |
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