From c568f150c9a3a546bc45d225be8d5f6c30995850 Mon Sep 17 00:00:00 2001 From: Yang Cen Date: Tue, 24 Nov 2026 17:19:10 +0800 Subject: [PATCH 1/2] perf(query): avoid opening vector indexes during cosine ANN planning (#5186) Planning a cosine ANN query opens each distinct index segment to determine its distance scale. Opening the index loads centroids and quantizer data even though the planner only needs the physical index type. Use Lance's batch physical-type lookup for the segment UUIDs in each ANN plan. The planner uses those types to select the existing distance conversion. Query execution still searches the selected segments. The lookup ships in [Lance v15.0.0-beta.31](https://github.com/lance-format/lance/releases/tag/v15.0.0-beta.31). This PR updates the Rust and Java dependencies and the Python test pin to that release. The regression test creates an IVF_RQ index, removes its auxiliary quantizer file, reopens the table in a fresh session, and verifies that a cosine ANN plan can still be built. Existing tests cover modern and legacy PQ scores and ordering across mixed tiers. --- Cargo.lock | 92 ++++++++++++++++---------------- Cargo.toml | 30 +++++------ java/pom.xml | 2 +- python/pyproject.toml | 2 +- python/uv.lock | 18 +++---- rust/lancedb/src/table/query.rs | 94 +++++++++++++++++++++++++++------ 6 files changed, 149 insertions(+), 89 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5a21c16ae..58b145bb5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3836,8 +3836,8 @@ checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" [[package]] name = "fsst" -version = "15.0.0-beta.29" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9" +version = "15.0.0-beta.31" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.31#d529e8d0d2d0fa8ddb87698d5a7301fee5150e51" dependencies = [ "arrow-array", "rand 0.9.5", @@ -5315,8 +5315,8 @@ checksum = "e037a2e1d8d5fdbd49b16a4ea09d5d6401c1f29eca5ff29d03d3824dba16256a" [[package]] name = "lance" -version = "15.0.0-beta.29" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9" +version = "15.0.0-beta.31" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.31#d529e8d0d2d0fa8ddb87698d5a7301fee5150e51" dependencies = [ "arc-swap", "arrow", @@ -5391,8 +5391,8 @@ dependencies = [ [[package]] name = "lance-arrow" -version = "15.0.0-beta.29" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9" +version = "15.0.0-beta.31" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.31#d529e8d0d2d0fa8ddb87698d5a7301fee5150e51" dependencies = [ "arrow-array", "arrow-buffer", @@ -5415,8 +5415,8 @@ dependencies = [ [[package]] name = "lance-bitpacking" -version = "15.0.0-beta.29" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9" +version = "15.0.0-beta.31" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.31#d529e8d0d2d0fa8ddb87698d5a7301fee5150e51" dependencies = [ "arrayref", "crunchy", @@ -5426,8 +5426,8 @@ dependencies = [ [[package]] name = "lance-core" -version = "15.0.0-beta.29" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9" +version = "15.0.0-beta.31" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.31#d529e8d0d2d0fa8ddb87698d5a7301fee5150e51" dependencies = [ "arrow-array", "arrow-buffer", @@ -5465,8 +5465,8 @@ dependencies = [ [[package]] name = "lance-datafusion" -version = "15.0.0-beta.29" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9" +version = "15.0.0-beta.31" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.31#d529e8d0d2d0fa8ddb87698d5a7301fee5150e51" dependencies = [ "arrow", "arrow-array", @@ -5497,8 +5497,8 @@ dependencies = [ [[package]] name = "lance-datafusion-exec" -version = "15.0.0-beta.29" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9" +version = "15.0.0-beta.31" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.31#d529e8d0d2d0fa8ddb87698d5a7301fee5150e51" dependencies = [ "arrow", "arrow-array", @@ -5523,8 +5523,8 @@ dependencies = [ [[package]] name = "lance-datagen" -version = "15.0.0-beta.29" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9" +version = "15.0.0-beta.31" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.31#d529e8d0d2d0fa8ddb87698d5a7301fee5150e51" dependencies = [ "arrow", "arrow-array", @@ -5541,8 +5541,8 @@ dependencies = [ [[package]] name = "lance-derive" -version = "15.0.0-beta.29" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9" +version = "15.0.0-beta.31" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.31#d529e8d0d2d0fa8ddb87698d5a7301fee5150e51" dependencies = [ "proc-macro2", "quote", @@ -5551,8 +5551,8 @@ dependencies = [ [[package]] name = "lance-encoding" -version = "15.0.0-beta.29" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9" +version = "15.0.0-beta.31" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.31#d529e8d0d2d0fa8ddb87698d5a7301fee5150e51" dependencies = [ "arrow-arith", "arrow-array", @@ -5586,8 +5586,8 @@ dependencies = [ [[package]] name = "lance-file" -version = "15.0.0-beta.29" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9" +version = "15.0.0-beta.31" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.31#d529e8d0d2d0fa8ddb87698d5a7301fee5150e51" dependencies = [ "arrow-arith", "arrow-array", @@ -5618,8 +5618,8 @@ dependencies = [ [[package]] name = "lance-geo" -version = "15.0.0-beta.29" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9" +version = "15.0.0-beta.31" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.31#d529e8d0d2d0fa8ddb87698d5a7301fee5150e51" dependencies = [ "arrow-array", "arrow-schema", @@ -5650,8 +5650,8 @@ dependencies = [ [[package]] name = "lance-index" -version = "15.0.0-beta.29" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9" +version = "15.0.0-beta.31" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.31#d529e8d0d2d0fa8ddb87698d5a7301fee5150e51" dependencies = [ "arc-swap", "arrow", @@ -5723,8 +5723,8 @@ dependencies = [ [[package]] name = "lance-index-core" -version = "15.0.0-beta.29" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9" +version = "15.0.0-beta.31" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.31#d529e8d0d2d0fa8ddb87698d5a7301fee5150e51" dependencies = [ "arrow-array", "arrow-schema", @@ -5747,8 +5747,8 @@ dependencies = [ [[package]] name = "lance-io" -version = "15.0.0-beta.29" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9" +version = "15.0.0-beta.31" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.31#d529e8d0d2d0fa8ddb87698d5a7301fee5150e51" dependencies = [ "arrow", "arrow-array", @@ -5793,8 +5793,8 @@ dependencies = [ [[package]] name = "lance-jsonb" -version = "15.0.0-beta.29" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9" +version = "15.0.0-beta.31" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.31#d529e8d0d2d0fa8ddb87698d5a7301fee5150e51" dependencies = [ "byteorder", "ethnum", @@ -5811,8 +5811,8 @@ dependencies = [ [[package]] name = "lance-linalg" -version = "15.0.0-beta.29" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9" +version = "15.0.0-beta.31" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.31#d529e8d0d2d0fa8ddb87698d5a7301fee5150e51" dependencies = [ "argminmax 0.7.1", "arrow-array", @@ -5827,8 +5827,8 @@ dependencies = [ [[package]] name = "lance-namespace" -version = "15.0.0-beta.29" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9" +version = "15.0.0-beta.31" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.31#d529e8d0d2d0fa8ddb87698d5a7301fee5150e51" dependencies = [ "arrow", "async-trait", @@ -5842,8 +5842,8 @@ dependencies = [ [[package]] name = "lance-namespace-impls" -version = "15.0.0-beta.29" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9" +version = "15.0.0-beta.31" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.31#d529e8d0d2d0fa8ddb87698d5a7301fee5150e51" dependencies = [ "arc-swap", "arrow", @@ -5897,8 +5897,8 @@ dependencies = [ [[package]] name = "lance-select" -version = "15.0.0-beta.29" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9" +version = "15.0.0-beta.31" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.31#d529e8d0d2d0fa8ddb87698d5a7301fee5150e51" dependencies = [ "arrow-array", "arrow-buffer", @@ -5912,8 +5912,8 @@ dependencies = [ [[package]] name = "lance-table" -version = "15.0.0-beta.29" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9" +version = "15.0.0-beta.31" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.31#d529e8d0d2d0fa8ddb87698d5a7301fee5150e51" dependencies = [ "arrow", "arrow-array", @@ -5954,8 +5954,8 @@ dependencies = [ [[package]] name = "lance-testing" -version = "15.0.0-beta.29" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9" +version = "15.0.0-beta.31" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.31#d529e8d0d2d0fa8ddb87698d5a7301fee5150e51" dependencies = [ "arrow-array", "arrow-schema", @@ -5968,8 +5968,8 @@ dependencies = [ [[package]] name = "lance-tokenizer" -version = "15.0.0-beta.29" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9" +version = "15.0.0-beta.31" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.31#d529e8d0d2d0fa8ddb87698d5a7301fee5150e51" dependencies = [ "frostem", "icu_segmenter", diff --git a/Cargo.toml b/Cargo.toml index bebf307d6..20bc83c25 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,21 +19,21 @@ categories = ["database-implementations"] rust-version = "1.95.0" [workspace.dependencies] -lance = { "version" = "=15.0.0-beta.29", default-features = false, "tag" = "v15.0.0-beta.29", "git" = "https://github.com/lance-format/lance.git" } -lance-core = { "version" = "=15.0.0-beta.29", "tag" = "v15.0.0-beta.29", "git" = "https://github.com/lance-format/lance.git" } -lance-datagen = { "version" = "=15.0.0-beta.29", "tag" = "v15.0.0-beta.29", "git" = "https://github.com/lance-format/lance.git" } -lance-file = { "version" = "=15.0.0-beta.29", "tag" = "v15.0.0-beta.29", "git" = "https://github.com/lance-format/lance.git" } -lance-io = { "version" = "=15.0.0-beta.29", default-features = false, "tag" = "v15.0.0-beta.29", "git" = "https://github.com/lance-format/lance.git" } -lance-index = { "version" = "=15.0.0-beta.29", "tag" = "v15.0.0-beta.29", "git" = "https://github.com/lance-format/lance.git" } -lance-jsonb = { "version" = "=15.0.0-beta.29", "tag" = "v15.0.0-beta.29", "git" = "https://github.com/lance-format/lance.git" } -lance-linalg = { "version" = "=15.0.0-beta.29", "tag" = "v15.0.0-beta.29", "git" = "https://github.com/lance-format/lance.git" } -lance-namespace = { "version" = "=15.0.0-beta.29", "tag" = "v15.0.0-beta.29", "git" = "https://github.com/lance-format/lance.git" } -lance-namespace-impls = { "version" = "=15.0.0-beta.29", default-features = false, "tag" = "v15.0.0-beta.29", "git" = "https://github.com/lance-format/lance.git" } -lance-table = { "version" = "=15.0.0-beta.29", "tag" = "v15.0.0-beta.29", "git" = "https://github.com/lance-format/lance.git" } -lance-testing = { "version" = "=15.0.0-beta.29", "tag" = "v15.0.0-beta.29", "git" = "https://github.com/lance-format/lance.git" } -lance-datafusion = { "version" = "=15.0.0-beta.29", "tag" = "v15.0.0-beta.29", "git" = "https://github.com/lance-format/lance.git" } -lance-encoding = { "version" = "=15.0.0-beta.29", "tag" = "v15.0.0-beta.29", "git" = "https://github.com/lance-format/lance.git" } -lance-arrow = { "version" = "=15.0.0-beta.29", "tag" = "v15.0.0-beta.29", "git" = "https://github.com/lance-format/lance.git" } +lance = { "version" = "=15.0.0-beta.31", default-features = false, "tag" = "v15.0.0-beta.31", "git" = "https://github.com/lance-format/lance.git" } +lance-core = { "version" = "=15.0.0-beta.31", "tag" = "v15.0.0-beta.31", "git" = "https://github.com/lance-format/lance.git" } +lance-datagen = { "version" = "=15.0.0-beta.31", "tag" = "v15.0.0-beta.31", "git" = "https://github.com/lance-format/lance.git" } +lance-file = { "version" = "=15.0.0-beta.31", "tag" = "v15.0.0-beta.31", "git" = "https://github.com/lance-format/lance.git" } +lance-io = { "version" = "=15.0.0-beta.31", default-features = false, "tag" = "v15.0.0-beta.31", "git" = "https://github.com/lance-format/lance.git" } +lance-index = { "version" = "=15.0.0-beta.31", "tag" = "v15.0.0-beta.31", "git" = "https://github.com/lance-format/lance.git" } +lance-jsonb = { "version" = "=15.0.0-beta.31", "tag" = "v15.0.0-beta.31", "git" = "https://github.com/lance-format/lance.git" } +lance-linalg = { "version" = "=15.0.0-beta.31", "tag" = "v15.0.0-beta.31", "git" = "https://github.com/lance-format/lance.git" } +lance-namespace = { "version" = "=15.0.0-beta.31", "tag" = "v15.0.0-beta.31", "git" = "https://github.com/lance-format/lance.git" } +lance-namespace-impls = { "version" = "=15.0.0-beta.31", default-features = false, "tag" = "v15.0.0-beta.31", "git" = "https://github.com/lance-format/lance.git" } +lance-table = { "version" = "=15.0.0-beta.31", "tag" = "v15.0.0-beta.31", "git" = "https://github.com/lance-format/lance.git" } +lance-testing = { "version" = "=15.0.0-beta.31", "tag" = "v15.0.0-beta.31", "git" = "https://github.com/lance-format/lance.git" } +lance-datafusion = { "version" = "=15.0.0-beta.31", "tag" = "v15.0.0-beta.31", "git" = "https://github.com/lance-format/lance.git" } +lance-encoding = { "version" = "=15.0.0-beta.31", "tag" = "v15.0.0-beta.31", "git" = "https://github.com/lance-format/lance.git" } +lance-arrow = { "version" = "=15.0.0-beta.31", "tag" = "v15.0.0-beta.31", "git" = "https://github.com/lance-format/lance.git" } lancedb = { path = "rust/lancedb", default-features = false } ahash = "0.8" anyhow = "1" diff --git a/java/pom.xml b/java/pom.xml index d1ca50c06..0f8e0bc98 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -28,7 +28,7 @@ UTF-8 15.0.0 - 15.0.0-beta.29 + 15.0.0-beta.31 2.18.12 false 2.30.0 diff --git a/python/pyproject.toml b/python/pyproject.toml index 61d7fcefb..d6dbb095e 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -63,7 +63,7 @@ tests = [ "polars>=0.19, <=1.32.3", "pyarrow>=16", "pyarrow-stubs>=16.0", - "pylance==15.0.0b29", + "pylance==15.0.0b31", "requests>=2.31.0", "datafusion>=54,<55", "opentelemetry-sdk>=1.30.0", diff --git a/python/uv.lock b/python/uv.lock index ce4935b4f..0e826a539 100644 --- a/python/uv.lock +++ b/python/uv.lock @@ -1910,7 +1910,7 @@ requires-dist = [ { name = "pyarrow-stubs", marker = "extra == 'tests'", specifier = ">=16.0" }, { name = "pydantic", specifier = ">=2.7.4,<3" }, { name = "pylance", marker = "extra == 'pylance'", specifier = ">=15.0.0b3" }, - { name = "pylance", marker = "extra == 'tests'", specifier = "==15.0.0b29" }, + { name = "pylance", marker = "extra == 'tests'", specifier = "==15.0.0b31" }, { name = "pyright", marker = "extra == 'dev'", specifier = ">=1.1.350" }, { name = "pytest", marker = "extra == 'tests'", specifier = ">=7.0" }, { name = "pytest-asyncio", marker = "extra == 'tests'", specifier = ">=0.21" }, @@ -3642,20 +3642,20 @@ crypto = [ [[package]] name = "pylance" -version = "15.0.0b29" +version = "15.0.0b31" source = { registry = "https://pypi.fury.io/lance-format/" } dependencies = [ { name = "lance-namespace" }, { name = "pyarrow" }, ] wheels = [ - { url = "https://pypi.fury.io/lance-format/-/ver_1CJyoP/pylance-15.0.0b29-cp310-abi3-macosx_11_0_arm64.whl", hash = "sha256:326acfac339c9715de8057c0f2220ff83f8454c9c78215a4de72c0e6bf868df7" }, - { url = "https://pypi.fury.io/lance-format/-/ver_17XkBE/pylance-15.0.0b29-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bf29bb80781a2a40e57842ff8c3fa3e44fa6f3ff264d1a89c6892c9eb3935412" }, - { url = "https://pypi.fury.io/lance-format/-/ver_yozDA/pylance-15.0.0b29-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:65b6963bd28aff9029dd96957b0a3507771a61cd5fb2343121dd19acca46515e" }, - { url = "https://pypi.fury.io/lance-format/-/ver_Ir3sf/pylance-15.0.0b29-cp310-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:7f500b56414eaaf2f2fdfb0c53ec9470fd81d13619d3f57059c6225b7080f3f2" }, - { url = "https://pypi.fury.io/lance-format/-/ver_1G4ois/pylance-15.0.0b29-cp310-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:33c499a2645b5165ff2fe8124ff1af985b8433eac480692cd9bcbfb550039475" }, - { url = "https://pypi.fury.io/lance-format/-/ver_1oUx2F/pylance-15.0.0b29-cp310-abi3-win_amd64.whl", hash = "sha256:f88a735790ab2fdbea8f52e4a1a18401b5f3e9a233d4334fda45e3e36dd77504" }, - { url = "https://pypi.fury.io/lance-format/-/ver_1Xgvqi/pylance-15.0.0b29-cp310-abi3-win_arm64.whl", hash = "sha256:6e0906650152a82d5fed99e1e526fc8349452446d91acf527b4c98307d87d74d" }, + { url = "https://pypi.fury.io/lance-format/-/ver_1lCn6w/pylance-15.0.0b31-cp310-abi3-macosx_11_0_arm64.whl", hash = "sha256:578209e81d42e02067d994241002f8eabb2bef9d9864aa4e572cc2862f2f82d3" }, + { url = "https://pypi.fury.io/lance-format/-/ver_2ijZWL/pylance-15.0.0b31-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:617d821455617fda85452c2e198fe5d5f5ab117e4792c44a9383c370708c3bd0" }, + { url = "https://pypi.fury.io/lance-format/-/ver_10fXzC/pylance-15.0.0b31-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:707d57e6f1ab40f9285773b5d238d18ba9f09ae3a0e3eb5a35314294ae61a07a" }, + { url = "https://pypi.fury.io/lance-format/-/ver_s8TSO/pylance-15.0.0b31-cp310-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:61c97cf9b3fd28f1a99fa72b0fc2a382efa08c1c94e13cb0509fb4bdf27e51de" }, + { url = "https://pypi.fury.io/lance-format/-/ver_2j1xRs/pylance-15.0.0b31-cp310-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:a53b26af0e320a115d30222ca54b174f794225a8fe5c8e9546cacc9890c64495" }, + { url = "https://pypi.fury.io/lance-format/-/ver_AZZGE/pylance-15.0.0b31-cp310-abi3-win_amd64.whl", hash = "sha256:e6c258cb9d90f05a31fab1ae0f602402aaf0b69b79fc08ad2acf47f3a4d120a2" }, + { url = "https://pypi.fury.io/lance-format/-/ver_1kjace/pylance-15.0.0b31-cp310-abi3-win_arm64.whl", hash = "sha256:fd175bcb41f3bd0d6e07a04f4014fe7dc5427bbc5647d3beee85053d12f503c6" }, ] [[package]] diff --git a/rust/lancedb/src/table/query.rs b/rust/lancedb/src/table/query.rs index 22de400cc..f63bf50bf 100644 --- a/rust/lancedb/src/table/query.rs +++ b/rust/lancedb/src/table/query.rs @@ -32,11 +32,9 @@ use datafusion_physical_plan::{ExecutionPlan, replace_children_if_necessary}; use lance::dataset::mem_wal::DatasetMemWalExt; use lance::dataset::scanner::DatasetRecordBatchStream; use lance::dataset::scanner::Scanner; -use lance::index::DatasetIndexInternalExt; use lance::io::exec::{ANNIvfBatchExec, ANNIvfSubIndexExec}; use lance_datafusion::exec::{analyze_plan as lance_analyze_plan, execute_plan}; use lance_index::IndexType; -use lance_index::metrics::NoOpMetricsCollector; use lance_index::scalar::FullTextSearchQuery; use lance_index::vector::DIST_COL; use lance_linalg::distance::DistanceType as LanceDistanceType; @@ -668,7 +666,7 @@ impl<'a> AnnExecRef<'a> { /// Cosine PQ/SQ/RQ indices normalize their vectors and use squared L2 internally. This /// preserves ranking, but squared L2 over unit vectors is twice the cosine distance. Flat /// cosine indices calculate cosine directly, so they are not included. -async fn normalized_l2_ann_indices(plan: &dyn ExecutionPlan) -> Result> { +async fn normalized_l2_ann_indices(plan: &dyn ExecutionPlan) -> Result> { let mut ann_plans = Vec::new(); find_ann_plans(plan, &mut ann_plans); @@ -678,17 +676,22 @@ async fn normalized_l2_ann_indices(plan: &dyn ExecutionPlan) -> Result = ann + .indices() + .iter() + .map(|index| index.uuid) + .filter(|uuid| checked.insert(*uuid)) + .collect(); + if uuids.is_empty() { + continue; + } + let types = ann + .dataset() + .vector_index_types(&ann.query().column, &uuids) + .await?; + for (uuid, index_type) in uuids.into_iter().zip(types) { if matches!( - vector_index.index_type(), + index_type, IndexType::IvfPq | IndexType::IvfSq | IndexType::IvfRq @@ -745,7 +748,7 @@ fn collect_ann_plans( fn normalize_ann_branches( public_plan: Arc, internal_plan: Arc, - normalized_l2_indices: &HashSet, + normalized_l2_indices: &HashSet, ) -> Result> { let mut internal_ann_plans = VecDeque::new(); collect_ann_plans(&internal_plan, &mut internal_ann_plans); @@ -763,7 +766,7 @@ fn normalize_ann_branches( fn replace_ann_branches( public_plan: Arc, internal_ann_plans: &mut VecDeque>, - normalized_l2_indices: &HashSet, + normalized_l2_indices: &HashSet, ) -> Result> { if let Some(public_ann) = AnnExecRef::from_plan(public_plan.as_ref()) { let internal_plan = internal_ann_plans @@ -795,7 +798,7 @@ fn replace_ann_branches( let normalized_count = public_ann .indices() .iter() - .filter(|index| normalized_l2_indices.contains(&index.uuid.to_string())) + .filter(|index| normalized_l2_indices.contains(&index.uuid)) .count(); if normalized_count == 0 { return Ok(public_plan); @@ -2142,6 +2145,62 @@ mod tests { ); } + #[tokio::test] + async fn test_cold_cosine_rq_plan_only_needs_index_header() { + use crate::index::{Index, vector::IvfRqIndexBuilder}; + use lance::index::DatasetIndexExt; + + let dir = tempfile::tempdir().unwrap(); + let uri = dir.path().to_str().unwrap(); + let conn = crate::connect(uri).execute().await.unwrap(); + let vectors = Arc::new(fixed_size_list_array( + (0..512 * 8).map(|n| (1 + n % 31) as f32).collect(), + 8, + )); + let schema = Arc::new(Schema::new(vec![arrow_schema::Field::new( + "vector", + vectors.data_type().clone(), + false, + )])); + let batch = RecordBatch::try_new(schema, vec![vectors]).unwrap(); + let table = conn.create_table("vectors", batch).execute().await.unwrap(); + table + .create_index( + &["vector"], + Index::IvfRq( + IvfRqIndexBuilder::default() + .distance_type(crate::DistanceType::Cosine) + .num_partitions(1), + ), + ) + .execute() + .await + .unwrap(); + let dataset = table.dataset().unwrap().get().await.unwrap(); + let indices = dataset.load_indices().await.unwrap(); + assert_eq!(indices.len(), 1); + // The quantizer is needed to execute the search. Planning should only read + // the segment's type from index.idx, even with an empty session cache. + let auxiliary = dir + .path() + .join("vectors.lance/_indices") + .join(indices[0].uuid.to_string()) + .join(lance_index::INDEX_AUXILIARY_FILE_NAME); + std::fs::remove_file(auxiliary).unwrap(); + let conn = crate::connect(uri).execute().await.unwrap(); + let table = conn.open_table("vectors").execute().await.unwrap(); + let plan = table + .vector_search([1.0_f32; 8].as_slice()) + .unwrap() + .create_plan(QueryExecutionOptions::default()) + .await + .unwrap(); + let mut ann = Vec::new(); + find_ann_plans(plan.as_ref(), &mut ann); + assert_eq!(ann.len(), 1); + assert_eq!(ann[0].query().metric_type, Some(LanceDistanceType::Cosine)); + } + #[rstest::rstest] #[case::modern(false)] #[case::legacy(true)] @@ -2156,9 +2215,10 @@ mod tests { use crate::connect; use crate::index::{Index, vector::IvfPqIndexBuilder}; use lance::index::{ - DatasetIndexExt, + DatasetIndexExt, DatasetIndexInternalExt, vector::{IndexFileVersion, VectorIndexParams}, }; + use lance_index::metrics::NoOpMetricsCollector; fn normalized_vector(state: &mut u64, dimension: usize) -> Vec { let mut vector = (0..dimension) From abe829f4a32538d636465ca3c77f1c32a753835b Mon Sep 17 00:00:00 2001 From: Lance Release Date: Tue, 24 Nov 2026 09:19:50 +0000 Subject: [PATCH 2/2] =?UTF-8?q?Bump=20version:=200.42.0-beta.27=20?= =?UTF-8?q?=E2=86=92=200.42.0-beta.28?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .bumpversion.toml | 2 +- Cargo.lock | 8 ++++---- docs/src/java/java.md | 2 +- java/lancedb-core/pom.xml | 2 +- java/pom.xml | 2 +- nodejs/Cargo.toml | 2 +- nodejs/npm/darwin-arm64/package.json | 2 +- nodejs/npm/linux-arm64-gnu/package.json | 2 +- nodejs/npm/linux-arm64-musl/package.json | 2 +- nodejs/npm/linux-x64-gnu/package.json | 2 +- nodejs/npm/linux-x64-musl/package.json | 2 +- nodejs/npm/win32-arm64-msvc/package.json | 2 +- nodejs/npm/win32-x64-msvc/package.json | 2 +- nodejs/package.json | 2 +- python/Cargo.toml | 2 +- rust/lancedb/Cargo.toml | 2 +- rust/lancedb/cli/Cargo.toml | 2 +- 17 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.bumpversion.toml b/.bumpversion.toml index 39503742e..244c10fe6 100644 --- a/.bumpversion.toml +++ b/.bumpversion.toml @@ -1,5 +1,5 @@ [tool.bumpversion] -current_version = "0.42.0-beta.27" +current_version = "0.42.0-beta.28" parse = """(?x) (?P0|[1-9]\\d*)\\. (?P0|[1-9]\\d*)\\. diff --git a/Cargo.lock b/Cargo.lock index 58b145bb5..955d8e9fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5982,7 +5982,7 @@ dependencies = [ [[package]] name = "lancedb" -version = "0.42.0-beta.27" +version = "0.42.0-beta.28" dependencies = [ "ahash", "anyhow", @@ -6093,7 +6093,7 @@ dependencies = [ [[package]] name = "lancedb-cli" -version = "0.42.0-beta.27" +version = "0.42.0-beta.28" dependencies = [ "anyhow", "arrow-array", @@ -6136,7 +6136,7 @@ dependencies = [ [[package]] name = "lancedb-nodejs" -version = "0.42.0-beta.27" +version = "0.42.0-beta.28" dependencies = [ "arrow-array", "arrow-buffer", @@ -6162,7 +6162,7 @@ dependencies = [ [[package]] name = "lancedb-python" -version = "0.42.0-beta.27" +version = "0.42.0-beta.28" dependencies = [ "arc-swap", "arrow", diff --git a/docs/src/java/java.md b/docs/src/java/java.md index aa52bb05e..2ab1b713d 100644 --- a/docs/src/java/java.md +++ b/docs/src/java/java.md @@ -14,7 +14,7 @@ Add the following dependency to your `pom.xml`: com.lancedb lancedb-core - 0.42.0-beta.27 + 0.42.0-beta.28 ``` diff --git a/java/lancedb-core/pom.xml b/java/lancedb-core/pom.xml index 79325435c..e68cb2297 100644 --- a/java/lancedb-core/pom.xml +++ b/java/lancedb-core/pom.xml @@ -8,7 +8,7 @@ com.lancedb lancedb-parent - 0.42.0-beta.27 + 0.42.0-beta.28 ../pom.xml diff --git a/java/pom.xml b/java/pom.xml index 0f8e0bc98..d7ff056df 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -6,7 +6,7 @@ com.lancedb lancedb-parent - 0.42.0-beta.27 + 0.42.0-beta.28 pom ${project.artifactId} LanceDB Java SDK Parent POM diff --git a/nodejs/Cargo.toml b/nodejs/Cargo.toml index 7d5bf5e1a..3459200fd 100644 --- a/nodejs/Cargo.toml +++ b/nodejs/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "lancedb-nodejs" edition.workspace = true -version = "0.42.0-beta.27" +version = "0.42.0-beta.28" publish = false license.workspace = true description.workspace = true diff --git a/nodejs/npm/darwin-arm64/package.json b/nodejs/npm/darwin-arm64/package.json index 827e75da8..34cf0a042 100644 --- a/nodejs/npm/darwin-arm64/package.json +++ b/nodejs/npm/darwin-arm64/package.json @@ -1,6 +1,6 @@ { "name": "@lancedb/lancedb-darwin-arm64", - "version": "0.42.0-beta.27", + "version": "0.42.0-beta.28", "os": ["darwin"], "cpu": ["arm64"], "main": "lancedb.darwin-arm64.node", diff --git a/nodejs/npm/linux-arm64-gnu/package.json b/nodejs/npm/linux-arm64-gnu/package.json index ba5eb8485..8fe88a4c6 100644 --- a/nodejs/npm/linux-arm64-gnu/package.json +++ b/nodejs/npm/linux-arm64-gnu/package.json @@ -1,6 +1,6 @@ { "name": "@lancedb/lancedb-linux-arm64-gnu", - "version": "0.42.0-beta.27", + "version": "0.42.0-beta.28", "os": ["linux"], "cpu": ["arm64"], "main": "lancedb.linux-arm64-gnu.node", diff --git a/nodejs/npm/linux-arm64-musl/package.json b/nodejs/npm/linux-arm64-musl/package.json index d8bd00065..bb942a472 100644 --- a/nodejs/npm/linux-arm64-musl/package.json +++ b/nodejs/npm/linux-arm64-musl/package.json @@ -1,6 +1,6 @@ { "name": "@lancedb/lancedb-linux-arm64-musl", - "version": "0.42.0-beta.27", + "version": "0.42.0-beta.28", "os": ["linux"], "cpu": ["arm64"], "main": "lancedb.linux-arm64-musl.node", diff --git a/nodejs/npm/linux-x64-gnu/package.json b/nodejs/npm/linux-x64-gnu/package.json index 73ee7f1bf..6e3582411 100644 --- a/nodejs/npm/linux-x64-gnu/package.json +++ b/nodejs/npm/linux-x64-gnu/package.json @@ -1,6 +1,6 @@ { "name": "@lancedb/lancedb-linux-x64-gnu", - "version": "0.42.0-beta.27", + "version": "0.42.0-beta.28", "os": ["linux"], "cpu": ["x64"], "main": "lancedb.linux-x64-gnu.node", diff --git a/nodejs/npm/linux-x64-musl/package.json b/nodejs/npm/linux-x64-musl/package.json index 95aed0a6b..8b44e72f2 100644 --- a/nodejs/npm/linux-x64-musl/package.json +++ b/nodejs/npm/linux-x64-musl/package.json @@ -1,6 +1,6 @@ { "name": "@lancedb/lancedb-linux-x64-musl", - "version": "0.42.0-beta.27", + "version": "0.42.0-beta.28", "os": ["linux"], "cpu": ["x64"], "main": "lancedb.linux-x64-musl.node", diff --git a/nodejs/npm/win32-arm64-msvc/package.json b/nodejs/npm/win32-arm64-msvc/package.json index 6b70830bd..c0d84a542 100644 --- a/nodejs/npm/win32-arm64-msvc/package.json +++ b/nodejs/npm/win32-arm64-msvc/package.json @@ -1,6 +1,6 @@ { "name": "@lancedb/lancedb-win32-arm64-msvc", - "version": "0.42.0-beta.27", + "version": "0.42.0-beta.28", "os": [ "win32" ], diff --git a/nodejs/npm/win32-x64-msvc/package.json b/nodejs/npm/win32-x64-msvc/package.json index c408d4ee9..704b07e18 100644 --- a/nodejs/npm/win32-x64-msvc/package.json +++ b/nodejs/npm/win32-x64-msvc/package.json @@ -1,6 +1,6 @@ { "name": "@lancedb/lancedb-win32-x64-msvc", - "version": "0.42.0-beta.27", + "version": "0.42.0-beta.28", "os": ["win32"], "cpu": ["x64"], "main": "lancedb.win32-x64-msvc.node", diff --git a/nodejs/package.json b/nodejs/package.json index 2ab267c56..1cc602d11 100644 --- a/nodejs/package.json +++ b/nodejs/package.json @@ -11,7 +11,7 @@ "ann" ], "private": false, - "version": "0.42.0-beta.27", + "version": "0.42.0-beta.28", "main": "dist/index.js", "exports": { ".": "./dist/index.js", diff --git a/python/Cargo.toml b/python/Cargo.toml index f8c7bdecb..6d3057608 100644 --- a/python/Cargo.toml +++ b/python/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lancedb-python" -version = "0.42.0-beta.27" +version = "0.42.0-beta.28" publish = false edition.workspace = true description = "Python bindings for LanceDB" diff --git a/rust/lancedb/Cargo.toml b/rust/lancedb/Cargo.toml index dcc9ec0a7..4458aa293 100644 --- a/rust/lancedb/Cargo.toml +++ b/rust/lancedb/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lancedb" -version = "0.42.0-beta.27" +version = "0.42.0-beta.28" edition.workspace = true description = "LanceDB: A serverless, low-latency vector database for AI applications" license.workspace = true diff --git a/rust/lancedb/cli/Cargo.toml b/rust/lancedb/cli/Cargo.toml index 0c958f31e..4ea7ecfc4 100644 --- a/rust/lancedb/cli/Cargo.toml +++ b/rust/lancedb/cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lancedb-cli" -version = "0.42.0-beta.27" +version = "0.42.0-beta.28" edition = "2021" license.workspace = true repository.workspace = true