Skip to content

Commit

Permalink
Fix naming for uppercase table names, check if codebook table exists …
Browse files Browse the repository at this point in the history
…before processing
  • Loading branch information
var77 committed Feb 21, 2024
1 parent d107f81 commit dcdfcd9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion ci/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function setup_lantern() {
git submodule update --recursive && \
mkdir build
pushd build
cmake -DUSEARCH_NO_MARCH_NATIVE=ON .. && \
cmake -DMARCH_NATIVE=OFF -DBUILD_FOR_DSTRIBUTING=1 .. && \
make install
popd
popd
Expand Down
2 changes: 1 addition & 1 deletion lantern_external_index/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ clap = { version = "4.4.0", features = ["derive"] }
cxx = "1.0.106"
postgres = "0.19.7"
postgres-types = { version = "0.2.6", features = ["derive"] }
usearch = { git = "https://github.com/Ngalstyan4/usearch.git", branch = "main-lantern" }
usearch = { git = "https://github.com/Ngalstyan4/usearch.git", branch="main-lantern" }
lantern_logger = { path = "../lantern_logger" }
lantern_utils = { path = "../lantern_utils" }
rand = "0.8.5"
29 changes: 18 additions & 11 deletions lantern_external_index/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,20 +148,26 @@ pub fn create_usearch_index(
let mut num_subvectors: usize = 0;

if args.pq {
let codebook_table_name = format!(
"_codebook_{table_name}_{column_name}",
table_name = &args.table,
column_name = &args.column
);
let full_codebook_table_name =
get_full_table_name("_lantern_internal", &codebook_table_name);

let rows_codebook_exists = transaction.query("SELECT true FROM information_schema.tables WHERE table_schema='_lantern_internal' AND table_name=$1;", &[&codebook_table_name])?;

if rows_codebook_exists.len() == 0 {
anyhow::bail!("Codebook table {full_codebook_table_name} does not exist");
}

let rows_c = transaction.query(
&format!(
"SELECT count(*) FROM _lantern_internal._codebook_{table_name}_{column_name} WHERE subvector_id = 0;",
table_name = args.table,
column_name = args.column,
),
&format!("SELECT COUNT(*) FROM {full_codebook_table_name} WHERE subvector_id = 0;"),
&[],
)?;
let rows_sv = transaction.query(
&format!(
"SELECT count(*) FROM _lantern_internal._codebook_{table_name}_{column_name} WHERE centroid_id = 0;",
table_name = args.table,
column_name = args.column,
),
&format!("SELECT COUNT(*) FROM {full_codebook_table_name} WHERE centroid_id = 0;"),
&[],
)?;

Expand All @@ -182,8 +188,9 @@ pub fn create_usearch_index(
),
&[],
)?;

logger.info(&format!(
"codebook has {} rows - {num_centroids} centroids and {num_subvectors} subvectors",
"Codebook has {} rows - {num_centroids} centroids and {num_subvectors} subvectors",
rows.len()
));

Expand Down
2 changes: 1 addition & 1 deletion lantern_extras/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lantern_extras"
version = "0.1.3"
version = "0.1.2"
edition = "2021"

[lib]
Expand Down

0 comments on commit dcdfcd9

Please sign in to comment.