mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-26 12:33:59 +00:00
Merge main into gatekeeper/fix-4911-1
This commit is contained in:
@@ -240,18 +240,11 @@ jobs:
|
||||
sudo mkswap "$swapfile"
|
||||
sudo swapon "$swapfile"
|
||||
- name: Build
|
||||
run: cargo build --profile ci --all-features --tests --locked --examples
|
||||
- name: Reclaim completed workspace build artifacts
|
||||
run: |
|
||||
# Package-level tests resolve a different feature graph from the workspace
|
||||
# build. Reclaim its lancedb outputs before linking the test graph.
|
||||
df -h .
|
||||
cargo clean --profile ci -p lancedb
|
||||
df -h .
|
||||
run: cargo build --profile ci -p lancedb --all-features --tests --locked --examples
|
||||
- name: Run feature tests
|
||||
run: CARGO_ARGS="--profile ci" make -C ./lancedb feature-tests
|
||||
- name: Run examples
|
||||
run: cargo run --profile ci --all-features --example simple --locked
|
||||
run: cargo run --profile ci -p lancedb --all-features --example simple --locked
|
||||
- name: Run blob v2 docs example
|
||||
# Python and TypeScript blob docs tests install preview packages.
|
||||
# Those builds are not guaranteed to remain available for more than
|
||||
|
||||
Generated
+47
-47
@@ -3814,8 +3814,8 @@ checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c"
|
||||
|
||||
[[package]]
|
||||
name = "fsst"
|
||||
version = "15.0.0-beta.14"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.14#3bb1550f4f27adf90948ff36c2318768e675b599"
|
||||
version = "15.0.0-beta.15"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.15#a826a940d550ee1f3bb5b470c3e10e670c1e38ce"
|
||||
dependencies = [
|
||||
"arrow-array",
|
||||
"rand 0.9.5",
|
||||
@@ -5292,8 +5292,8 @@ checksum = "e037a2e1d8d5fdbd49b16a4ea09d5d6401c1f29eca5ff29d03d3824dba16256a"
|
||||
|
||||
[[package]]
|
||||
name = "lance"
|
||||
version = "15.0.0-beta.14"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.14#3bb1550f4f27adf90948ff36c2318768e675b599"
|
||||
version = "15.0.0-beta.15"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.15#a826a940d550ee1f3bb5b470c3e10e670c1e38ce"
|
||||
dependencies = [
|
||||
"arc-swap",
|
||||
"arrow",
|
||||
@@ -5368,8 +5368,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-arrow"
|
||||
version = "15.0.0-beta.14"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.14#3bb1550f4f27adf90948ff36c2318768e675b599"
|
||||
version = "15.0.0-beta.15"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.15#a826a940d550ee1f3bb5b470c3e10e670c1e38ce"
|
||||
dependencies = [
|
||||
"arrow-array",
|
||||
"arrow-buffer",
|
||||
@@ -5391,7 +5391,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "lance-arrow-scalar"
|
||||
version = "59.0.0"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.14#3bb1550f4f27adf90948ff36c2318768e675b599"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.15#a826a940d550ee1f3bb5b470c3e10e670c1e38ce"
|
||||
dependencies = [
|
||||
"arrow-array",
|
||||
"arrow-buffer",
|
||||
@@ -5405,7 +5405,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "lance-arrow-stats"
|
||||
version = "59.0.0"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.14#3bb1550f4f27adf90948ff36c2318768e675b599"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.15#a826a940d550ee1f3bb5b470c3e10e670c1e38ce"
|
||||
dependencies = [
|
||||
"arrow-array",
|
||||
"arrow-schema",
|
||||
@@ -5414,8 +5414,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-bitpacking"
|
||||
version = "15.0.0-beta.14"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.14#3bb1550f4f27adf90948ff36c2318768e675b599"
|
||||
version = "15.0.0-beta.15"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.15#a826a940d550ee1f3bb5b470c3e10e670c1e38ce"
|
||||
dependencies = [
|
||||
"arrayref",
|
||||
"crunchy",
|
||||
@@ -5425,8 +5425,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-core"
|
||||
version = "15.0.0-beta.14"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.14#3bb1550f4f27adf90948ff36c2318768e675b599"
|
||||
version = "15.0.0-beta.15"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.15#a826a940d550ee1f3bb5b470c3e10e670c1e38ce"
|
||||
dependencies = [
|
||||
"arrow-array",
|
||||
"arrow-buffer",
|
||||
@@ -5464,8 +5464,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-datafusion"
|
||||
version = "15.0.0-beta.14"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.14#3bb1550f4f27adf90948ff36c2318768e675b599"
|
||||
version = "15.0.0-beta.15"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.15#a826a940d550ee1f3bb5b470c3e10e670c1e38ce"
|
||||
dependencies = [
|
||||
"arrow",
|
||||
"arrow-array",
|
||||
@@ -5496,8 +5496,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-datafusion-exec"
|
||||
version = "15.0.0-beta.14"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.14#3bb1550f4f27adf90948ff36c2318768e675b599"
|
||||
version = "15.0.0-beta.15"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.15#a826a940d550ee1f3bb5b470c3e10e670c1e38ce"
|
||||
dependencies = [
|
||||
"arrow",
|
||||
"arrow-array",
|
||||
@@ -5522,8 +5522,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-datagen"
|
||||
version = "15.0.0-beta.14"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.14#3bb1550f4f27adf90948ff36c2318768e675b599"
|
||||
version = "15.0.0-beta.15"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.15#a826a940d550ee1f3bb5b470c3e10e670c1e38ce"
|
||||
dependencies = [
|
||||
"arrow",
|
||||
"arrow-array",
|
||||
@@ -5540,8 +5540,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-derive"
|
||||
version = "15.0.0-beta.14"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.14#3bb1550f4f27adf90948ff36c2318768e675b599"
|
||||
version = "15.0.0-beta.15"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.15#a826a940d550ee1f3bb5b470c3e10e670c1e38ce"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -5550,8 +5550,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-encoding"
|
||||
version = "15.0.0-beta.14"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.14#3bb1550f4f27adf90948ff36c2318768e675b599"
|
||||
version = "15.0.0-beta.15"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.15#a826a940d550ee1f3bb5b470c3e10e670c1e38ce"
|
||||
dependencies = [
|
||||
"arrow-arith",
|
||||
"arrow-array",
|
||||
@@ -5584,8 +5584,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-file"
|
||||
version = "15.0.0-beta.14"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.14#3bb1550f4f27adf90948ff36c2318768e675b599"
|
||||
version = "15.0.0-beta.15"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.15#a826a940d550ee1f3bb5b470c3e10e670c1e38ce"
|
||||
dependencies = [
|
||||
"arrow-arith",
|
||||
"arrow-array",
|
||||
@@ -5616,8 +5616,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-geo"
|
||||
version = "15.0.0-beta.14"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.14#3bb1550f4f27adf90948ff36c2318768e675b599"
|
||||
version = "15.0.0-beta.15"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.15#a826a940d550ee1f3bb5b470c3e10e670c1e38ce"
|
||||
dependencies = [
|
||||
"arrow-array",
|
||||
"arrow-schema",
|
||||
@@ -5648,8 +5648,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-index"
|
||||
version = "15.0.0-beta.14"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.14#3bb1550f4f27adf90948ff36c2318768e675b599"
|
||||
version = "15.0.0-beta.15"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.15#a826a940d550ee1f3bb5b470c3e10e670c1e38ce"
|
||||
dependencies = [
|
||||
"arc-swap",
|
||||
"arrow",
|
||||
@@ -5720,8 +5720,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-index-core"
|
||||
version = "15.0.0-beta.14"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.14#3bb1550f4f27adf90948ff36c2318768e675b599"
|
||||
version = "15.0.0-beta.15"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.15#a826a940d550ee1f3bb5b470c3e10e670c1e38ce"
|
||||
dependencies = [
|
||||
"arrow-array",
|
||||
"arrow-schema",
|
||||
@@ -5744,8 +5744,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-io"
|
||||
version = "15.0.0-beta.14"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.14#3bb1550f4f27adf90948ff36c2318768e675b599"
|
||||
version = "15.0.0-beta.15"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.15#a826a940d550ee1f3bb5b470c3e10e670c1e38ce"
|
||||
dependencies = [
|
||||
"arrow",
|
||||
"arrow-array",
|
||||
@@ -5790,8 +5790,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-jsonb"
|
||||
version = "15.0.0-beta.14"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.14#3bb1550f4f27adf90948ff36c2318768e675b599"
|
||||
version = "15.0.0-beta.15"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.15#a826a940d550ee1f3bb5b470c3e10e670c1e38ce"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"ethnum",
|
||||
@@ -5808,7 +5808,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-linalg"
|
||||
version = "15.0.0-beta.14"
|
||||
version = "15.0.0-beta.15"
|
||||
dependencies = [
|
||||
"approx",
|
||||
"argminmax 0.7.1",
|
||||
@@ -5830,8 +5830,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-namespace"
|
||||
version = "15.0.0-beta.14"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.14#3bb1550f4f27adf90948ff36c2318768e675b599"
|
||||
version = "15.0.0-beta.15"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.15#a826a940d550ee1f3bb5b470c3e10e670c1e38ce"
|
||||
dependencies = [
|
||||
"arrow",
|
||||
"async-trait",
|
||||
@@ -5845,8 +5845,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-namespace-impls"
|
||||
version = "15.0.0-beta.14"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.14#3bb1550f4f27adf90948ff36c2318768e675b599"
|
||||
version = "15.0.0-beta.15"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.15#a826a940d550ee1f3bb5b470c3e10e670c1e38ce"
|
||||
dependencies = [
|
||||
"arc-swap",
|
||||
"arrow",
|
||||
@@ -5900,8 +5900,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-select"
|
||||
version = "15.0.0-beta.14"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.14#3bb1550f4f27adf90948ff36c2318768e675b599"
|
||||
version = "15.0.0-beta.15"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.15#a826a940d550ee1f3bb5b470c3e10e670c1e38ce"
|
||||
dependencies = [
|
||||
"arrow-array",
|
||||
"arrow-buffer",
|
||||
@@ -5915,8 +5915,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-table"
|
||||
version = "15.0.0-beta.14"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.14#3bb1550f4f27adf90948ff36c2318768e675b599"
|
||||
version = "15.0.0-beta.15"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.15#a826a940d550ee1f3bb5b470c3e10e670c1e38ce"
|
||||
dependencies = [
|
||||
"arrow",
|
||||
"arrow-array",
|
||||
@@ -5957,8 +5957,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-testing"
|
||||
version = "15.0.0-beta.14"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.14#3bb1550f4f27adf90948ff36c2318768e675b599"
|
||||
version = "15.0.0-beta.15"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.15#a826a940d550ee1f3bb5b470c3e10e670c1e38ce"
|
||||
dependencies = [
|
||||
"arrow-array",
|
||||
"arrow-schema",
|
||||
@@ -5971,8 +5971,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-tokenizer"
|
||||
version = "15.0.0-beta.14"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.14#3bb1550f4f27adf90948ff36c2318768e675b599"
|
||||
version = "15.0.0-beta.15"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.15#a826a940d550ee1f3bb5b470c3e10e670c1e38ce"
|
||||
dependencies = [
|
||||
"frostem",
|
||||
"icu_segmenter",
|
||||
|
||||
+14
-14
@@ -20,20 +20,20 @@ categories = ["database-implementations"]
|
||||
rust-version = "1.95.0"
|
||||
|
||||
[workspace.dependencies]
|
||||
lance = { "version" = "=15.0.0-beta.14", default-features = false, "tag" = "v15.0.0-beta.14", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-core = { "version" = "=15.0.0-beta.14", "tag" = "v15.0.0-beta.14", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-datagen = { "version" = "=15.0.0-beta.14", "tag" = "v15.0.0-beta.14", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-file = { "version" = "=15.0.0-beta.14", "tag" = "v15.0.0-beta.14", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-io = { "version" = "=15.0.0-beta.14", default-features = false, "tag" = "v15.0.0-beta.14", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-index = { "version" = "=15.0.0-beta.14", "tag" = "v15.0.0-beta.14", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-jsonb = { "version" = "=15.0.0-beta.14", "tag" = "v15.0.0-beta.14", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-namespace = { "version" = "=15.0.0-beta.14", "tag" = "v15.0.0-beta.14", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-namespace-impls = { "version" = "=15.0.0-beta.14", default-features = false, "tag" = "v15.0.0-beta.14", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-table = { "version" = "=15.0.0-beta.14", "tag" = "v15.0.0-beta.14", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-testing = { "version" = "=15.0.0-beta.14", "tag" = "v15.0.0-beta.14", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-datafusion = { "version" = "=15.0.0-beta.14", "tag" = "v15.0.0-beta.14", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-encoding = { "version" = "=15.0.0-beta.14", "tag" = "v15.0.0-beta.14", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-arrow = { "version" = "=15.0.0-beta.14", "tag" = "v15.0.0-beta.14", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance = { "version" = "=15.0.0-beta.15", default-features = false, "tag" = "v15.0.0-beta.15", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-core = { "version" = "=15.0.0-beta.15", "tag" = "v15.0.0-beta.15", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-datagen = { "version" = "=15.0.0-beta.15", "tag" = "v15.0.0-beta.15", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-file = { "version" = "=15.0.0-beta.15", "tag" = "v15.0.0-beta.15", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-io = { "version" = "=15.0.0-beta.15", default-features = false, "tag" = "v15.0.0-beta.15", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-index = { "version" = "=15.0.0-beta.15", "tag" = "v15.0.0-beta.15", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-jsonb = { "version" = "=15.0.0-beta.15", "tag" = "v15.0.0-beta.15", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-namespace = { "version" = "=15.0.0-beta.15", "tag" = "v15.0.0-beta.15", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-namespace-impls = { "version" = "=15.0.0-beta.15", default-features = false, "tag" = "v15.0.0-beta.15", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-table = { "version" = "=15.0.0-beta.15", "tag" = "v15.0.0-beta.15", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-testing = { "version" = "=15.0.0-beta.15", "tag" = "v15.0.0-beta.15", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-datafusion = { "version" = "=15.0.0-beta.15", "tag" = "v15.0.0-beta.15", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-encoding = { "version" = "=15.0.0-beta.15", "tag" = "v15.0.0-beta.15", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-arrow = { "version" = "=15.0.0-beta.15", "tag" = "v15.0.0-beta.15", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lancedb = { path = "rust/lancedb", default-features = false }
|
||||
ahash = "0.8"
|
||||
anyhow = "1"
|
||||
|
||||
@@ -948,6 +948,9 @@ supported. Pruning old versions and index optimization are silently
|
||||
skipped there instead of being attempted, so this call resolves
|
||||
successfully, with zeroed pruning statistics, once the compaction job
|
||||
has been submitted; it does not wait for that job to finish.
|
||||
`compactionOptions` can tune the four per-job settings documented in
|
||||
[CompactionOptions](../interfaces/CompactionOptions.md). Older-server errors are propagated without
|
||||
retrying with the settings removed.
|
||||
|
||||
#### Parameters
|
||||
|
||||
|
||||
@@ -74,6 +74,7 @@
|
||||
- [ClientConfig](interfaces/ClientConfig.md)
|
||||
- [ColumnAlteration](interfaces/ColumnAlteration.md)
|
||||
- [ColumnOrdering](interfaces/ColumnOrdering.md)
|
||||
- [CompactionOptions](interfaces/CompactionOptions.md)
|
||||
- [CompactionStats](interfaces/CompactionStats.md)
|
||||
- [ConnectNamespaceOptions](interfaces/ConnectNamespaceOptions.md)
|
||||
- [ConnectionOptions](interfaces/ConnectionOptions.md)
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
[**@lancedb/lancedb**](../README.md) • **Docs**
|
||||
|
||||
***
|
||||
|
||||
[@lancedb/lancedb](../globals.md) / CompactionOptions
|
||||
|
||||
# Interface: CompactionOptions
|
||||
|
||||
Per-invocation compaction settings. Values must be safe integers.
|
||||
|
||||
## Properties
|
||||
|
||||
### batchSize?
|
||||
|
||||
```ts
|
||||
optional batchSize: number;
|
||||
```
|
||||
|
||||
Positive scanner batch size in rows.
|
||||
|
||||
***
|
||||
|
||||
### ioBufferSize?
|
||||
|
||||
```ts
|
||||
optional ioBufferSize: number;
|
||||
```
|
||||
|
||||
Scanner I/O read-ahead budget in bytes; zero disables byte-based I/O backpressure.
|
||||
|
||||
***
|
||||
|
||||
### maxSourceRows?
|
||||
|
||||
```ts
|
||||
optional maxSourceRows: number;
|
||||
```
|
||||
|
||||
Positive live-source-row budget across whole tasks; an oversized first task can produce no work.
|
||||
|
||||
***
|
||||
|
||||
### targetRowsPerFragment?
|
||||
|
||||
```ts
|
||||
optional targetRowsPerFragment: number;
|
||||
```
|
||||
|
||||
Positive target rows per output fragment; also affects candidate selection.
|
||||
@@ -33,6 +33,28 @@ tbl.optimize({cleanupOlderThan: new Date()});
|
||||
|
||||
***
|
||||
|
||||
### compactionOptions?
|
||||
|
||||
```ts
|
||||
optional compactionOptions: CompactionOptions;
|
||||
```
|
||||
|
||||
Compaction settings for this invocation. Omitted remote values inherit table
|
||||
tuning, then deployment/built-in defaults.
|
||||
Remote tables require a server supporting these SQL options; settings do
|
||||
not change table policy. This is not a runtime or total-memory limit.
|
||||
|
||||
#### Example
|
||||
|
||||
```ts
|
||||
await tbl.optimize({ compactionOptions: {
|
||||
targetRowsPerFragment: 1000, maxSourceRows: 5000,
|
||||
ioBufferSize: 64 * 1024 * 1024, batchSize: 128,
|
||||
} });
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
### deleteUnverified
|
||||
|
||||
```ts
|
||||
|
||||
@@ -352,9 +352,27 @@ accept the LanceDB Embedded options: cleanup and compaction warn that they are n
|
||||
`optimize` submits a durable compaction job and returns once that submission is
|
||||
accepted, not once compaction itself finishes. Pruning and index optimization
|
||||
are not yet supported remotely, so it silently skips them and returns with
|
||||
zeroed pruning statistics rather than attempting and failing. A non-default
|
||||
`compaction_options` raises `NotImplementedError` before anything is
|
||||
submitted, since there is no way yet to forward those settings to the server.
|
||||
zeroed pruning statistics. Remote `compaction_options` support per-job
|
||||
`target_rows_per_fragment`, `max_source_rows`, `io_buffer_size`, and `batch_size`
|
||||
on compatible servers. Other non-default settings raise `NotImplementedError`
|
||||
before submission; older-server errors are returned without dropping options.
|
||||
The source-row budget selects whole tasks and can produce no work if the first
|
||||
task exceeds it. An I/O buffer size of zero disables byte-based I/O backpressure.
|
||||
Use a positive size to limit I/O read-ahead; this is not a total-memory limit.
|
||||
Each field resolves as invocation option → table tuning → deployment/built-in
|
||||
default. These options apply only to the submitted job and leave table policy
|
||||
unchanged. Table `enabled` controls automatic scheduling; explicit manual runs
|
||||
remain allowed.
|
||||
|
||||
```python
|
||||
table.optimize(compaction_options={
|
||||
"target_rows_per_fragment": 100_000,
|
||||
"max_source_rows": 1_000_000,
|
||||
"io_buffer_size": 64 * 1024 * 1024,
|
||||
"batch_size": 1024,
|
||||
})
|
||||
```
|
||||
|
||||
Removed Tantivy options produce the same explanatory errors on both backends.
|
||||
|
||||
The old LanceDB Enterprise keyword names `predicate` for `delete`, `index_name` for
|
||||
|
||||
@@ -22,7 +22,7 @@ Computed columns require LanceDB Enterprise.
|
||||
job = table.refresh_column_async("doubled")
|
||||
job.wait()
|
||||
|
||||
table.to_arrow().sort_by("x").to_pandas()
|
||||
table.search().to_arrow().sort_by("x").to_pandas()
|
||||
# x doubled
|
||||
# 0 1 2
|
||||
# 1 2 4
|
||||
@@ -77,13 +77,21 @@ catch-up works when it's re-enabled after being off.
|
||||
|
||||
## Refreshing part of a table {#partial}
|
||||
|
||||
<Badge color="red">Enterprise</Badge> In SQL a refresh can be scoped to a
|
||||
predicate, which is useful for filling a slice first and checking it before
|
||||
committing to the whole table:
|
||||
<Badge color="red">Enterprise</Badge> A refresh can be scoped to a predicate,
|
||||
with `where=` in Python or `WHERE` in SQL, which is useful for filling a slice
|
||||
first and checking it before committing to the whole table:
|
||||
|
||||
<CodeGroup>
|
||||
```python Python icon="python"
|
||||
job = table.refresh_column_async(
|
||||
"embedding",
|
||||
where="created_at > date '2026-01-01'",
|
||||
)
|
||||
job.wait()
|
||||
```
|
||||
|
||||
```sql SQL icon="database"
|
||||
REFRESH COLUMN embedding ON documents WHERE created_at > '2026-01-01'
|
||||
REFRESH COLUMN embedding ON documents WHERE created_at > date '2026-01-01'
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
@@ -92,9 +100,17 @@ whose outputs are already current. Repeating the same predicate repeats those
|
||||
Function calls and their cost. To select only null outputs within a slice:
|
||||
|
||||
<CodeGroup>
|
||||
```python Python icon="python"
|
||||
job = table.refresh_column_async(
|
||||
"embedding",
|
||||
where="created_at > date '2026-01-01' AND embedding IS NULL",
|
||||
)
|
||||
job.wait()
|
||||
```
|
||||
|
||||
```sql SQL icon="database"
|
||||
REFRESH COLUMN embedding ON documents
|
||||
WHERE created_at > '2026-01-01' AND embedding IS NULL
|
||||
WHERE created_at > date '2026-01-01' AND embedding IS NULL
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
@@ -247,13 +263,14 @@ and `gpuCount` in the `refreshColumnAsync` options.
|
||||
|
||||
The job APIs also take the row filter and failure handling of the SQL
|
||||
`REFRESH COLUMN ... WHERE ... WITH (...)` form, so a refresh can be narrowed
|
||||
to new rows and told to skip rows whose Function call fails:
|
||||
to new rows (see [what a filter recomputes](#partial)) and told to skip rows
|
||||
whose Function call fails:
|
||||
|
||||
<CodeGroup>
|
||||
```python
|
||||
job = table.refresh_column_async(
|
||||
"embedding",
|
||||
where="published_at > '2026-01-01'",
|
||||
where="created_at > date '2026-01-01'",
|
||||
error_policy="skip",
|
||||
max_failed_fraction=0.01,
|
||||
row_timeout_seconds=30,
|
||||
@@ -262,7 +279,7 @@ job = table.refresh_column_async(
|
||||
|
||||
```typescript
|
||||
const job = await table.refreshColumnAsync("embedding", {
|
||||
where: "published_at > '2026-01-01'",
|
||||
where: "created_at > date '2026-01-01'",
|
||||
errorPolicy: "skip",
|
||||
maxFailedFraction: 0.01,
|
||||
rowTimeoutSeconds: 30,
|
||||
@@ -276,7 +293,7 @@ let _job = table
|
||||
.refresh_column_async_with_options(
|
||||
"embedding",
|
||||
RefreshColumnOptions::default()
|
||||
.where_clause("published_at > '2026-01-01'")
|
||||
.where_clause("created_at > date '2026-01-01'")
|
||||
.error_policy(FunctionErrorPolicy::Skip)
|
||||
.max_failed_fraction(0.01)
|
||||
.row_timeout_seconds(30.0),
|
||||
|
||||
@@ -59,6 +59,65 @@ Use `view.table.count_rows()` for the view's row count at any time; on
|
||||
LanceDB Embedded it always matches `rows_written` from the most recent
|
||||
refresh.
|
||||
|
||||
{/*
|
||||
Draft: publish this section after the Python/Rust resource-budget SDK support
|
||||
is released. TypeScript parity is tracked separately in issue #4903.
|
||||
|
||||
## Resource budgets {#resources}
|
||||
|
||||
For training-data curation, bound the resources used to recompute a view:
|
||||
|
||||
<CodeGroup>
|
||||
```python Python icon="python"
|
||||
job = view.refresh_async(
|
||||
cpu_millis=8000,
|
||||
memory_bytes=16 * 1024**3,
|
||||
gpu_count=2,
|
||||
gpu_class="h100",
|
||||
)
|
||||
job.wait()
|
||||
```
|
||||
|
||||
```rust Rust icon="rust"
|
||||
use lancedb::materialized_view::MaterializedView;
|
||||
|
||||
async fn refresh(view: &MaterializedView) -> lancedb::Result<()> {
|
||||
let job = view
|
||||
.refresh()
|
||||
.cpu_millis(8000)
|
||||
.memory_bytes(16_u64 << 30)
|
||||
.gpu_count(2)
|
||||
.gpu_class("h100")
|
||||
.execute_async()
|
||||
.await?;
|
||||
job.wait().await?;
|
||||
Ok(())
|
||||
}
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
The same options are available on `refresh`, asynchronous Python connections,
|
||||
and the Rust refresh builder (`cpu_millis`, `memory_bytes`, `gpu_count`, and
|
||||
`gpu_class`). CPU is in millicores (8000 means eight cores), memory is bytes,
|
||||
and GPU count is an aggregate concurrent cap. CPU or memory requires all three
|
||||
budget fields. Use zero GPUs for a CPU-only view, or specify a GPU cap alone.
|
||||
|
||||
The cap covers the refresh execution and its Function processes together.
|
||||
It does not allocate that budget separately to each Function. A GPU class
|
||||
selects placement for this execution; discover configured classes with
|
||||
`db.list_gpu_classes()`. A cap does not promise more parallelism: current MV
|
||||
refreshes use at most one GPU. Omitted settings keep existing defaults.
|
||||
|
||||
These controls require an Enterprise server with an isolated backend that can
|
||||
enforce them; Embedded and unsupported execution backends reject them. Earlier
|
||||
Enterprise servers reject the new SQL options. See the
|
||||
[SQL resource options](/sql/dml/refresh-materialized-view#resources).
|
||||
|
||||
TypeScript does not expose these options yet; SDK parity is tracked in
|
||||
[issue #4903](https://github.com/lancedb/lancedb/issues/4903).
|
||||
|
||||
*/}
|
||||
|
||||
## Automatic refresh {#auto-refresh}
|
||||
|
||||
A materialized view can refresh itself on a schedule instead of waiting
|
||||
|
||||
@@ -150,9 +150,10 @@ task at a time can also reduce memory use.
|
||||
The Rust example runs compaction only. Run pruning and index optimization
|
||||
separately when needed; Python's `optimize()` includes those steps.
|
||||
|
||||
TypeScript's `optimize()` does not currently expose the fragment row target,
|
||||
scan batch size, or compaction thread count. These tuning examples apply to
|
||||
Python and Rust tables in LanceDB Embedded.
|
||||
TypeScript's `optimize()` exposes the fragment row target through
|
||||
`compactionOptions.targetRowsPerFragment` and the scanner batch size through
|
||||
`compactionOptions.batchSize`. Compaction thread count is not exposed. The tuning
|
||||
examples above use Python and Rust tables in LanceDB Embedded.
|
||||
|
||||
Planning remains row based. The row target bounds later passes after existing
|
||||
oversized fragments have been rewritten; the first pass rewrites those
|
||||
|
||||
@@ -24,7 +24,7 @@ REFRESH COLUMN <column> ON [TABLE] <table>
|
||||
<CodeGroup>
|
||||
```sql SQL icon="database"
|
||||
REFRESH COLUMN doubled ON my_table
|
||||
REFRESH COLUMN embedding ON documents WHERE created_at > '2026-01-01'
|
||||
REFRESH COLUMN embedding ON documents WHERE created_at > date '2026-01-01'
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
@@ -39,7 +39,7 @@ calls and their cost. To select only null outputs within a slice:
|
||||
<CodeGroup>
|
||||
```sql SQL icon="database"
|
||||
REFRESH COLUMN embedding ON documents
|
||||
WHERE created_at > '2026-01-01' AND embedding IS NULL
|
||||
WHERE created_at > date '2026-01-01' AND embedding IS NULL
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
|
||||
@@ -14,7 +14,8 @@ A LanceDB extension with no DataFusion equivalent.
|
||||
<CodeGroup>
|
||||
```sql SQL icon="database"
|
||||
REFRESH MATERIALIZED VIEW <name>
|
||||
[WITH (full = <boolean>)]
|
||||
[WITH (full = <boolean>, cpu_millis = <integer>, memory_bytes = <integer>,
|
||||
gpu_count = <integer>, gpu_class = '<class>')]
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
@@ -36,6 +37,39 @@ regardless of what a local SDK's `refresh()` method accepts -- do not
|
||||
assume the two option sets match.
|
||||
</Note>
|
||||
|
||||
## Resource budgets {#resources}
|
||||
|
||||
Set budgets for one refresh execution:
|
||||
|
||||
```sql
|
||||
REFRESH MATERIALIZED VIEW curated_training_set WITH (
|
||||
cpu_millis = 8000,
|
||||
memory_bytes = 17179869184,
|
||||
gpu_count = 2,
|
||||
gpu_class = 'h100'
|
||||
);
|
||||
```
|
||||
|
||||
`cpu_millis` is CPU capacity in millicores (1000 = one core), not CPU time.
|
||||
`memory_bytes` caps memory in bytes. `gpu_count` caps concurrent GPUs for the
|
||||
refresh. These are aggregate caps across its SQL execution and Function
|
||||
processes; they are not multiplied by the number of Functions in the query.
|
||||
|
||||
CPU or memory requires all three budget fields. CPU and memory must be positive;
|
||||
`gpu_count = 0` is allowed for CPU-only views. A GPU budget alone is also accepted.
|
||||
A cap does not reserve all of its GPUs or increase refresh parallelism. Current
|
||||
MV refreshes use at most one GPU, shared by their GPU Function calls.
|
||||
|
||||
`gpu_class` selects an operator-configured class for this execution, leaving the
|
||||
Function registration and saved MV placement unchanged. Use `SHOW GPU CLASSES`
|
||||
to discover configured classes. Omitted budgets and class preserve defaults.
|
||||
Options can be combined with `full = true`.
|
||||
|
||||
This requires an Enterprise server and an isolated execution backend that can
|
||||
enforce resource budgets. Unsupported backends reject constrained refreshes.
|
||||
Older servers reject the new options. Saved defaults and automatic refresh
|
||||
configuration are unchanged.
|
||||
|
||||
## Watching a refresh {#watching}
|
||||
|
||||
A refresh submits work that outlives the call. Track it with
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<arrow.version>15.0.0</arrow.version>
|
||||
<lance-core.version>15.0.0-beta.8</lance-core.version>
|
||||
<lance-core.version>15.0.0-beta.15</lance-core.version>
|
||||
<jackson.version>2.18.12</jackson.version>
|
||||
<spotless.skip>false</spotless.skip>
|
||||
<spotless.version>2.30.0</spotless.version>
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
AutoQuery,
|
||||
type BlobInput,
|
||||
type BlobMode,
|
||||
type CompactionOptions,
|
||||
Connection,
|
||||
MatchQuery,
|
||||
PhraseQuery,
|
||||
@@ -3997,7 +3998,93 @@ it("passes cleanupOlderThan to the native binding as an absolute timestamp", asy
|
||||
|
||||
await table.optimize({ cleanupOlderThan: cutoff, deleteUnverified: true });
|
||||
|
||||
expect(optimize).toHaveBeenCalledWith(cutoff.getTime(), true);
|
||||
expect(optimize).toHaveBeenCalledWith(cutoff.getTime(), true, undefined);
|
||||
});
|
||||
|
||||
it("forwards per-job compaction options to the native binding", async () => {
|
||||
const optimize = jest.fn().mockResolvedValue({});
|
||||
const table = new LocalTable({ optimize } as never);
|
||||
const compactionOptions = {
|
||||
targetRowsPerFragment: 20,
|
||||
maxSourceRows: 25,
|
||||
ioBufferSize: 0,
|
||||
batchSize: 8,
|
||||
};
|
||||
await table.optimize({ compactionOptions });
|
||||
expect(optimize).toHaveBeenCalledWith(
|
||||
undefined,
|
||||
undefined,
|
||||
compactionOptions,
|
||||
);
|
||||
});
|
||||
|
||||
it("rejects unsupported JavaScript compaction options before native submission", async () => {
|
||||
const optimize = jest.fn();
|
||||
const table = new LocalTable({ optimize } as never);
|
||||
await expect(
|
||||
table.optimize({
|
||||
compactionOptions: {
|
||||
maxSourceBytes: 1024,
|
||||
} as unknown as CompactionOptions,
|
||||
}),
|
||||
).rejects.toThrow("Unsupported compaction option: maxSourceBytes");
|
||||
expect(optimize).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
describe("per-job compaction options", () => {
|
||||
let tmpDir: tmp.DirResult;
|
||||
let table: Table;
|
||||
beforeEach(async () => {
|
||||
tmpDir = tmp.dirSync({ unsafeCleanup: true });
|
||||
const db = await connect(tmpDir.name);
|
||||
table = await db.createTable(
|
||||
"bounded",
|
||||
Array.from({ length: 10 }, (_, id) => ({ id })),
|
||||
);
|
||||
for (let f = 1; f < 8; f++) {
|
||||
await table.add(
|
||||
Array.from({ length: 10 }, (_, id) => ({ id: f * 10 + id })),
|
||||
);
|
||||
}
|
||||
});
|
||||
afterEach(() => {
|
||||
tmpDir.removeCallback();
|
||||
});
|
||||
it("bounds source work and preserves zero I/O buffering", async () => {
|
||||
const stats = await table.optimize({
|
||||
compactionOptions: {
|
||||
targetRowsPerFragment: 20,
|
||||
maxSourceRows: 25,
|
||||
ioBufferSize: 0,
|
||||
batchSize: 8,
|
||||
},
|
||||
});
|
||||
expect(stats.compaction.fragmentsRemoved).toBe(2);
|
||||
expect(stats.compaction.fragmentsAdded).toBe(1);
|
||||
expect(await table.countRows()).toBe(80);
|
||||
const defaults = await table.optimize();
|
||||
expect(defaults.compaction.fragmentsRemoved).toBe(7);
|
||||
expect(defaults.compaction.fragmentsAdded).toBe(1);
|
||||
expect(await table.countRows()).toBe(80);
|
||||
});
|
||||
const invalid: CompactionOptions[] = [
|
||||
{ targetRowsPerFragment: 0 },
|
||||
{ maxSourceRows: 0 },
|
||||
{ batchSize: 0 },
|
||||
{ ioBufferSize: -1 },
|
||||
{ batchSize: 1.5 },
|
||||
{ maxSourceRows: Number.NaN },
|
||||
{ ioBufferSize: Number.POSITIVE_INFINITY },
|
||||
{ maxSourceRows: Number.MAX_SAFE_INTEGER + 1 },
|
||||
{ targetRowsPerFragment: 2 ** 32 },
|
||||
{ batchSize: 2 ** 32 },
|
||||
];
|
||||
it.each(invalid)("rejects invalid settings %p", async (compactionOptions) => {
|
||||
await expect(table.optimize({ compactionOptions })).rejects.toThrow(
|
||||
/safe integer/,
|
||||
);
|
||||
expect(await table.countRows()).toBe(80);
|
||||
});
|
||||
});
|
||||
|
||||
describe.each(arrowVersions)(
|
||||
|
||||
@@ -165,6 +165,7 @@ export {
|
||||
AddDataOptions,
|
||||
UpdateOptions,
|
||||
OptimizeOptions,
|
||||
CompactionOptions,
|
||||
Version,
|
||||
WriteProgress,
|
||||
FtsToken,
|
||||
|
||||
@@ -152,7 +152,31 @@ export interface UpdateOptions {
|
||||
where: string;
|
||||
}
|
||||
|
||||
/** Per-invocation compaction settings. Values must be safe integers. */
|
||||
export interface CompactionOptions {
|
||||
/** Positive target rows per output fragment; also affects candidate selection. */
|
||||
targetRowsPerFragment?: number;
|
||||
/** Positive live-source-row budget across whole tasks; an oversized first task can produce no work. */
|
||||
maxSourceRows?: number;
|
||||
/** Scanner I/O read-ahead budget in bytes; zero disables byte-based I/O backpressure. */
|
||||
ioBufferSize?: number;
|
||||
/** Positive scanner batch size in rows. */
|
||||
batchSize?: number;
|
||||
}
|
||||
|
||||
export interface OptimizeOptions {
|
||||
/**
|
||||
* Compaction settings for this invocation. Omitted remote values inherit table
|
||||
* tuning, then deployment/built-in defaults.
|
||||
* Remote tables require a server supporting these SQL options; settings do
|
||||
* not change table policy. This is not a runtime or total-memory limit.
|
||||
* @example
|
||||
* await tbl.optimize({ compactionOptions: {
|
||||
* targetRowsPerFragment: 1000, maxSourceRows: 5000,
|
||||
* ioBufferSize: 64 * 1024 * 1024, batchSize: 128,
|
||||
* } });
|
||||
*/
|
||||
compactionOptions?: CompactionOptions;
|
||||
/**
|
||||
* If set then all versions older than the given date
|
||||
* be removed. The current version will never be removed.
|
||||
@@ -1047,6 +1071,9 @@ export abstract class Table {
|
||||
* skipped there instead of being attempted, so this call resolves
|
||||
* successfully, with zeroed pruning statistics, once the compaction job
|
||||
* has been submitted; it does not wait for that job to finish.
|
||||
* `compactionOptions` can tune the four per-job settings documented in
|
||||
* {@link CompactionOptions}. Older-server errors are propagated without
|
||||
* retrying with the settings removed.
|
||||
*/
|
||||
abstract optimize(options?: Partial<OptimizeOptions>): Promise<OptimizeStats>;
|
||||
/**
|
||||
@@ -1646,9 +1673,23 @@ export class LocalTable extends Table {
|
||||
}
|
||||
|
||||
async optimize(options?: Partial<OptimizeOptions>): Promise<OptimizeStats> {
|
||||
// JavaScript callers can supply extra keys that TypeScript would reject.
|
||||
// Refuse them before the native binding can silently discard a work limit.
|
||||
const supported = new Set([
|
||||
"targetRowsPerFragment",
|
||||
"maxSourceRows",
|
||||
"ioBufferSize",
|
||||
"batchSize",
|
||||
]);
|
||||
for (const key of Object.keys(options?.compactionOptions ?? {})) {
|
||||
if (!supported.has(key)) {
|
||||
throw new Error(`Unsupported compaction option: ${key}`);
|
||||
}
|
||||
}
|
||||
return await this.inner.optimize(
|
||||
options?.cleanupOlderThan?.getTime(),
|
||||
options?.deleteUnverified,
|
||||
options?.compactionOptions,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+63
-2
@@ -23,6 +23,63 @@ use crate::merge::NativeMergeInsertBuilder;
|
||||
use crate::query::{Query, TakeQuery, VectorQuery};
|
||||
use crate::util::schema_to_buffer;
|
||||
|
||||
/// Per-invocation file-compaction settings. All numbers must be safe integers.
|
||||
#[napi(object)]
|
||||
pub struct CompactionOptions {
|
||||
pub target_rows_per_fragment: Option<f64>,
|
||||
pub max_source_rows: Option<f64>,
|
||||
pub io_buffer_size: Option<f64>,
|
||||
pub batch_size: Option<f64>,
|
||||
}
|
||||
|
||||
impl CompactionOptions {
|
||||
fn into_overrides(self) -> napi::Result<lancedb::table::optimize::CompactionOverrides> {
|
||||
const MAX_SAFE_INTEGER: u64 = 9_007_199_254_740_991;
|
||||
fn integer(
|
||||
value: Option<f64>,
|
||||
name: &str,
|
||||
max: u64,
|
||||
allow_zero: bool,
|
||||
) -> napi::Result<Option<u64>> {
|
||||
let Some(value) = value else {
|
||||
return Ok(None);
|
||||
};
|
||||
let min = if allow_zero { 0 } else { 1 };
|
||||
let max = max.min(MAX_SAFE_INTEGER);
|
||||
if !value.is_finite()
|
||||
|| value.fract() != 0.0
|
||||
|| value < min as f64
|
||||
|| value > max as f64
|
||||
{
|
||||
return Err(napi::Error::from_reason(format!(
|
||||
"{name} must be a safe integer between {min} and {max}"
|
||||
)));
|
||||
}
|
||||
Ok(Some(value as u64))
|
||||
}
|
||||
let mut options = lancedb::table::optimize::CompactionOverrides::default();
|
||||
if let Some(target) = integer(
|
||||
self.target_rows_per_fragment,
|
||||
"targetRowsPerFragment",
|
||||
u32::MAX as u64,
|
||||
false,
|
||||
)? {
|
||||
options.target_rows_per_fragment = Some(target as usize);
|
||||
}
|
||||
options.max_source_rows = integer(
|
||||
self.max_source_rows,
|
||||
"maxSourceRows",
|
||||
usize::MAX as u64,
|
||||
false,
|
||||
)?
|
||||
.map(|v| v as usize);
|
||||
options.io_buffer_size = integer(self.io_buffer_size, "ioBufferSize", u64::MAX, true)?;
|
||||
options.batch_size =
|
||||
integer(self.batch_size, "batchSize", u32::MAX as u64, false)?.map(|v| v as usize);
|
||||
Ok(options)
|
||||
}
|
||||
}
|
||||
|
||||
#[napi]
|
||||
pub struct Table {
|
||||
// We keep a duplicate of the table name so we can use it for error
|
||||
@@ -732,6 +789,7 @@ impl Table {
|
||||
&self,
|
||||
before_timestamp_ms: Option<i64>,
|
||||
delete_unverified: Option<bool>,
|
||||
compaction_options: Option<CompactionOptions>,
|
||||
) -> napi::Result<OptimizeStats> {
|
||||
let inner = self.inner_ref()?;
|
||||
|
||||
@@ -746,8 +804,11 @@ impl Table {
|
||||
.transpose()?;
|
||||
|
||||
let stats = inner
|
||||
.optimize_full(
|
||||
lancedb::table::CompactionOptions::default(),
|
||||
.optimize_full_with_overrides(
|
||||
compaction_options
|
||||
.map(CompactionOptions::into_overrides)
|
||||
.transpose()?
|
||||
.unwrap_or_default(),
|
||||
None,
|
||||
before_timestamp,
|
||||
delete_unverified,
|
||||
|
||||
@@ -64,7 +64,7 @@ tests = [
|
||||
"polars>=0.19, <=1.32.3",
|
||||
"pyarrow>=16",
|
||||
"pyarrow-stubs>=16.0",
|
||||
"pylance==15.0.0b14",
|
||||
"pylance==15.0.0b15",
|
||||
"requests>=2.31.0",
|
||||
"datafusion>=54,<55",
|
||||
"opentelemetry-sdk>=1.30.0",
|
||||
|
||||
@@ -654,10 +654,24 @@ class Table:
|
||||
limit: Optional[int] = None,
|
||||
) -> FunctionErrors: ...
|
||||
async def refresh_materialized_view(
|
||||
self, source_version: Optional[int] = None, *, full: bool = False
|
||||
self,
|
||||
source_version: Optional[int] = None,
|
||||
*,
|
||||
full: bool = False,
|
||||
cpu_millis: Optional[int] = None,
|
||||
memory_bytes: Optional[int] = None,
|
||||
gpu_count: Optional[int] = None,
|
||||
gpu_class: Optional[str] = None,
|
||||
) -> RefreshMaterializedViewResult: ...
|
||||
async def refresh_materialized_view_async(
|
||||
self, source_version: Optional[int] = None, *, full: bool = False
|
||||
self,
|
||||
source_version: Optional[int] = None,
|
||||
*,
|
||||
full: bool = False,
|
||||
cpu_millis: Optional[int] = None,
|
||||
memory_bytes: Optional[int] = None,
|
||||
gpu_count: Optional[int] = None,
|
||||
gpu_class: Optional[str] = None,
|
||||
) -> Job: ...
|
||||
async def materialized_view_definition(self) -> str: ...
|
||||
async def add_columns_with_schema(self, schema: pa.Schema) -> AddColumnsResult: ...
|
||||
|
||||
@@ -17,6 +17,7 @@ from typing import TYPE_CHECKING, Dict, List, Optional, Sequence, Tuple, Union
|
||||
import json
|
||||
from dataclasses import dataclass
|
||||
|
||||
from .functions import _validate_gpu_class_name
|
||||
from .background_loop import LOOP
|
||||
from .job import AsyncJob, Job, _typed_job
|
||||
|
||||
@@ -156,6 +157,34 @@ def normalize_select(select: SelectArg) -> Optional[List[Tuple[str, str]]]:
|
||||
return normalized
|
||||
|
||||
|
||||
def _refresh_execution_options(cpu_millis, memory_bytes, gpu_count, gpu_class):
|
||||
values = {
|
||||
"cpu_millis": cpu_millis,
|
||||
"memory_bytes": memory_bytes,
|
||||
"gpu_count": gpu_count,
|
||||
}
|
||||
for name, value in values.items():
|
||||
maximum = 2**32 - 1 if name == "gpu_count" else 2**64 - 1
|
||||
minimum = 0 if name == "gpu_count" else 1
|
||||
if value is not None and (
|
||||
type(value) is not int or not minimum <= value <= maximum
|
||||
):
|
||||
raise ValueError(
|
||||
f"{name} must be an integer between {minimum} and {maximum}"
|
||||
)
|
||||
if (cpu_millis is not None or memory_bytes is not None) and any(
|
||||
value is None for value in values.values()
|
||||
):
|
||||
raise ValueError(
|
||||
"cpu_millis, memory_bytes, and gpu_count must be specified together"
|
||||
)
|
||||
if gpu_class is not None:
|
||||
values["gpu_class"] = _validate_gpu_class_name(gpu_class)
|
||||
if gpu_count == 0:
|
||||
raise ValueError("gpu_class requires a positive GPU budget")
|
||||
return {name: value for name, value in values.items() if value is not None}
|
||||
|
||||
|
||||
class AsyncMaterializedView:
|
||||
"""A handle on a materialized view: its table plus its definition.
|
||||
|
||||
@@ -185,7 +214,14 @@ class AsyncMaterializedView:
|
||||
return _definition_from_json(raw)
|
||||
|
||||
async def refresh(
|
||||
self, *, full: bool = False, source_version: Optional[int] = None
|
||||
self,
|
||||
*,
|
||||
full: bool = False,
|
||||
source_version: Optional[int] = None,
|
||||
cpu_millis: Optional[int] = None,
|
||||
memory_bytes: Optional[int] = None,
|
||||
gpu_count: Optional[int] = None,
|
||||
gpu_class: Optional[str] = None,
|
||||
) -> "RefreshMaterializedViewResult":
|
||||
"""Recompute the view from its source.
|
||||
|
||||
@@ -194,16 +230,35 @@ class AsyncMaterializedView:
|
||||
and ``source_version`` selects a source version instead of the latest.
|
||||
LanceDB Enterprise SQL refreshes do not support source-version pinning.
|
||||
|
||||
``cpu_millis`` (1000 = one core), ``memory_bytes``, and ``gpu_count``
|
||||
cap aggregate resources for this execution, including its Function
|
||||
processes. CPU or memory requires all three budget fields; GPU count
|
||||
may be zero for CPU-only views. ``gpu_class`` selects an operator-defined
|
||||
GPU class for this execution only. Omitted options preserve defaults.
|
||||
These options require an Enterprise backend that enforces isolation;
|
||||
Embedded refreshes reject them. Other servers may reject the new options.
|
||||
|
||||
LanceDB Enterprise results leave ``mode``, ``rows_written``, and
|
||||
``source_version`` as ``None`` because the SQL job adapter does not expose
|
||||
these metrics.
|
||||
"""
|
||||
return await self._table._inner.refresh_materialized_view(
|
||||
source_version=source_version, full=full
|
||||
source_version=source_version,
|
||||
full=full,
|
||||
**_refresh_execution_options(
|
||||
cpu_millis, memory_bytes, gpu_count, gpu_class
|
||||
),
|
||||
)
|
||||
|
||||
async def refresh_async(
|
||||
self, *, full: bool = False, source_version: Optional[int] = None
|
||||
self,
|
||||
*,
|
||||
full: bool = False,
|
||||
source_version: Optional[int] = None,
|
||||
cpu_millis: Optional[int] = None,
|
||||
memory_bytes: Optional[int] = None,
|
||||
gpu_count: Optional[int] = None,
|
||||
gpu_class: Optional[str] = None,
|
||||
) -> "AsyncJob[RefreshMaterializedViewResult]":
|
||||
"""Submit a refresh and return its job without waiting.
|
||||
|
||||
@@ -221,7 +276,11 @@ class AsyncMaterializedView:
|
||||
|
||||
return _typed_job(
|
||||
await self._table._inner.refresh_materialized_view_async(
|
||||
source_version=source_version, full=full
|
||||
source_version=source_version,
|
||||
full=full,
|
||||
**_refresh_execution_options(
|
||||
cpu_millis, memory_bytes, gpu_count, gpu_class
|
||||
),
|
||||
),
|
||||
RefreshMaterializedViewResult.from_json,
|
||||
)
|
||||
@@ -253,14 +312,36 @@ class MaterializedView:
|
||||
return LOOP.run(self._async.definition())
|
||||
|
||||
def refresh(
|
||||
self, *, full: bool = False, source_version: Optional[int] = None
|
||||
self,
|
||||
*,
|
||||
full: bool = False,
|
||||
source_version: Optional[int] = None,
|
||||
cpu_millis: Optional[int] = None,
|
||||
memory_bytes: Optional[int] = None,
|
||||
gpu_count: Optional[int] = None,
|
||||
gpu_class: Optional[str] = None,
|
||||
) -> "RefreshMaterializedViewResult":
|
||||
"""Recompute the view from its source. See
|
||||
[AsyncMaterializedView.refresh][lancedb.materialized_view.AsyncMaterializedView.refresh]."""
|
||||
return LOOP.run(self._async.refresh(full=full, source_version=source_version))
|
||||
return LOOP.run(
|
||||
self._async.refresh(
|
||||
full=full,
|
||||
source_version=source_version,
|
||||
**_refresh_execution_options(
|
||||
cpu_millis, memory_bytes, gpu_count, gpu_class
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
def refresh_async(
|
||||
self, *, full: bool = False, source_version: Optional[int] = None
|
||||
self,
|
||||
*,
|
||||
full: bool = False,
|
||||
source_version: Optional[int] = None,
|
||||
cpu_millis: Optional[int] = None,
|
||||
memory_bytes: Optional[int] = None,
|
||||
gpu_count: Optional[int] = None,
|
||||
gpu_class: Optional[str] = None,
|
||||
) -> "Job[RefreshMaterializedViewResult]":
|
||||
"""Submit a refresh and return its job without waiting.
|
||||
|
||||
@@ -269,6 +350,12 @@ class MaterializedView:
|
||||
"""
|
||||
return Job(
|
||||
LOOP.run(
|
||||
self._async.refresh_async(full=full, source_version=source_version)
|
||||
self._async.refresh_async(
|
||||
full=full,
|
||||
source_version=source_version,
|
||||
**_refresh_execution_options(
|
||||
cpu_millis, memory_bytes, gpu_count, gpu_class
|
||||
),
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -1091,10 +1091,13 @@ class RemoteTable(Table):
|
||||
Enterprise job. Pruning old versions and index optimization are not
|
||||
yet supported remotely, so this call skips them and returns
|
||||
successfully with zeroed pruning statistics once the compaction job
|
||||
has been submitted; it does not wait for that job to finish. Passing
|
||||
a non-default ``compaction_options`` raises ``NotImplementedError``
|
||||
before anything is submitted, since there is no way yet to forward
|
||||
those settings to the server.
|
||||
has been submitted; it does not wait for that job to finish. The
|
||||
per-job options ``target_rows_per_fragment``, ``max_source_rows``,
|
||||
``io_buffer_size``, and ``batch_size`` are supported on compatible
|
||||
servers. Omitted fields inherit table tuning, then deployment/built-in
|
||||
defaults. Other non-default settings raise ``NotImplementedError``
|
||||
before submission. Errors from older servers are propagated without
|
||||
retrying with the settings removed.
|
||||
"""
|
||||
return LOOP.run(
|
||||
self._table.optimize(
|
||||
|
||||
@@ -307,7 +307,12 @@ IndexConfigType = Union[
|
||||
class CompactionOptions(TypedDict, total=False):
|
||||
"""Options that control file compaction during table optimization.
|
||||
|
||||
Unspecified options use Lance's defaults.
|
||||
Unspecified options use Lance's defaults for local tables. Remote tables
|
||||
forward ``target_rows_per_fragment``, ``max_source_rows``, ``io_buffer_size``,
|
||||
and ``batch_size`` as per-job SQL options; other non-default settings are
|
||||
unsupported. Omitted remote options inherit table tuning, then deployment/built-in
|
||||
defaults. The server must support these SQL options. These settings do not
|
||||
change table policy.
|
||||
|
||||
Compaction planning is row based. Lowering ``target_rows_per_fragment``
|
||||
based on the expected row size can bound later compaction passes once
|
||||
@@ -353,7 +358,10 @@ class CompactionOptions(TypedDict, total=False):
|
||||
"""Number of rows per input scan batch."""
|
||||
|
||||
io_buffer_size: Optional[int]
|
||||
"""Maximum number of bytes queued in the input scan I/O buffer."""
|
||||
"""Input scan I/O read-ahead budget in bytes.
|
||||
|
||||
Zero disables byte-based I/O backpressure.
|
||||
"""
|
||||
|
||||
defer_index_remap: bool
|
||||
"""Whether to defer index remapping during compaction (default: False)."""
|
||||
@@ -2943,9 +2951,13 @@ class Table(ABC):
|
||||
are silently skipped there instead of being attempted, so this
|
||||
call returns successfully, with zeroed pruning statistics, once
|
||||
the compaction job has been submitted; it does not wait for that
|
||||
job to finish. A non-default ``compaction_options`` raises
|
||||
``NotImplementedError`` before anything is submitted, since
|
||||
there is no way yet to forward those settings to the server.
|
||||
job to finish. Remote compaction supports per-job
|
||||
``target_rows_per_fragment``, ``max_source_rows``, ``io_buffer_size``,
|
||||
and ``batch_size``. Omitted fields inherit table tuning, then
|
||||
deployment/built-in defaults. Other non-default compaction settings raise
|
||||
``NotImplementedError`` before submission. The server must support
|
||||
these SQL options; older-server errors are propagated without
|
||||
dropping the requested settings.
|
||||
|
||||
Modeled after ``VACUUM`` in PostgreSQL.
|
||||
|
||||
@@ -8477,9 +8489,13 @@ class AsyncTable:
|
||||
are silently skipped there instead of being attempted, so this
|
||||
call returns successfully, with zeroed pruning statistics, once
|
||||
the compaction job has been submitted; it does not wait for that
|
||||
job to finish. A non-default ``compaction_options`` raises
|
||||
``NotImplementedError`` before anything is submitted, since
|
||||
there is no way yet to forward those settings to the server.
|
||||
job to finish. Remote compaction supports per-job
|
||||
``target_rows_per_fragment``, ``max_source_rows``, ``io_buffer_size``,
|
||||
and ``batch_size``. Omitted fields inherit table tuning, then
|
||||
deployment/built-in defaults. Other non-default compaction settings raise
|
||||
``NotImplementedError`` before submission. The server must support
|
||||
these SQL options; older-server errors are propagated without
|
||||
dropping the requested settings.
|
||||
|
||||
Modeled after ``VACUUM`` in PostgreSQL.
|
||||
|
||||
|
||||
@@ -63,7 +63,17 @@ def mock_remote_materialized_view_refresh():
|
||||
@pytest.mark.parametrize("sync", [False, True])
|
||||
@pytest.mark.parametrize("background", [False, True])
|
||||
@pytest.mark.parametrize("full", [False, True])
|
||||
async def test_remote_refresh_reports_unknown_metrics(sync, background, full):
|
||||
@pytest.mark.parametrize(
|
||||
"resources",
|
||||
[
|
||||
{},
|
||||
{"gpu_count": 2, "gpu_class": "h100"},
|
||||
{"cpu_millis": 8000, "memory_bytes": 16 * 1024**3, "gpu_count": 0},
|
||||
],
|
||||
)
|
||||
async def test_remote_refresh_reports_unknown_metrics(
|
||||
sync, background, full, resources
|
||||
):
|
||||
flight = pytest.importorskip("pyarrow.flight")
|
||||
|
||||
class RefreshServer(flight.FlightServerBase):
|
||||
@@ -90,7 +100,7 @@ async def test_remote_refresh_reports_unknown_metrics(sync, background, full):
|
||||
mock_remote_materialized_view_refresh() as (host, requests),
|
||||
RefreshServer() as server,
|
||||
):
|
||||
options = {"full": True} if full else {}
|
||||
options = {"full": full, **resources}
|
||||
connect = lancedb.connect if sync else lancedb.connect_async
|
||||
db = connect(
|
||||
"db://dev",
|
||||
@@ -140,7 +150,28 @@ async def test_remote_refresh_reports_unknown_metrics(sync, background, full):
|
||||
)
|
||||
(refresh,) = refreshes
|
||||
assert b'REFRESH MATERIALIZED VIEW "view"' in refresh
|
||||
assert (b"WITH (full = true)" in refresh) is full
|
||||
assert (b"full = true" in refresh) is full
|
||||
for key, value in resources.items():
|
||||
expected = (
|
||||
f"{key} = '{value}'" if key == "gpu_class" else f"{key} = {value}"
|
||||
)
|
||||
assert expected.encode() in refresh
|
||||
previous = len(server.commands)
|
||||
for invalid in [
|
||||
{"cpu_millis": 0},
|
||||
{"memory_bytes": 1},
|
||||
{"gpu_count": -1},
|
||||
{"gpu_count": True},
|
||||
{"gpu_count": 2**32},
|
||||
{"gpu_class": "H200:8"},
|
||||
{"gpu_count": 0, "gpu_class": "h100"},
|
||||
]:
|
||||
with pytest.raises(ValueError):
|
||||
if sync:
|
||||
view.refresh(**invalid)
|
||||
else:
|
||||
await view.refresh(**invalid)
|
||||
assert len(server.commands) == previous
|
||||
assert not any("count_rows" in path for path in requests)
|
||||
|
||||
|
||||
|
||||
@@ -5837,10 +5837,8 @@ def _create_table_handler(request):
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def _mock_remote_table_with_sql(flight_server):
|
||||
"""A remote table backed by a mock REST server (for create/open) and the
|
||||
given mock Flight SQL server (for the SQL statements `optimize()` submits
|
||||
as jobs)."""
|
||||
def _mock_remote_sql_connection(flight_server):
|
||||
"""Connection arguments for mock REST and Flight SQL servers."""
|
||||
with http.server.ThreadingHTTPServer(
|
||||
("127.0.0.1", 0), make_mock_http_handler(_create_table_handler)
|
||||
) as rest_server:
|
||||
@@ -5848,18 +5846,106 @@ def _mock_remote_table_with_sql(flight_server):
|
||||
handle = start_server_thread(rest_server)
|
||||
try:
|
||||
with flight_server:
|
||||
db = lancedb.connect(
|
||||
"db://dev",
|
||||
api_key="fake",
|
||||
host_override=f"http://127.0.0.1:{rest_port}",
|
||||
sql_host_override=f"grpc://127.0.0.1:{flight_server.port}",
|
||||
)
|
||||
yield db.create_table("test", [{"id": 1}])
|
||||
yield {
|
||||
"uri": "db://dev",
|
||||
"api_key": "fake",
|
||||
"host_override": f"http://127.0.0.1:{rest_port}",
|
||||
"sql_host_override": f"grpc://127.0.0.1:{flight_server.port}",
|
||||
}
|
||||
finally:
|
||||
rest_server.shutdown()
|
||||
handle.join()
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def _mock_remote_table_with_sql(flight_server):
|
||||
with _mock_remote_sql_connection(flight_server) as kwargs:
|
||||
yield lancedb.connect(**kwargs).create_table("test", [{"id": 1}])
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize("asynchronous", [False, True])
|
||||
@pytest.mark.parametrize(
|
||||
"options,sql_options",
|
||||
[
|
||||
({"target_rows_per_fragment": 100}, [b"target_rows_per_fragment = 100"]),
|
||||
(
|
||||
{"target_rows_per_fragment": 1_048_576},
|
||||
[b"target_rows_per_fragment = 1048576"],
|
||||
),
|
||||
({"max_source_rows": 500}, [b"max_source_rows = 500"]),
|
||||
({"io_buffer_size": 0}, [b"io_buffer_size = 0"]),
|
||||
({"batch_size": 16}, [b"batch_size = 16"]),
|
||||
(
|
||||
{
|
||||
"target_rows_per_fragment": 100,
|
||||
"max_source_rows": 500,
|
||||
"io_buffer_size": 65536,
|
||||
"batch_size": 16,
|
||||
},
|
||||
[
|
||||
b"target_rows_per_fragment = 100",
|
||||
b"max_source_rows = 500",
|
||||
b"io_buffer_size = 65536",
|
||||
b"batch_size = 16",
|
||||
],
|
||||
),
|
||||
({}, []),
|
||||
],
|
||||
)
|
||||
async def test_remote_optimize_forwards_per_job_compaction_options(
|
||||
asynchronous, options, sql_options
|
||||
):
|
||||
flight = pytest.importorskip("pyarrow.flight")
|
||||
|
||||
class AckServer(flight.FlightServerBase):
|
||||
def __init__(self):
|
||||
super().__init__("grpc://127.0.0.1:0")
|
||||
self.tickets = []
|
||||
|
||||
def do_get(self, context, ticket):
|
||||
self.tickets.append(ticket.ticket)
|
||||
return flight.RecordBatchStream(
|
||||
pa.table({"ok": pa.array([], type=pa.bool_())})
|
||||
)
|
||||
|
||||
server = AckServer()
|
||||
with _mock_remote_sql_connection(server) as kwargs:
|
||||
if asynchronous:
|
||||
db = await lancedb.connect_async(**kwargs)
|
||||
table = await db.create_table("test", [{"id": 1}])
|
||||
stats = await table.optimize(compaction_options=options)
|
||||
else:
|
||||
table = lancedb.connect(**kwargs).create_table("test", [{"id": 1}])
|
||||
stats = table.optimize(compaction_options=options)
|
||||
assert len(server.tickets) == 1
|
||||
assert b"OPTIMIZE" in server.tickets[0]
|
||||
assert all(option in server.tickets[0] for option in sql_options)
|
||||
if not sql_options:
|
||||
assert b"WITH (" not in server.tickets[0]
|
||||
assert stats.prune.bytes_removed == 0
|
||||
|
||||
|
||||
def test_remote_optimize_does_not_drop_options_after_server_rejection():
|
||||
flight = pytest.importorskip("pyarrow.flight")
|
||||
|
||||
class OldServer(flight.FlightServerBase):
|
||||
def __init__(self):
|
||||
super().__init__("grpc://127.0.0.1:0")
|
||||
self.tickets = []
|
||||
|
||||
def do_get(self, context, ticket):
|
||||
self.tickets.append(ticket.ticket)
|
||||
raise flight.FlightServerError("Unknown OPTIMIZE option 'max_source_rows'")
|
||||
|
||||
server = OldServer()
|
||||
with _mock_remote_table_with_sql(server) as table:
|
||||
with pytest.raises(Exception, match="max_source_rows"):
|
||||
table.optimize(compaction_options={"max_source_rows": 500})
|
||||
assert server.tickets
|
||||
assert all(b"max_source_rows = 500" in ticket for ticket in server.tickets)
|
||||
|
||||
|
||||
def test_remote_optimize_skips_prune_and_index():
|
||||
"""Regression test: a remote table's `optimize()` used to submit a
|
||||
compaction job and then raise `NotImplementedError` once it went on to
|
||||
@@ -5868,7 +5954,7 @@ def test_remote_optimize_skips_prune_and_index():
|
||||
zeroed pruning statistics, once compaction is submitted.
|
||||
|
||||
The SQL job submission for a query without parameters (like
|
||||
`OPTIMIZE TABLE ... REWRITE DATA`) goes over plain Flight `do_get`, not
|
||||
`OPTIMIZE ... REWRITE DATA`) goes over plain Flight `do_get`, not
|
||||
`do_exchange`: the client sends a ticket wrapping the statement and reads
|
||||
back whatever the server returns as the job's result stream.
|
||||
"""
|
||||
@@ -5890,12 +5976,12 @@ def test_remote_optimize_skips_prune_and_index():
|
||||
stats = table.optimize()
|
||||
|
||||
assert len(server.tickets) == 1
|
||||
assert b"OPTIMIZE TABLE" in server.tickets[0]
|
||||
assert b"OPTIMIZE" in server.tickets[0]
|
||||
assert stats.prune.bytes_removed == 0
|
||||
assert stats.prune.old_versions_removed == 0
|
||||
|
||||
|
||||
def test_remote_optimize_rejects_non_default_compaction_options_before_submitting():
|
||||
def test_remote_optimize_rejects_unsupported_compaction_options_before_submitting():
|
||||
"""Regression test: `RemoteTable.optimize()` used to drop
|
||||
`compaction_options` instead of forwarding it to the Rust layer, so a
|
||||
non-default value was silently ignored -- the server-side guard against
|
||||
@@ -5917,7 +6003,7 @@ def test_remote_optimize_rejects_non_default_compaction_options_before_submittin
|
||||
)
|
||||
|
||||
server = UnreachableServer()
|
||||
options: CompactionOptions = {"target_rows_per_fragment": 5}
|
||||
options: CompactionOptions = {"max_source_bytes": 1024}
|
||||
with _mock_remote_table_with_sql(server) as table:
|
||||
with pytest.raises(NotImplementedError, match="CompactionOptions"):
|
||||
table.optimize(compaction_options=options)
|
||||
|
||||
+56
-6
@@ -1838,6 +1838,10 @@ impl Table {
|
||||
compaction_options: Option<&Bound<'py, PyDict>>,
|
||||
) -> PyResult<Bound<'py, PyAny>> {
|
||||
let inner = self_.inner_ref()?.clone();
|
||||
let target_specified = compaction_options
|
||||
.map(|options| options.contains("target_rows_per_fragment"))
|
||||
.transpose()?
|
||||
.unwrap_or(false);
|
||||
let compaction_options = parse_compaction_options(compaction_options)?;
|
||||
let older_than = if let Some(ms) = cleanup_since_ms {
|
||||
if ms > i64::MAX as u64 {
|
||||
@@ -1852,10 +1856,22 @@ impl Table {
|
||||
None
|
||||
};
|
||||
future_into_py(self_.py(), async move {
|
||||
let stats = inner
|
||||
.optimize_full(compaction_options, older_than, None, delete_unverified)
|
||||
.await
|
||||
.infer_error()?;
|
||||
let stats = if inner.as_native().is_some() {
|
||||
inner
|
||||
.optimize_full(compaction_options, older_than, None, delete_unverified)
|
||||
.await
|
||||
} else {
|
||||
let mut overrides =
|
||||
lancedb::table::optimize::CompactionOverrides::try_from(compaction_options)
|
||||
.infer_error()?;
|
||||
if !target_specified {
|
||||
overrides.target_rows_per_fragment = None;
|
||||
}
|
||||
inner
|
||||
.optimize_full_with_overrides(overrides, older_than, None, delete_unverified)
|
||||
.await
|
||||
}
|
||||
.infer_error()?;
|
||||
let compaction_stats = stats.compaction.unwrap();
|
||||
let prune_stats = stats.prune.unwrap();
|
||||
Ok(OptimizeStats {
|
||||
@@ -2293,11 +2309,16 @@ impl Table {
|
||||
})
|
||||
}
|
||||
|
||||
#[pyo3(signature = (source_version=None, *, full=false))]
|
||||
#[pyo3(signature = (source_version=None, *, full=false, cpu_millis=None, memory_bytes=None, gpu_count=None, gpu_class=None))]
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn refresh_materialized_view(
|
||||
self_: PyRef<'_, Self>,
|
||||
source_version: Option<u64>,
|
||||
full: bool,
|
||||
cpu_millis: Option<u64>,
|
||||
memory_bytes: Option<u64>,
|
||||
gpu_count: Option<u32>,
|
||||
gpu_class: Option<String>,
|
||||
) -> PyResult<Bound<'_, PyAny>> {
|
||||
let inner = self_.inner_ref()?.clone();
|
||||
future_into_py(self_.py(), async move {
|
||||
@@ -2305,6 +2326,18 @@ impl Table {
|
||||
.await
|
||||
.infer_error()?;
|
||||
let mut builder = view.refresh().full(full);
|
||||
if let Some(value) = cpu_millis {
|
||||
builder = builder.cpu_millis(value);
|
||||
}
|
||||
if let Some(value) = memory_bytes {
|
||||
builder = builder.memory_bytes(value);
|
||||
}
|
||||
if let Some(value) = gpu_count {
|
||||
builder = builder.gpu_count(value);
|
||||
}
|
||||
if let Some(value) = gpu_class {
|
||||
builder = builder.gpu_class(value);
|
||||
}
|
||||
if let Some(version) = source_version {
|
||||
builder = builder.source_version(version);
|
||||
}
|
||||
@@ -2313,11 +2346,16 @@ impl Table {
|
||||
})
|
||||
}
|
||||
|
||||
#[pyo3(signature = (source_version=None, *, full=false))]
|
||||
#[pyo3(signature = (source_version=None, *, full=false, cpu_millis=None, memory_bytes=None, gpu_count=None, gpu_class=None))]
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn refresh_materialized_view_async(
|
||||
self_: PyRef<'_, Self>,
|
||||
source_version: Option<u64>,
|
||||
full: bool,
|
||||
cpu_millis: Option<u64>,
|
||||
memory_bytes: Option<u64>,
|
||||
gpu_count: Option<u32>,
|
||||
gpu_class: Option<String>,
|
||||
) -> PyResult<Bound<'_, PyAny>> {
|
||||
let inner = self_.inner_ref()?.clone();
|
||||
future_into_py(self_.py(), async move {
|
||||
@@ -2325,6 +2363,18 @@ impl Table {
|
||||
.await
|
||||
.infer_error()?;
|
||||
let mut builder = view.refresh().full(full);
|
||||
if let Some(value) = cpu_millis {
|
||||
builder = builder.cpu_millis(value);
|
||||
}
|
||||
if let Some(value) = memory_bytes {
|
||||
builder = builder.memory_bytes(value);
|
||||
}
|
||||
if let Some(value) = gpu_count {
|
||||
builder = builder.gpu_count(value);
|
||||
}
|
||||
if let Some(value) = gpu_class {
|
||||
builder = builder.gpu_class(value);
|
||||
}
|
||||
if let Some(version) = source_version {
|
||||
builder = builder.source_version(version);
|
||||
}
|
||||
|
||||
Generated
+7
-9
@@ -2147,7 +2147,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.0b14" },
|
||||
{ name = "pylance", marker = "extra == 'tests'", specifier = "==15.0.0b15" },
|
||||
{ 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" },
|
||||
@@ -4301,7 +4301,7 @@ crypto = [
|
||||
|
||||
[[package]]
|
||||
name = "pylance"
|
||||
version = "15.0.0b14"
|
||||
version = "15.0.0b15"
|
||||
source = { registry = "https://pypi.fury.io/lance-format/" }
|
||||
dependencies = [
|
||||
{ name = "lance-namespace" },
|
||||
@@ -4312,13 +4312,11 @@ dependencies = [
|
||||
{ name = "pyarrow", version = "26.0.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11'" },
|
||||
]
|
||||
wheels = [
|
||||
{ url = "https://pypi.fury.io/lance-format/-/ver_b88Zw/pylance-15.0.0b14-cp310-abi3-macosx_11_0_arm64.whl", hash = "sha256:48bcdfda408d1f8eaabbd066236bdb0ae9539acb3186b246c5c1ad4e8e5dcf23" },
|
||||
{ url = "https://pypi.fury.io/lance-format/-/ver_J0evn/pylance-15.0.0b14-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:958d7cf0c8f31e09be94d6785c45158121073e79eb3bdb6f7ed25f7dde22c9a2" },
|
||||
{ url = "https://pypi.fury.io/lance-format/-/ver_18gbAN/pylance-15.0.0b14-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:80814eff77dd0b83ee3c18280895a8d2cadf6d49818d7047a4540b773618738d" },
|
||||
{ url = "https://pypi.fury.io/lance-format/-/ver_1gqym0/pylance-15.0.0b14-cp310-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:bb59f5d5b8740eb5df57c1777bce61f3e2a9f7d47ab31068e2ccf43549627103" },
|
||||
{ url = "https://pypi.fury.io/lance-format/-/ver_1FHTtC/pylance-15.0.0b14-cp310-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:357357f9f419efe9f90ba63d4dc371fc93e191aa692cf6f88d327607680f77da" },
|
||||
{ url = "https://pypi.fury.io/lance-format/-/ver_1LzfL9/pylance-15.0.0b14-cp310-abi3-win_amd64.whl", hash = "sha256:916fcc39051bdd2e8ca50950ee4d8afb941c130fd278ac7cea252c2059beab58" },
|
||||
{ url = "https://pypi.fury.io/lance-format/-/ver_nDQ2x/pylance-15.0.0b14-cp310-abi3-win_arm64.whl", hash = "sha256:e1449bbb7a207cb2890d9afeef41f816d2ab4a459ed73cc46c919d463e46fe10" },
|
||||
{ url = "https://pypi.fury.io/lance-format/-/ver_29HO58/pylance-15.0.0b15-cp310-abi3-macosx_11_0_arm64.whl", hash = "sha256:46c870c3d650f911eccb7406ec77f72fa448f80b2f827ff35dd86bbc0b9e08ca" },
|
||||
{ url = "https://pypi.fury.io/lance-format/-/ver_OBkXR/pylance-15.0.0b15-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b3f418584cdee98d27aac538ebe5203051a0b78a98668aff22bc29aebe3dd3c9" },
|
||||
{ url = "https://pypi.fury.io/lance-format/-/ver_TMbLm/pylance-15.0.0b15-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3656d52ba65d297b41f1973d1a3efbb888f761cf7c934ff15e0c1aecc560b2d5" },
|
||||
{ url = "https://pypi.fury.io/lance-format/-/ver_mmYmR/pylance-15.0.0b15-cp310-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:a50d06e3a86d68acf8edf5a83736890a648a16a1cb8c8ccde9ef5b6c82ebef76" },
|
||||
{ url = "https://pypi.fury.io/lance-format/-/ver_1aYiTc/pylance-15.0.0b15-cp310-abi3-win_amd64.whl", hash = "sha256:6451499f0612d0326d54168bedcc6df29c1e0700c4f92902f5f00a6ecdf17745" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -46,7 +46,7 @@ lance-io = { workspace = true }
|
||||
lance-index = { workspace = true, features = ["tokenizer-jieba", "tokenizer-lindera"] }
|
||||
lance-table = { workspace = true }
|
||||
# Keep the upstream source for downstream SDKs, where workspace patches do not apply.
|
||||
lance-linalg = { "version" = "=15.0.0-beta.14", "tag" = "v15.0.0-beta.14", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-linalg = { "version" = "=15.0.0-beta.15", "tag" = "v15.0.0-beta.15", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-encoding = { workspace = true }
|
||||
lance-arrow = { workspace = true }
|
||||
lance-namespace = { workspace = true }
|
||||
|
||||
@@ -1863,18 +1863,119 @@ impl MaterializedView {
|
||||
view: self.clone(),
|
||||
source_version: None,
|
||||
full: false,
|
||||
options: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Per-execution resource caps and GPU placement for Enterprise MV refreshes.
|
||||
///
|
||||
/// CPU is in millicores (1000 = one core), memory is bytes, and GPUs are a
|
||||
/// simultaneous cap across the refresh, not a per-Function allocation. CPU or
|
||||
/// memory requires all three budget fields. Embedded refreshes reject options.
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq)]
|
||||
#[non_exhaustive]
|
||||
pub struct RefreshMaterializedViewOptions {
|
||||
pub cpu_millis: Option<u64>,
|
||||
pub memory_bytes: Option<u64>,
|
||||
pub gpu_count: Option<u32>,
|
||||
pub gpu_class: Option<String>,
|
||||
}
|
||||
|
||||
impl RefreshMaterializedViewOptions {
|
||||
pub(crate) fn is_empty(&self) -> bool {
|
||||
self.cpu_millis.is_none()
|
||||
&& self.memory_bytes.is_none()
|
||||
&& self.gpu_count.is_none()
|
||||
&& self.gpu_class.is_none()
|
||||
}
|
||||
|
||||
pub(crate) fn validate(&self) -> Result<()> {
|
||||
let invalid = |message: &str| Error::InvalidInput {
|
||||
message: message.into(),
|
||||
};
|
||||
if self.cpu_millis == Some(0) || self.memory_bytes == Some(0) {
|
||||
return Err(invalid(
|
||||
"cpu_millis and memory_bytes must be positive integers",
|
||||
));
|
||||
}
|
||||
if (self.cpu_millis.is_some() || self.memory_bytes.is_some())
|
||||
&& !(self.cpu_millis.is_some()
|
||||
&& self.memory_bytes.is_some()
|
||||
&& self.gpu_count.is_some())
|
||||
{
|
||||
return Err(invalid(
|
||||
"cpu_millis, memory_bytes, and gpu_count must be specified together",
|
||||
));
|
||||
}
|
||||
if let Some(class) = &self.gpu_class {
|
||||
crate::function::validate_gpu_class_name(class)?;
|
||||
if self.gpu_count == Some(0) {
|
||||
return Err(invalid("gpu_class requires a positive GPU budget"));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn sql_clause(&self, full: bool) -> Result<String> {
|
||||
self.validate()?;
|
||||
let mut values = Vec::new();
|
||||
if full {
|
||||
values.push("full = true".to_string());
|
||||
}
|
||||
if let Some(cpu) = self.cpu_millis {
|
||||
values.push(format!("cpu_millis = {cpu}"));
|
||||
}
|
||||
if let Some(memory) = self.memory_bytes {
|
||||
values.push(format!("memory_bytes = {memory}"));
|
||||
}
|
||||
if let Some(gpu) = self.gpu_count {
|
||||
values.push(format!("gpu_count = {gpu}"));
|
||||
}
|
||||
if let Some(class) = &self.gpu_class {
|
||||
values.push(format!("gpu_class = '{class}'"));
|
||||
}
|
||||
Ok(if values.is_empty() {
|
||||
String::new()
|
||||
} else {
|
||||
format!(" WITH ({})", values.join(", "))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Builds a refresh. Created by [`MaterializedView::refresh`].
|
||||
pub struct RefreshMaterializedViewBuilder {
|
||||
view: MaterializedView,
|
||||
source_version: Option<u64>,
|
||||
full: bool,
|
||||
options: RefreshMaterializedViewOptions,
|
||||
}
|
||||
|
||||
impl RefreshMaterializedViewBuilder {
|
||||
/// Cap total CPU capacity in millicores; requires memory and GPU budgets.
|
||||
pub fn cpu_millis(mut self, cpu_millis: u64) -> Self {
|
||||
self.options.cpu_millis = Some(cpu_millis);
|
||||
self
|
||||
}
|
||||
|
||||
/// Cap total memory in bytes; requires CPU and GPU budgets.
|
||||
pub fn memory_bytes(mut self, memory_bytes: u64) -> Self {
|
||||
self.options.memory_bytes = Some(memory_bytes);
|
||||
self
|
||||
}
|
||||
|
||||
/// Cap concurrent GPUs for this refresh. Zero is CPU-only.
|
||||
pub fn gpu_count(mut self, gpu_count: u32) -> Self {
|
||||
self.options.gpu_count = Some(gpu_count);
|
||||
self
|
||||
}
|
||||
|
||||
/// Select an operator-configured GPU class for this execution only.
|
||||
pub fn gpu_class(mut self, gpu_class: impl Into<String>) -> Self {
|
||||
self.options.gpu_class = Some(gpu_class.into());
|
||||
self
|
||||
}
|
||||
|
||||
/// Force a complete rebuild instead of letting the server choose
|
||||
/// the refresh mode. Defaults to `false`. LanceDB Embedded views always rebuild.
|
||||
///
|
||||
@@ -1900,14 +2001,22 @@ impl RefreshMaterializedViewBuilder {
|
||||
|
||||
/// Submit the refresh and return a job that settles with its result.
|
||||
pub async fn execute_async(self) -> Result<Job<RefreshMaterializedViewResult>> {
|
||||
self.options.validate()?;
|
||||
if self.view.table.as_native().is_none() {
|
||||
return self
|
||||
.view
|
||||
.table
|
||||
.base_table()
|
||||
.refresh_materialized_view_async(self.source_version, self.full)
|
||||
.refresh_materialized_view_async_with_options(
|
||||
self.source_version,
|
||||
self.full,
|
||||
self.options,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
if !self.options.is_empty() {
|
||||
return Err(Error::NotSupported { message: "resource budgets and GPU placement require an Enterprise materialized-view refresh".into() });
|
||||
}
|
||||
crate::require_experimental_functions()?;
|
||||
Ok(Job::spawned(tokio::spawn(async move {
|
||||
refresh::execute_refresh(&self.view.table, self.source_version).await
|
||||
@@ -1916,6 +2025,10 @@ impl RefreshMaterializedViewBuilder {
|
||||
|
||||
/// Refresh the view, waiting for the job to finish.
|
||||
pub async fn execute(self) -> Result<RefreshMaterializedViewResult> {
|
||||
self.options.validate()?;
|
||||
if self.view.table.as_native().is_some() && !self.options.is_empty() {
|
||||
return Err(Error::NotSupported { message: "resource budgets and GPU placement require an Enterprise materialized-view refresh".into() });
|
||||
}
|
||||
if self.view.table.as_native().is_some() {
|
||||
return refresh::execute_refresh(&self.view.table, self.source_version).await;
|
||||
}
|
||||
@@ -2151,6 +2264,15 @@ mod tests {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(matches!(
|
||||
view.refresh().gpu_count(0).execute().await,
|
||||
Err(Error::NotSupported { .. })
|
||||
));
|
||||
assert!(matches!(
|
||||
view.refresh().gpu_class("h100").execute_async().await,
|
||||
Err(Error::NotSupported { .. })
|
||||
));
|
||||
|
||||
assert_eq!(view.table().count_rows(None).await.unwrap(), 2);
|
||||
assert!(
|
||||
view.table()
|
||||
|
||||
@@ -1329,7 +1329,30 @@ async fn remote_refresh_omits_unknown_metrics_and_forwards_full() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
for result in [first, second] {
|
||||
let third = view
|
||||
.refresh()
|
||||
.full(true)
|
||||
.cpu_millis(8000)
|
||||
.memory_bytes(16 << 30)
|
||||
.gpu_count(2)
|
||||
.gpu_class("h100")
|
||||
.execute_async()
|
||||
.await
|
||||
.unwrap()
|
||||
.wait()
|
||||
.await
|
||||
.unwrap();
|
||||
for invalid in [
|
||||
view.refresh().cpu_millis(1),
|
||||
view.refresh().gpu_class("H200:8"),
|
||||
view.refresh().gpu_count(0).gpu_class("h100"),
|
||||
] {
|
||||
assert!(matches!(
|
||||
invalid.execute_async().await,
|
||||
Err(Error::InvalidInput { .. })
|
||||
));
|
||||
}
|
||||
for result in [first, second, third] {
|
||||
assert_eq!(result.mode, None);
|
||||
assert_eq!(result.rows_written, None);
|
||||
assert_eq!(result.source_version, None);
|
||||
@@ -1350,6 +1373,7 @@ async fn remote_refresh_omits_unknown_metrics_and_forwards_full() {
|
||||
"DESCRIBE MATERIALIZED VIEW \"view\"",
|
||||
"REFRESH MATERIALIZED VIEW \"view\"",
|
||||
"REFRESH MATERIALIZED VIEW \"view\" WITH (full = true)",
|
||||
"REFRESH MATERIALIZED VIEW \"view\" WITH (full = true, cpu_millis = 8000, memory_bytes = 17179869184, gpu_count = 2, gpu_class = 'h100')",
|
||||
]
|
||||
);
|
||||
assert!(
|
||||
@@ -2318,7 +2342,7 @@ async fn remote_optimize_submits_a_compaction_job_over_sql() {
|
||||
assert!(stats.prune.is_none());
|
||||
assert_eq!(
|
||||
*statements.lock().unwrap(),
|
||||
["OPTIMIZE TABLE \"events\" REWRITE DATA"]
|
||||
["OPTIMIZE \"events\" REWRITE DATA"]
|
||||
);
|
||||
assert!(
|
||||
headers
|
||||
@@ -2362,7 +2386,7 @@ async fn remote_optimize_on_a_branch_submits_a_with_clause_over_sql() {
|
||||
|
||||
assert_eq!(
|
||||
*statements.lock().unwrap(),
|
||||
["OPTIMIZE TABLE \"events\" REWRITE DATA WITH (branch = 'o''brien')"]
|
||||
["OPTIMIZE \"events\" REWRITE DATA WITH (branch = 'o''brien')"]
|
||||
);
|
||||
shutdown.send(()).unwrap();
|
||||
}
|
||||
@@ -2426,7 +2450,7 @@ async fn remote_optimize_full_skips_prune_and_index() {
|
||||
);
|
||||
assert_eq!(
|
||||
*statements.lock().unwrap(),
|
||||
["OPTIMIZE TABLE \"events\" REWRITE DATA"]
|
||||
["OPTIMIZE \"events\" REWRITE DATA"]
|
||||
);
|
||||
shutdown.send(()).unwrap();
|
||||
}
|
||||
@@ -3612,3 +3636,109 @@ fn sql_status_reports_structured_resource_identity() {
|
||||
assert_eq!(resource.name, "missing");
|
||||
assert_eq!(resource.namespace_path, ["ns"]);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn remote_optimize_forwards_per_job_options_on_main_and_branch() {
|
||||
for branch in [None, Some("o'brien")] {
|
||||
let service = TestSqlService {
|
||||
adaptive: true,
|
||||
..Default::default()
|
||||
};
|
||||
let statements = service.statements.clone();
|
||||
let headers = service.headers.clone();
|
||||
let (sql_client, shutdown) = start_sql_service(service, ClientConfig::default()).await;
|
||||
let client = client_with_handler(|request| -> http::Response<String> {
|
||||
panic!("unexpected REST request: {}", request.url().path());
|
||||
});
|
||||
let table = RemoteTable::new_with_sql_client(
|
||||
client,
|
||||
"analytics".into(),
|
||||
"events".into(),
|
||||
vec!["team".into()],
|
||||
"team$events".into(),
|
||||
Default::default(),
|
||||
Some(sql_client),
|
||||
)
|
||||
.with_branch(branch.map(str::to_string));
|
||||
table
|
||||
.optimize(crate::table::optimize::OptimizeAction::Compact {
|
||||
options: crate::table::optimize::CompactionOptions {
|
||||
target_rows_per_fragment: 100,
|
||||
max_source_rows: Some(500),
|
||||
io_buffer_size: Some(0),
|
||||
batch_size: Some(16),
|
||||
..Default::default()
|
||||
},
|
||||
remap_options: None,
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
let prefix = if branch.is_some() {
|
||||
"branch = 'o''brien', "
|
||||
} else {
|
||||
""
|
||||
};
|
||||
assert_eq!(
|
||||
*statements.lock().unwrap(),
|
||||
[format!(
|
||||
"OPTIMIZE \"events\" REWRITE DATA WITH ({prefix}target_rows_per_fragment = 100, max_source_rows = 500, io_buffer_size = 0, batch_size = 16)"
|
||||
)]
|
||||
);
|
||||
assert!(
|
||||
headers
|
||||
.lock()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.all(|h| h.namespace_path == "team")
|
||||
);
|
||||
shutdown.send(()).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn remote_compact_preserves_omissions_and_explicit_default_values() {
|
||||
use crate::table::{CompactionOptions, CompactionOverrides};
|
||||
let target = CompactionOptions::default().target_rows_per_fragment;
|
||||
for (options, suffix) in [
|
||||
(CompactionOverrides::default(), String::new()),
|
||||
(
|
||||
CompactionOverrides {
|
||||
target_rows_per_fragment: Some(target),
|
||||
..Default::default()
|
||||
},
|
||||
format!(" WITH (target_rows_per_fragment = {target})"),
|
||||
),
|
||||
(
|
||||
CompactionOverrides {
|
||||
io_buffer_size: Some(0),
|
||||
..Default::default()
|
||||
},
|
||||
" WITH (io_buffer_size = 0)".into(),
|
||||
),
|
||||
] {
|
||||
let service = TestSqlService {
|
||||
adaptive: true,
|
||||
..Default::default()
|
||||
};
|
||||
let statements = service.statements.clone();
|
||||
let (sql_client, shutdown) = start_sql_service(service, ClientConfig::default()).await;
|
||||
let client = client_with_handler(|request| -> http::Response<String> {
|
||||
panic!("unexpected REST request: {}", request.url().path());
|
||||
});
|
||||
let table = RemoteTable::new_with_sql_client(
|
||||
client,
|
||||
"analytics".into(),
|
||||
"events".into(),
|
||||
vec![],
|
||||
"events".into(),
|
||||
Default::default(),
|
||||
Some(sql_client),
|
||||
);
|
||||
table.compact(options).await.unwrap();
|
||||
assert_eq!(
|
||||
*statements.lock().unwrap(),
|
||||
[format!("OPTIMIZE \"events\" REWRITE DATA{suffix}")]
|
||||
);
|
||||
shutdown.send(()).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
pub mod blobs;
|
||||
pub mod insert;
|
||||
mod optimize;
|
||||
|
||||
use self::insert::{RemoteWriteExec, WriteOp};
|
||||
use super::client::RequestResultExt;
|
||||
@@ -2378,6 +2379,17 @@ impl<S: HttpSend> BaseTable for RemoteTable<S> {
|
||||
source_version: Option<u64>,
|
||||
full: bool,
|
||||
) -> Result<Job<RefreshMaterializedViewResult>> {
|
||||
self.refresh_materialized_view_async_with_options(source_version, full, Default::default())
|
||||
.await
|
||||
}
|
||||
|
||||
async fn refresh_materialized_view_async_with_options(
|
||||
&self,
|
||||
source_version: Option<u64>,
|
||||
full: bool,
|
||||
options: crate::materialized_view::RefreshMaterializedViewOptions,
|
||||
) -> Result<Job<RefreshMaterializedViewResult>> {
|
||||
let with_clause = options.sql_clause(full)?;
|
||||
self.check_mutable().await?;
|
||||
if source_version.is_some() {
|
||||
return Err(Error::NotSupported {
|
||||
@@ -2391,7 +2403,7 @@ impl<S: HttpSend> BaseTable for RemoteTable<S> {
|
||||
let statement = format!(
|
||||
"REFRESH MATERIALIZED VIEW {}{}",
|
||||
quote_sql_identifier(&self.name),
|
||||
if full { " WITH (full = true)" } else { "" },
|
||||
with_clause,
|
||||
);
|
||||
let namespace = self.namespace.clone();
|
||||
let client = self.client.clone();
|
||||
@@ -3662,9 +3674,9 @@ impl<S: HttpSend> BaseTable for RemoteTable<S> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
/// Only `OptimizeAction::Compact` with default `options` and no custom
|
||||
/// Only `OptimizeAction::Compact` with supported `options` and no custom
|
||||
/// `remap_options` is supported remotely: it submits a durable
|
||||
/// compaction job through the server's `OPTIMIZE TABLE ... REWRITE DATA`
|
||||
/// compaction job through the server's `OPTIMIZE ... REWRITE DATA`
|
||||
/// SQL statement, the same atomic, single-worker, index-safe path the
|
||||
/// server uses for its own automatic compaction. `.wait()` below waits
|
||||
/// for that SQL statement's own execution to finish, which only confirms
|
||||
@@ -3680,11 +3692,12 @@ impl<S: HttpSend> BaseTable for RemoteTable<S> {
|
||||
/// optimization. A branch-scoped table handle submits a
|
||||
/// `WITH (branch = '<branch>')` clause; the statement does not itself
|
||||
/// validate the branch exists, so a nonexistent branch surfaces as an
|
||||
/// async job failure rather than an error from this call. A non-default
|
||||
/// `CompactionOptions` (for example `target_rows_per_fragment` or
|
||||
/// `max_source_bytes`) is rejected: the SQL statement has no `WITH`
|
||||
/// clause to carry it yet, so accepting it would silently ignore
|
||||
/// settings a caller may be relying on to bound the job.
|
||||
/// async job failure rather than an error from this call. Per-job
|
||||
/// `target_rows_per_fragment`, `max_source_rows`, `io_buffer_size`, and
|
||||
/// `batch_size` are forwarded in the SQL `WITH` clause. Other non-default
|
||||
/// options are rejected before submission. Servers must support these
|
||||
/// SQL options; an older server's error is returned without retrying
|
||||
/// with the settings removed.
|
||||
async fn optimize(&self, action: OptimizeAction) -> Result<OptimizeStats> {
|
||||
self.check_mutable().await?;
|
||||
let OptimizeAction::Compact {
|
||||
@@ -3707,26 +3720,34 @@ impl<S: HttpSend> BaseTable for RemoteTable<S> {
|
||||
.into(),
|
||||
});
|
||||
}
|
||||
if *options != lance::dataset::optimize::CompactionOptions::default() {
|
||||
return Err(Error::NotSupported {
|
||||
message: "custom CompactionOptions are not supported in LanceDB \
|
||||
Enterprise; the OPTIMIZE TABLE ... REWRITE DATA SQL \
|
||||
statement has no WITH clause to carry them yet, so a \
|
||||
non-default value would be silently ignored rather than \
|
||||
applied. Omit options to use the server's managed \
|
||||
compaction settings."
|
||||
.into(),
|
||||
});
|
||||
let mut overrides = crate::table::optimize::CompactionOverrides::try_from(options.clone())?;
|
||||
// The legacy Lance options type has no presence bit for this field.
|
||||
// Use Table::compact to explicitly send a target equal to Lance's default.
|
||||
if options.target_rows_per_fragment
|
||||
== crate::table::CompactionOptions::default().target_rows_per_fragment
|
||||
{
|
||||
overrides.target_rows_per_fragment = None;
|
||||
}
|
||||
self.compact(overrides).await
|
||||
}
|
||||
|
||||
async fn compact(
|
||||
&self,
|
||||
options: crate::table::optimize::CompactionOverrides,
|
||||
) -> Result<OptimizeStats> {
|
||||
self.check_mutable().await?;
|
||||
let compaction_options = optimize::compaction_sql_options(&options)?;
|
||||
let sql_client = self.sql_client.clone().ok_or_else(|| Error::NotSupported {
|
||||
message: "SQL is unavailable for this remote table client".to_string(),
|
||||
})?;
|
||||
let mut statement = format!(
|
||||
"OPTIMIZE TABLE {} REWRITE DATA",
|
||||
quote_sql_identifier(&self.name)
|
||||
);
|
||||
let mut statement = format!("OPTIMIZE {} REWRITE DATA", quote_sql_identifier(&self.name));
|
||||
let mut sql_options = Vec::new();
|
||||
if let Some(branch) = &self.branch {
|
||||
statement.push_str(&format!(" WITH (branch = {})", quote_sql_string(branch)));
|
||||
sql_options.push(format!("branch = {}", quote_sql_string(branch)));
|
||||
}
|
||||
sql_options.extend(compaction_options);
|
||||
if !sql_options.is_empty() {
|
||||
statement.push_str(&format!(" WITH ({})", sql_options.join(", ")));
|
||||
}
|
||||
// `OptimizeStats` carries `lance::dataset::optimize` metric types that
|
||||
// are not `Serialize`/`Deserialize`/`Clone`, which `Job<T>` requires,
|
||||
@@ -15863,7 +15884,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_optimize_rejects_non_default_compaction_options() {
|
||||
async fn test_optimize_rejects_unsupported_compaction_options() {
|
||||
let table = Table::new_with_handler("my_table", move |_| -> http::Response<String> {
|
||||
panic!("custom compaction options must be rejected before any request is sent")
|
||||
});
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
||||
|
||||
//! Compaction options supported by the remote SQL submission protocol.
|
||||
use crate::error::{Error, Result};
|
||||
|
||||
pub(super) fn compaction_sql_options(
|
||||
options: &crate::table::optimize::CompactionOverrides,
|
||||
) -> Result<Vec<String>> {
|
||||
for (name, value) in [
|
||||
("target_rows_per_fragment", options.target_rows_per_fragment),
|
||||
("max_source_rows", options.max_source_rows),
|
||||
("batch_size", options.batch_size),
|
||||
] {
|
||||
if value == Some(0) {
|
||||
return Err(Error::InvalidInput {
|
||||
message: format!("{name} must be greater than 0"),
|
||||
});
|
||||
}
|
||||
}
|
||||
let mut result = Vec::new();
|
||||
for (name, value) in [
|
||||
(
|
||||
"target_rows_per_fragment",
|
||||
options.target_rows_per_fragment.map(|v| v as u64),
|
||||
),
|
||||
("max_source_rows", options.max_source_rows.map(|v| v as u64)),
|
||||
("io_buffer_size", options.io_buffer_size),
|
||||
("batch_size", options.batch_size.map(|v| v as u64)),
|
||||
] {
|
||||
if let Some(value) = value {
|
||||
result.push(format!("{name} = {value}"));
|
||||
}
|
||||
}
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::table::{CompactionOptions, CompactionOverrides};
|
||||
|
||||
#[test]
|
||||
fn omissions_and_explicit_default_target_are_distinct() {
|
||||
assert!(
|
||||
compaction_sql_options(&CompactionOverrides::default())
|
||||
.unwrap()
|
||||
.is_empty()
|
||||
);
|
||||
let target = CompactionOptions::default().target_rows_per_fragment;
|
||||
assert_eq!(
|
||||
compaction_sql_options(&CompactionOverrides {
|
||||
target_rows_per_fragment: Some(target),
|
||||
io_buffer_size: Some(0),
|
||||
..Default::default()
|
||||
})
|
||||
.unwrap(),
|
||||
[
|
||||
format!("target_rows_per_fragment = {target}"),
|
||||
"io_buffer_size = 0".into()
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unsupported_settings_are_rejected() {
|
||||
assert!(matches!(
|
||||
CompactionOverrides::try_from(CompactionOptions {
|
||||
max_source_bytes: Some(1024),
|
||||
..Default::default()
|
||||
}),
|
||||
Err(Error::NotSupported { .. })
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid_row_settings_are_rejected() {
|
||||
for options in [
|
||||
CompactionOverrides {
|
||||
target_rows_per_fragment: Some(0),
|
||||
..Default::default()
|
||||
},
|
||||
CompactionOverrides {
|
||||
max_source_rows: Some(0),
|
||||
..Default::default()
|
||||
},
|
||||
CompactionOverrides {
|
||||
batch_size: Some(0),
|
||||
..Default::default()
|
||||
},
|
||||
] {
|
||||
assert!(matches!(
|
||||
compaction_sql_options(&options),
|
||||
Err(Error::InvalidInput { .. })
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -111,7 +111,8 @@ pub use lance::dataset::refs::{BranchContents, Ref, TagContents, Tags as LanceTa
|
||||
pub use lance::dataset::scanner::DatasetRecordBatchStream;
|
||||
pub use lance_index::optimize::OptimizeOptions;
|
||||
pub use optimize::{
|
||||
CompactionMode, CompactionOptions, IndexRemapMode, OptimizeAction, OptimizeStats,
|
||||
CompactionMode, CompactionOptions, CompactionOverrides, IndexRemapMode, OptimizeAction,
|
||||
OptimizeStats,
|
||||
};
|
||||
pub use refresh::{RefreshColumnOptions, RefreshColumnResult};
|
||||
pub use rte_stats::{MemtableStats, RTEStats, SsTableStats, TableShardStats};
|
||||
@@ -595,6 +596,25 @@ pub trait BaseTable: std::fmt::Display + std::fmt::Debug + Send + Sync {
|
||||
.append_to("remote materialized-view refresh is not supported on this table type"),
|
||||
})
|
||||
}
|
||||
/// Submit an Enterprise refresh with aggregate resource caps and GPU placement.
|
||||
#[doc(hidden)]
|
||||
async fn refresh_materialized_view_async_with_options(
|
||||
&self,
|
||||
source_version: Option<u64>,
|
||||
full: bool,
|
||||
options: crate::materialized_view::RefreshMaterializedViewOptions,
|
||||
) -> Result<Job<crate::materialized_view::RefreshMaterializedViewResult>> {
|
||||
options.validate()?;
|
||||
if !options.is_empty() {
|
||||
return Err(Error::NotSupported {
|
||||
message:
|
||||
"this table cannot enforce materialized-view resource budgets or GPU placement"
|
||||
.into(),
|
||||
});
|
||||
}
|
||||
self.refresh_materialized_view_async(source_version, full)
|
||||
.await
|
||||
}
|
||||
/// Create a read-only handle pinned to the table's current active revision.
|
||||
///
|
||||
/// The returned handle is independent from later refreshes or checkouts on
|
||||
@@ -842,6 +862,14 @@ pub trait BaseTable: std::fmt::Display + std::fmt::Debug + Send + Sync {
|
||||
async fn tags(&self) -> Result<Box<dyn Tags + '_>>;
|
||||
/// Optimize the dataset.
|
||||
async fn optimize(&self, action: OptimizeAction) -> Result<OptimizeStats>;
|
||||
/// Compact with optional fields, preserving remote policy inheritance.
|
||||
async fn compact(&self, options: optimize::CompactionOverrides) -> Result<OptimizeStats> {
|
||||
self.optimize(OptimizeAction::Compact {
|
||||
options: options.into_options(),
|
||||
remap_options: None,
|
||||
})
|
||||
.await
|
||||
}
|
||||
/// Add columns to the table.
|
||||
async fn add_columns(
|
||||
&self,
|
||||
@@ -1925,14 +1953,62 @@ impl Table {
|
||||
///
|
||||
/// # LanceDB Enterprise (remote tables)
|
||||
///
|
||||
/// Only [`OptimizeAction::Compact`] with default `options` and no custom
|
||||
/// `remap_options` is supported; `All`, `Prune`, and `Index` return
|
||||
/// [`OptimizeAction::Compact`] supports per-job `target_rows_per_fragment`,
|
||||
/// `max_source_rows`, `io_buffer_size`, and `batch_size`, with no custom
|
||||
/// `remap_options`. Other non-default options, `All`, `Prune`, and `Index` return
|
||||
/// [`crate::Error::NotSupported`]. See [`OptimizeAction::Compact`] for
|
||||
/// what a remote call submits and what it does and does not wait for.
|
||||
pub async fn optimize(&self, action: OptimizeAction) -> Result<OptimizeStats> {
|
||||
self.inner.optimize(action).await
|
||||
}
|
||||
|
||||
/// Compact data files with optional tuning fields. On remote tables,
|
||||
/// omitted fields inherit table tuning, then deployment/built-in defaults.
|
||||
/// Returns after job submission; remote statistics are placeholders.
|
||||
///
|
||||
/// ```
|
||||
/// use lancedb::{Table, table::optimize::CompactionOverrides};
|
||||
/// # async fn compact(table: &Table) -> lancedb::Result<()> {
|
||||
/// table.compact(CompactionOverrides {
|
||||
/// io_buffer_size: Some(64 * 1024 * 1024),
|
||||
/// ..Default::default()
|
||||
/// }).await?;
|
||||
/// # Ok(())
|
||||
/// # }
|
||||
/// ```
|
||||
pub async fn compact(&self, options: optimize::CompactionOverrides) -> Result<OptimizeStats> {
|
||||
self.inner.compact(options).await
|
||||
}
|
||||
|
||||
/// Language-binding entry point retaining optional compaction fields.
|
||||
#[doc(hidden)]
|
||||
pub async fn optimize_full_with_overrides(
|
||||
&self,
|
||||
options: optimize::CompactionOverrides,
|
||||
older_than: Option<chrono::Duration>,
|
||||
before_timestamp: Option<chrono::DateTime<chrono::Utc>>,
|
||||
delete_unverified: Option<bool>,
|
||||
) -> Result<OptimizeStats> {
|
||||
if self.as_native().is_some() {
|
||||
return self
|
||||
.optimize_full(
|
||||
options.into_options(),
|
||||
older_than,
|
||||
before_timestamp,
|
||||
delete_unverified,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
if older_than.is_some() || before_timestamp.is_some() || delete_unverified == Some(true) {
|
||||
return Err(Error::NotSupported { message: "pruning is not supported in LanceDB Enterprise; omit pruning options to run compaction only".into() });
|
||||
}
|
||||
let stats = self.compact(options).await?;
|
||||
Ok(OptimizeStats {
|
||||
compaction: stats.compaction,
|
||||
prune: Some(RemovalStats::default()),
|
||||
})
|
||||
}
|
||||
|
||||
/// Prune versions committed before an absolute timestamp.
|
||||
///
|
||||
/// This is an internal entry point for language bindings whose public API
|
||||
@@ -1966,10 +2042,10 @@ impl Table {
|
||||
///
|
||||
/// This is an internal entry point for language bindings. On a remote
|
||||
/// table (LanceDB Enterprise) only [`OptimizeAction::Compact`] with its
|
||||
/// defaults is supported. A caller asking for anything pruning-related
|
||||
/// supported per-job options is supported. A caller asking for anything pruning-related
|
||||
/// (`older_than`, `before_timestamp`, or `delete_unverified: Some(true)`)
|
||||
/// gets `NotSupported` before anything is submitted, the same way a
|
||||
/// non-default `CompactionOptions` is already rejected -- rather than a
|
||||
/// gets `NotSupported` before anything is submitted, the same way
|
||||
/// unsupported `CompactionOptions` are rejected -- rather than a
|
||||
/// success that silently reports zero bytes pruned when nothing was
|
||||
/// pruned at all. A plain call with none of those set only compacts:
|
||||
/// `Prune` and `Index` are skipped here rather than attempted and
|
||||
|
||||
@@ -184,6 +184,53 @@ async fn validate_sq_index_remapping(
|
||||
Ok(plan)
|
||||
}
|
||||
|
||||
/// Optional compaction tuning. Remote tables inherit omitted values from table
|
||||
/// policy, then deployment/built-in defaults. Explicit values, including a zero
|
||||
/// I/O budget, take precedence. Local tables use Lance defaults for omissions.
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq)]
|
||||
pub struct CompactionOverrides {
|
||||
pub target_rows_per_fragment: Option<usize>,
|
||||
pub max_source_rows: Option<usize>,
|
||||
/// Read-ahead budget in bytes; zero disables byte-based I/O backpressure.
|
||||
pub io_buffer_size: Option<u64>,
|
||||
pub batch_size: Option<usize>,
|
||||
}
|
||||
|
||||
impl CompactionOverrides {
|
||||
pub(crate) fn into_options(self) -> CompactionOptions {
|
||||
let mut options = CompactionOptions::default();
|
||||
if let Some(target) = self.target_rows_per_fragment {
|
||||
options.target_rows_per_fragment = target;
|
||||
}
|
||||
options.max_source_rows = self.max_source_rows;
|
||||
options.io_buffer_size = self.io_buffer_size;
|
||||
options.batch_size = self.batch_size;
|
||||
options
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<CompactionOptions> for CompactionOverrides {
|
||||
type Error = Error;
|
||||
|
||||
fn try_from(options: CompactionOptions) -> Result<Self> {
|
||||
let mut remaining = options.clone();
|
||||
let defaults = CompactionOptions::default();
|
||||
remaining.target_rows_per_fragment = defaults.target_rows_per_fragment;
|
||||
remaining.max_source_rows = defaults.max_source_rows;
|
||||
remaining.io_buffer_size = defaults.io_buffer_size;
|
||||
remaining.batch_size = defaults.batch_size;
|
||||
if remaining != defaults {
|
||||
return Err(Error::NotSupported { message: "remote CompactionOptions support only target_rows_per_fragment, max_source_rows, io_buffer_size, and batch_size; other options must retain their defaults".into() });
|
||||
}
|
||||
Ok(Self {
|
||||
target_rows_per_fragment: Some(options.target_rows_per_fragment),
|
||||
max_source_rows: options.max_source_rows,
|
||||
io_buffer_size: options.io_buffer_size,
|
||||
batch_size: options.batch_size,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Optimize the dataset.
|
||||
///
|
||||
/// Similar to `VACUUM` in PostgreSQL, it offers different options to
|
||||
@@ -209,9 +256,24 @@ pub enum OptimizeAction {
|
||||
///
|
||||
/// # LanceDB Enterprise (remote tables)
|
||||
///
|
||||
/// A remote table only supports `Compact` with default `options` and no
|
||||
/// custom `remap_options`; both are rejected with
|
||||
/// [`crate::Error::NotSupported`] otherwise. It submits a durable
|
||||
/// A remote table supports per-job `target_rows_per_fragment`,
|
||||
/// `max_source_rows`, `io_buffer_size`, and `batch_size`. Other non-default
|
||||
/// options and custom `remap_options` return [`crate::Error::NotSupported`]
|
||||
/// before submission. The server must support these SQL options; errors
|
||||
/// from older servers are returned without dropping the settings.
|
||||
/// The source-row budget admits whole tasks and may perform no work when
|
||||
/// the first task exceeds it. Zero I/O buffer size disables byte-based I/O
|
||||
/// backpressure. Use a positive size to limit I/O read-ahead; this is not a
|
||||
/// total-memory limit. Row targets, source-row budgets, and batch sizes must
|
||||
/// be positive.
|
||||
/// The legacy Lance options type cannot distinguish an omitted fragment target
|
||||
/// from its default value; that default is treated as unspecified remotely.
|
||||
/// Use [`crate::Table::compact`] with [`CompactionOverrides`] to explicitly
|
||||
/// override a table target with the Lance default value.
|
||||
/// Omitted options inherit table tuning, then deployment/built-in defaults; options
|
||||
/// affect only this job, without changing ongoing table policy.
|
||||
///
|
||||
/// It submits a durable
|
||||
/// compaction job to the server over SQL and waits for that submission to
|
||||
/// be confirmed, not for compaction itself to finish: the job then runs
|
||||
/// asynchronously on the server, so this call can return well before the
|
||||
@@ -219,6 +281,23 @@ pub enum OptimizeAction {
|
||||
/// [`OptimizeStats::compaction`] is a zeroed [`CompactionMetrics`]
|
||||
/// placeholder rather than the real counts a local table reports.
|
||||
///
|
||||
/// ```
|
||||
/// use lancedb::{Table, table::{CompactionOptions, OptimizeAction}};
|
||||
/// # async fn compact(table: &Table) -> lancedb::Result<()> {
|
||||
/// table.optimize(OptimizeAction::Compact {
|
||||
/// options: CompactionOptions {
|
||||
/// target_rows_per_fragment: 100_000,
|
||||
/// max_source_rows: Some(1_000_000),
|
||||
/// io_buffer_size: Some(64 * 1024 * 1024),
|
||||
/// batch_size: Some(1024),
|
||||
/// ..Default::default()
|
||||
/// },
|
||||
/// remap_options: None,
|
||||
/// }).await?;
|
||||
/// # Ok(())
|
||||
/// # }
|
||||
/// ```
|
||||
///
|
||||
/// A branch-scoped table handle compacts that branch. The branch is not
|
||||
/// validated to exist before the job is submitted, so a nonexistent
|
||||
/// branch fails the compaction job asynchronously rather than failing
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "lance-linalg"
|
||||
version = "15.0.0-beta.14"
|
||||
version = "15.0.0-beta.15"
|
||||
publish = false
|
||||
edition = { workspace = true }
|
||||
license = { workspace = true }
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
This directory contains `rust/lance-linalg` from Lance tag `v15.0.0-beta.14`
|
||||
(commit `3bb1550f4f27adf90948ff36c2318768e675b599`), licensed under Apache-2.0.
|
||||
This directory contains `rust/lance-linalg` from Lance tag `v15.0.0-beta.15`
|
||||
(commit `a826a940d550ee1f3bb5b470c3e10e670c1e38ce`), licensed under Apache-2.0.
|
||||
|
||||
LanceDB patches `src/distance/cosine.rs` to recompute FLOAT32 cosine distances
|
||||
in FLOAT64 when squared norms or dot products overflow or underflow. Ordinary
|
||||
|
||||
+17
-56
@@ -1117,71 +1117,32 @@ mod tests {
|
||||
do_dot_test(&x, &y)?;
|
||||
}
|
||||
|
||||
/// Cross-backend parity: scalar fallback must match the dispatched
|
||||
/// SIMD path within numerical tolerance. Exercises `dot_f64_scalar`
|
||||
/// directly so the runtime fallback is exercised even on AVX2-capable
|
||||
/// CI hosts.
|
||||
/// Every f64 kernel the host supports, plus the runtime dispatch, must
|
||||
/// match the scalar fallback. Calling `dot_f64_scalar` directly
|
||||
/// exercises the fallback even on AVX2-capable CI hosts.
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
#[test]
|
||||
fn test_dot_f64_scalar_simd_parity(
|
||||
fn test_dot_f64_kernels_match_scalar(
|
||||
(x, y) in arbitrary_vector_pair(arbitrary_f64, 4..4048)
|
||||
) {
|
||||
let scalar = dot_f64_scalar(&x, &y);
|
||||
let simd = dot_f64_simd(&x, &y);
|
||||
let max_error = max_error::<f64>(&x, &y);
|
||||
prop_assert!(approx::relative_eq!(scalar, simd, epsilon = max_error));
|
||||
}
|
||||
|
||||
/// AVX-512-direct parity: explicitly compares the scalar fallback
|
||||
/// against the native AVX-512 inner kernel on AVX-512F-capable hosts
|
||||
/// (Skylake-X+, Ice Lake, Sapphire Rapids, Zen 4). Early-returns on
|
||||
/// hosts without AVX-512F.
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
#[test]
|
||||
fn test_dot_f64_scalar_vs_avx512_parity(
|
||||
(x, y) in arbitrary_vector_pair(arbitrary_f64, 4..4048)
|
||||
) {
|
||||
if !std::is_x86_feature_detected!("avx512f") {
|
||||
return Ok(());
|
||||
let mut results = vec![("dispatched", dot_f64_simd(&x, &y))];
|
||||
if std::is_x86_feature_detected!("avx512f") {
|
||||
results.push(("avx512", unsafe { x86::dot_f64_avx512(&x, &y) }));
|
||||
}
|
||||
let scalar = dot_f64_scalar(&x, &y);
|
||||
let avx512 = unsafe { x86::dot_f64_avx512(&x, &y) };
|
||||
let max_error = max_error::<f64>(&x, &y);
|
||||
prop_assert!(approx::relative_eq!(scalar, avx512, epsilon = max_error));
|
||||
}
|
||||
|
||||
/// AVX + FMA-direct parity for the f64 dot kernel. Covers the AMD
|
||||
/// Piledriver / Steamroller / FX-7500 tier. Early-returns on hosts
|
||||
/// without both AVX and FMA.
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
#[test]
|
||||
fn test_dot_f64_scalar_vs_avx_fma_parity(
|
||||
(x, y) in arbitrary_vector_pair(arbitrary_f64, 4..4048)
|
||||
) {
|
||||
if !(std::is_x86_feature_detected!("avx") && std::is_x86_feature_detected!("fma")) {
|
||||
return Ok(());
|
||||
if std::is_x86_feature_detected!("avx") && std::is_x86_feature_detected!("fma") {
|
||||
results.push(("avx_fma", unsafe { x86::dot_f64_avx_fma(&x, &y) }));
|
||||
}
|
||||
let scalar = dot_f64_scalar(&x, &y);
|
||||
let avx_fma = unsafe { x86::dot_f64_avx_fma(&x, &y) };
|
||||
let max_error = max_error::<f64>(&x, &y);
|
||||
prop_assert!(approx::relative_eq!(scalar, avx_fma, epsilon = max_error));
|
||||
}
|
||||
|
||||
/// AVX-only-direct parity for the f64 dot kernel. Covers the Intel
|
||||
/// Sandy Bridge / Ivy Bridge tier (AVX without FMA). Early-returns
|
||||
/// on hosts without AVX.
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
#[test]
|
||||
fn test_dot_f64_scalar_vs_avx_parity(
|
||||
(x, y) in arbitrary_vector_pair(arbitrary_f64, 4..4048)
|
||||
) {
|
||||
if !std::is_x86_feature_detected!("avx") {
|
||||
return Ok(());
|
||||
if std::is_x86_feature_detected!("avx") {
|
||||
results.push(("avx", unsafe { x86::dot_f64_avx(&x, &y) }));
|
||||
}
|
||||
for (kernel, got) in results {
|
||||
prop_assert!(
|
||||
approx::relative_eq!(scalar, got, epsilon = max_error),
|
||||
"{kernel}: {got} != scalar {scalar}"
|
||||
);
|
||||
}
|
||||
let scalar = dot_f64_scalar(&x, &y);
|
||||
let avx = unsafe { x86::dot_f64_avx(&x, &y) };
|
||||
let max_error = max_error::<f64>(&x, &y);
|
||||
prop_assert!(approx::relative_eq!(scalar, avx, epsilon = max_error));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+17
-53
@@ -1381,67 +1381,31 @@ mod tests {
|
||||
do_l2_test(&x, &y)?;
|
||||
}
|
||||
|
||||
/// Cross-backend parity: scalar fallback must match the dispatched
|
||||
/// SIMD path within numerical tolerance. Exercises `l2_f64_scalar`
|
||||
/// directly so the runtime fallback is exercised even on AVX2-capable
|
||||
/// CI hosts.
|
||||
/// Every f64 kernel the host supports, plus the runtime dispatch, must
|
||||
/// match the scalar fallback. Calling `l2_f64_scalar` directly
|
||||
/// exercises the fallback even on AVX2-capable CI hosts.
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
#[test]
|
||||
fn test_l2_f64_scalar_simd_parity(
|
||||
fn test_l2_f64_kernels_match_scalar(
|
||||
(x, y) in arbitrary_vector_pair(arbitrary_f64, 4..4048)
|
||||
) {
|
||||
let scalar = l2_f64_scalar(&x, &y);
|
||||
let simd = l2_f64_simd(&x, &y);
|
||||
prop_assert!(approx::relative_eq!(scalar, simd, max_relative = 1e-6));
|
||||
}
|
||||
|
||||
/// AVX-512-direct parity: explicitly compares the scalar fallback
|
||||
/// against the native AVX-512 inner kernel on AVX-512F-capable hosts
|
||||
/// (Skylake-X+, Ice Lake, Sapphire Rapids, Zen 4). Early-returns on
|
||||
/// hosts without AVX-512F.
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
#[test]
|
||||
fn test_l2_f64_scalar_vs_avx512_parity(
|
||||
(x, y) in arbitrary_vector_pair(arbitrary_f64, 4..4048)
|
||||
) {
|
||||
if !std::is_x86_feature_detected!("avx512f") {
|
||||
return Ok(());
|
||||
let mut results = vec![("dispatched", l2_f64_simd(&x, &y))];
|
||||
if std::is_x86_feature_detected!("avx512f") {
|
||||
results.push(("avx512", unsafe { x86::l2_f64_avx512(&x, &y) }));
|
||||
}
|
||||
let scalar = l2_f64_scalar(&x, &y);
|
||||
let avx512 = unsafe { x86::l2_f64_avx512(&x, &y) };
|
||||
prop_assert!(approx::relative_eq!(scalar, avx512, max_relative = 1e-6));
|
||||
}
|
||||
|
||||
/// AVX + FMA-direct parity for the f64 L2 kernel. Covers the AMD
|
||||
/// Piledriver / Steamroller / FX-7500 tier. Early-returns on hosts
|
||||
/// without both AVX and FMA.
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
#[test]
|
||||
fn test_l2_f64_scalar_vs_avx_fma_parity(
|
||||
(x, y) in arbitrary_vector_pair(arbitrary_f64, 4..4048)
|
||||
) {
|
||||
if !(std::is_x86_feature_detected!("avx") && std::is_x86_feature_detected!("fma")) {
|
||||
return Ok(());
|
||||
if std::is_x86_feature_detected!("avx") && std::is_x86_feature_detected!("fma") {
|
||||
results.push(("avx_fma", unsafe { x86::l2_f64_avx_fma(&x, &y) }));
|
||||
}
|
||||
let scalar = l2_f64_scalar(&x, &y);
|
||||
let avx_fma = unsafe { x86::l2_f64_avx_fma(&x, &y) };
|
||||
prop_assert!(approx::relative_eq!(scalar, avx_fma, max_relative = 1e-6));
|
||||
}
|
||||
|
||||
/// AVX-only-direct parity for the f64 L2 kernel. Covers the Intel
|
||||
/// Sandy Bridge / Ivy Bridge tier. Early-returns on hosts without
|
||||
/// AVX.
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
#[test]
|
||||
fn test_l2_f64_scalar_vs_avx_parity(
|
||||
(x, y) in arbitrary_vector_pair(arbitrary_f64, 4..4048)
|
||||
) {
|
||||
if !std::is_x86_feature_detected!("avx") {
|
||||
return Ok(());
|
||||
if std::is_x86_feature_detected!("avx") {
|
||||
results.push(("avx", unsafe { x86::l2_f64_avx(&x, &y) }));
|
||||
}
|
||||
for (kernel, got) in results {
|
||||
prop_assert!(
|
||||
approx::relative_eq!(scalar, got, max_relative = 1e-6),
|
||||
"{kernel}: {got} != scalar {scalar}"
|
||||
);
|
||||
}
|
||||
let scalar = l2_f64_scalar(&x, &y);
|
||||
let avx = unsafe { x86::l2_f64_avx(&x, &y) };
|
||||
prop_assert!(approx::relative_eq!(scalar, avx, max_relative = 1e-6));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+34
-94
@@ -525,117 +525,57 @@ mod tests {
|
||||
do_norm_l2_test(&data)?;
|
||||
}
|
||||
|
||||
/// Cross-backend parity: scalar fallback must match the dispatched
|
||||
/// SIMD path within numerical tolerance. Exercises `norm_l2_f64_scalar`
|
||||
/// directly so the runtime fallback is exercised even on AVX2-capable
|
||||
/// CI hosts.
|
||||
/// Every f64 kernel the host supports, plus the runtime dispatch, must
|
||||
/// match the scalar fallback. Calling `norm_l2_f64_scalar` directly
|
||||
/// exercises the fallback even on AVX2-capable CI hosts.
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
#[test]
|
||||
fn test_l2_norm_f64_scalar_simd_parity(
|
||||
fn test_l2_norm_f64_kernels_match_scalar(
|
||||
data in prop::collection::vec(arbitrary_f64(), 4..4048)
|
||||
) {
|
||||
let scalar = norm_l2_f64_scalar(&data);
|
||||
let simd = norm_l2_f64_simd(&data);
|
||||
prop_assert!(approx::relative_eq!(scalar, simd, max_relative = 1e-6));
|
||||
}
|
||||
|
||||
/// AVX-512-direct parity: explicitly compares the scalar fallback
|
||||
/// against the native AVX-512 inner kernel on AVX-512F-capable hosts
|
||||
/// (Skylake-X+, Ice Lake, Sapphire Rapids, Zen 4). Early-returns on
|
||||
/// hosts without AVX-512F so the test stays portable; CI runners with
|
||||
/// AVX-512F exercise the `_mm512_*` path.
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
#[test]
|
||||
fn test_l2_norm_f64_scalar_vs_avx512_parity(
|
||||
data in prop::collection::vec(arbitrary_f64(), 4..4048)
|
||||
) {
|
||||
if !std::is_x86_feature_detected!("avx512f") {
|
||||
return Ok(());
|
||||
let mut results = vec![("dispatched", norm_l2_f64_simd(&data))];
|
||||
if std::is_x86_feature_detected!("avx512f") {
|
||||
results.push(("avx512", unsafe { x86::norm_l2_f64_avx512(&data) }));
|
||||
}
|
||||
let scalar = norm_l2_f64_scalar(&data);
|
||||
let avx512 = unsafe { x86::norm_l2_f64_avx512(&data) };
|
||||
prop_assert!(approx::relative_eq!(scalar, avx512, max_relative = 1e-6));
|
||||
}
|
||||
|
||||
/// AVX + FMA-direct parity for the f64 L2-norm kernel. Covers the
|
||||
/// AMD Piledriver / Steamroller / FX-7500 tier. Early-returns on
|
||||
/// hosts without both AVX and FMA.
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
#[test]
|
||||
fn test_l2_norm_f64_scalar_vs_avx_fma_parity(
|
||||
data in prop::collection::vec(arbitrary_f64(), 4..4048)
|
||||
) {
|
||||
if !(std::is_x86_feature_detected!("avx") && std::is_x86_feature_detected!("fma")) {
|
||||
return Ok(());
|
||||
if std::is_x86_feature_detected!("avx") && std::is_x86_feature_detected!("fma") {
|
||||
results.push(("avx_fma", unsafe { x86::norm_l2_f64_avx_fma(&data) }));
|
||||
}
|
||||
let scalar = norm_l2_f64_scalar(&data);
|
||||
let avx_fma = unsafe { x86::norm_l2_f64_avx_fma(&data) };
|
||||
prop_assert!(approx::relative_eq!(scalar, avx_fma, max_relative = 1e-6));
|
||||
}
|
||||
|
||||
/// AVX-only-direct parity for the f64 L2-norm kernel. Covers the
|
||||
/// Intel Sandy Bridge / Ivy Bridge tier (AVX without FMA).
|
||||
/// Early-returns on hosts without AVX.
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
#[test]
|
||||
fn test_l2_norm_f64_scalar_vs_avx_parity(
|
||||
data in prop::collection::vec(arbitrary_f64(), 4..4048)
|
||||
) {
|
||||
if !std::is_x86_feature_detected!("avx") {
|
||||
return Ok(());
|
||||
if std::is_x86_feature_detected!("avx") {
|
||||
results.push(("avx", unsafe { x86::norm_l2_f64_avx(&data) }));
|
||||
}
|
||||
for (kernel, got) in results {
|
||||
prop_assert!(
|
||||
approx::relative_eq!(scalar, got, max_relative = 1e-6),
|
||||
"{kernel}: {got} != scalar {scalar}"
|
||||
);
|
||||
}
|
||||
let scalar = norm_l2_f64_scalar(&data);
|
||||
let avx = unsafe { x86::norm_l2_f64_avx(&data) };
|
||||
prop_assert!(approx::relative_eq!(scalar, avx, max_relative = 1e-6));
|
||||
}
|
||||
|
||||
/// AVX-512-direct parity for the f32 L2-norm kernel. Explicitly
|
||||
/// compares the scalar fallback against the native AVX-512 inner
|
||||
/// kernel on AVX-512F-capable hosts. Early-returns on hosts without
|
||||
/// AVX-512F; CI runners with AVX-512F exercise the `_mm512_*` path.
|
||||
/// Every f32 x86 kernel the host supports must match the scalar
|
||||
/// fallback.
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
#[test]
|
||||
fn test_norm_l2_f32_scalar_vs_avx512_parity(
|
||||
fn test_norm_l2_f32_kernels_match_scalar(
|
||||
data in prop::collection::vec(arbitrary_f32(), 4..4048)
|
||||
) {
|
||||
if !std::is_x86_feature_detected!("avx512f") {
|
||||
return Ok(());
|
||||
}
|
||||
let scalar = norm_l2_f32_scalar(&data);
|
||||
let avx512 = unsafe { x86::norm_l2_f32_avx512(&data) };
|
||||
prop_assert!(approx::relative_eq!(scalar, avx512, max_relative = 1e-3));
|
||||
}
|
||||
|
||||
/// AVX + FMA-direct parity for the f32 L2-norm kernel. Covers the
|
||||
/// AMD Piledriver / Steamroller / FX-7500 tier. Early-returns on
|
||||
/// hosts without both AVX and FMA.
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
#[test]
|
||||
fn test_norm_l2_f32_scalar_vs_avx_fma_parity(
|
||||
data in prop::collection::vec(arbitrary_f32(), 4..4048)
|
||||
) {
|
||||
if !(std::is_x86_feature_detected!("avx") && std::is_x86_feature_detected!("fma")) {
|
||||
return Ok(());
|
||||
let mut results = vec![];
|
||||
if std::is_x86_feature_detected!("avx512f") {
|
||||
results.push(("avx512", unsafe { x86::norm_l2_f32_avx512(&data) }));
|
||||
}
|
||||
let scalar = norm_l2_f32_scalar(&data);
|
||||
let avx_fma = unsafe { x86::norm_l2_f32_avx_fma(&data) };
|
||||
prop_assert!(approx::relative_eq!(scalar, avx_fma, max_relative = 1e-3));
|
||||
}
|
||||
|
||||
/// AVX-only-direct parity for the f32 L2-norm kernel. Covers the
|
||||
/// Intel Sandy Bridge / Ivy Bridge tier (AVX without FMA).
|
||||
/// Early-returns on hosts without AVX.
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
#[test]
|
||||
fn test_norm_l2_f32_scalar_vs_avx_parity(
|
||||
data in prop::collection::vec(arbitrary_f32(), 4..4048)
|
||||
) {
|
||||
if !std::is_x86_feature_detected!("avx") {
|
||||
return Ok(());
|
||||
if std::is_x86_feature_detected!("avx") && std::is_x86_feature_detected!("fma") {
|
||||
results.push(("avx_fma", unsafe { x86::norm_l2_f32_avx_fma(&data) }));
|
||||
}
|
||||
if std::is_x86_feature_detected!("avx") {
|
||||
results.push(("avx", unsafe { x86::norm_l2_f32_avx(&data) }));
|
||||
}
|
||||
for (kernel, got) in results {
|
||||
prop_assert!(
|
||||
approx::relative_eq!(scalar, got, max_relative = 1e-3),
|
||||
"{kernel}: {got} != scalar {scalar}"
|
||||
);
|
||||
}
|
||||
let scalar = norm_l2_f32_scalar(&data);
|
||||
let avx = unsafe { x86::norm_l2_f32_avx(&data) };
|
||||
prop_assert!(approx::relative_eq!(scalar, avx, max_relative = 1e-3));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user