Skip to content

Commit

Permalink
Use the INTEGER_KEY database flag to gain (a little bit of) space
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerollmops committed Nov 26, 2023
1 parent 034d231 commit cb32175
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
[dependencies]
bytemuck = { version = "1.14.0", features = ["derive", "extern_crate_alloc"] }
byteorder = "1.5.0"
heed = "0.20.0-alpha.7"
heed = "0.20.0-alpha.8"
ordered-float = "4.1.1"
rand = { version = "0.8.5", features = ["alloc"] }
thiserror = "1.0.50"
Expand Down
8 changes: 5 additions & 3 deletions examples/compare_with_hnsw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ fn main() -> Result<()> {
eprintln!("took {:.02?} to generate the {NUMBER_VECTORS} random points", before.elapsed());

let mut wtxn = env.write_txn()?;
let mut options = env.database_options();
options.flags(DatabaseFlags::INTEGER_KEY);
let database = options.types::<KeyCodec, Unspecified>().create(&mut wtxn)?;
let database = env
.database_options()
.flags(DatabaseFlags::INTEGER_KEY)
.types::<KeyCodec, Unspecified>()
.create(&mut wtxn)?;
let before = Instant::now();
load_into_arroy(rng_arroy, wtxn, database, VECTOR_DIMENSIONS, &points)?;
eprintln!("took {:.02?} to load into arroy", before.elapsed());
Expand Down
8 changes: 6 additions & 2 deletions examples/debug.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use arroy::{DotProduct, KeyCodec, NodeCodec, NodeMode, Reader, Result, Writer};
use heed::types::LazyDecode;
use heed::{Database, EnvOpenOptions, Unspecified};
use heed::{DatabaseFlags, EnvOpenOptions, Unspecified};

const TWENTY_HUNDRED_MIB: usize = 200 * 1024 * 1024;

Expand All @@ -11,7 +11,11 @@ fn main() -> Result<()> {
// we will open the default unnamed database
let mut wtxn = env.write_txn()?;
let dimensions = 2;
let database: Database<KeyCodec, Unspecified> = env.create_database(&mut wtxn, None)?;
let database = env
.database_options()
.types::<KeyCodec, Unspecified>()
.flags(DatabaseFlags::INTEGER_KEY)
.create(&mut wtxn)?;
let writer = Writer::<DotProduct>::prepare(&mut wtxn, database, 0, dimensions)?;

for i in 0..5 {
Expand Down

0 comments on commit cb32175

Please sign in to comment.