From cb3217528334f88cc5cbecd0e997d0b624fadcc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Sun, 26 Nov 2023 11:27:13 +0100 Subject: [PATCH] Use the INTEGER_KEY database flag to gain (a little bit of) space --- Cargo.toml | 2 +- examples/compare_with_hnsw.rs | 8 +++++--- examples/debug.rs | 8 ++++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 68ccf36d..1a9f715c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/examples/compare_with_hnsw.rs b/examples/compare_with_hnsw.rs index bb77f2d3..5da3e43e 100644 --- a/examples/compare_with_hnsw.rs +++ b/examples/compare_with_hnsw.rs @@ -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::().create(&mut wtxn)?; + let database = env + .database_options() + .flags(DatabaseFlags::INTEGER_KEY) + .types::() + .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()); diff --git a/examples/debug.rs b/examples/debug.rs index d8816178..a79bffb9 100644 --- a/examples/debug.rs +++ b/examples/debug.rs @@ -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; @@ -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 = env.create_database(&mut wtxn, None)?; + let database = env + .database_options() + .types::() + .flags(DatabaseFlags::INTEGER_KEY) + .create(&mut wtxn)?; let writer = Writer::::prepare(&mut wtxn, database, 0, dimensions)?; for i in 0..5 {