Skip to content

feat(index): support distributed optimize for ZoneMap - #10945

Draft
ddupg wants to merge 7 commits into
lance-format:mainfrom
ddupg:codex/zonemap-distributed-optimize
Draft

ddupg wants to merge 7 commits into
lance-format:mainfrom
ddupg:codex/zonemap-distributed-optimize

Conversation

@ddupg

@ddupg ddupg commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Part of #10847.

Closes #11551

ZoneMap optimize currently runs as a single task even when task or segment row limits are configured. This PR adds support for distributing the work across fragment groups.

  • Reuse compatible ZoneMap v1 segments by merging them with newly indexed data.
  • Distribute rebuilds for v0 upgrades and incompatible parameters over the selected segments' live coverage and new fragments.
  • Reuse the shared optimize planning, merge, and commit flow while preserving existing remap and shallow-clone policies.

Earlier validation: optimize tests (64), ZoneMap tests (71), and version tests (5) passed, with overlapping coverage. Rust formatting and Java Spotless passed. Workspace and scoped Clippy are blocked on ARM64 by existing unreachable_code errors in rust/lance-encoding/src/encodings/physical/byte_stream_split.rs:358,393; that file is unchanged from the rebased main.

The seed-reuse boundary test now explicitly triggers a rebuild with incompatible segment parameters. Formatting passed; the final local rerun was interrupted when the Cargo build directory was removed. Validation of this test-only fix is pending CI.

@github-actions github-actions Bot added A-index Vector index, linalg, tokenizer A-java Java bindings + JNI enhancement New feature or request labels Nov 11, 2026
@ddupg
ddupg force-pushed the codex/zonemap-distributed-optimize branch from 5d76ae5 to 37a0f59 Compare November 11, 2026 10:12
@ddupg
ddupg force-pushed the codex/zonemap-distributed-optimize branch 2 times, most recently from 9844507 to 79089bb Compare November 20, 2026 12:19
@wombatu-kun

Copy link
Copy Markdown
Contributor

I ran the regression test from #11551 on both revisions. It fails on main (168623492) and passes on this PR (b140a9ce7).

Could you include the test in this PR and add Closes #11551 to the PR description?

@codecov

codecov Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
11709 1 11708 0
View the full list of 1 ❄️ flaky test(s)
lance::hybrid_udtf::hybrid_field_path_payload::case_2_backtick

Flake rate in main: 100.00% (Passed 0 times, Failed 1 times)

Stack Traces | 0.302s run time
thread 'hybrid_field_path_payload::case_2_backtick' (95290) panicked at .../lance/tests/hybrid_udtf.rs:1059:9:
assertion `left == right` failed: hybrid projection="a`b": RecordBatch { schema: Schema { fields: [Field { name: "a`b", data_type: Int32, nullable: true }], metadata: {} }, columns: [PrimitiveArray<Int32>
[
  null,
  null,
  null,
]], row_count: 3 }
  left: 3
 right: 0
stack backtrace:
   0: __rustc::rust_begin_unwind
             at .../std/src/panicking.rs:679:5
   1: core::panicking::panic_fmt
             at .../core/src/panicking.rs:80:14
   2: core::panicking::assert_failed_inner
             at .../core/src/panicking.rs:434:23
   3: core::panicking::assert_failed::<usize, usize>
             at .../core/src/panicking.rs:394:5
   4: {async_fn#0}
             at ./tests/hybrid_udtf.rs:1059:9
   5: {async_block#0}
             at ./tests/hybrid_udtf.rs:1029:1
   6: poll<&mut dyn core::future::future::Future<Output=()>>
             at .../src/future/future.rs:133:9
   7: {closure#0}<core::pin::Pin<&mut dyn core::future::future::Future<Output=()>>>
             at .................................................../home/runner/.cargo.................................................../registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.54..../scheduler/current_thread/mod.rs:830:70
   8: with_budget<core::task::poll::Poll<()>, tokio::runtime::scheduler::current_thread::{impl#9}::block_on::{closure#0}::{closure#0}::{closure_env#0}<core::pin::Pin<&mut dyn core::future::future::Future<Output=()>>>>
             at .................................................../home/runner/.cargo.................................................../registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.54..../task/coop/mod.rs:167:5
   9: budget<core::task::poll::Poll<()>, tokio::runtime::scheduler::current_thread::{impl#9}::block_on::{closure#0}::{closure#0}::{closure_env#0}<core::pin::Pin<&mut dyn core::future::future::Future<Output=()>>>>
             at .................................................../home/runner/.cargo.................................................../registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.54..../task/coop/mod.rs:133:5
  10: {closure#0}<core::pin::Pin<&mut dyn core::future::future::Future<Output=()>>>
             at .................................................../home/runner/.cargo.................................................../registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.54..../scheduler/current_thread/mod.rs:830:25
  11: <tokio::runtime::scheduler::current_thread::Context>::enter::<core::task::poll::Poll<()>, <tokio::runtime::scheduler::current_thread::CoreGuard>::block_on<core::pin::Pin<&mut dyn core::future::future::Future<Output = ()>>>::{closure#0}::{closure#0}>
             at .................................................../home/runner/.cargo.................................................../registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.54..../scheduler/current_thread/mod.rs:486:19
  12: <tokio::runtime::scheduler::current_thread::CoreGuard>::block_on::<core::pin::Pin<&mut dyn core::future::future::Future<Output = ()>>>::{closure#0}
             at .................................................../home/runner/.cargo.................................................../registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.54..../scheduler/current_thread/mod.rs:829:44
  13: <tokio::runtime::scheduler::current_thread::CoreGuard>::enter::<<tokio::runtime::scheduler::current_thread::CoreGuard>::block_on<core::pin::Pin<&mut dyn core::future::future::Future<Output = ()>>>::{closure#0}, core::option::Option<()>>::{closure#0}
             at .................................................../home/runner/.cargo.................................................../registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.54..../scheduler/current_thread/mod.rs:906:68
  14: <tokio::runtime::context::scoped::Scoped<tokio::runtime::scheduler::Context>>::set::<<tokio::runtime::scheduler::current_thread::CoreGuard>::enter<<tokio::runtime::scheduler::current_thread::CoreGuard>::block_on<core::pin::Pin<&mut dyn core::future::future::Future<Output = ()>>>::{closure#0}, core::option::Option<()>>::{closure#0}, (alloc::boxed::Box<tokio::runtime::scheduler::current_thread::Core>, core::option::Option<()>)>
             at .................................................../home/runner/.cargo.................................................../registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.54..../runtime/context/scoped.rs:40:9
  15: tokio::runtime::context::set_scheduler::<(alloc::boxed::Box<tokio::runtime::scheduler::current_thread::Core>, core::option::Option<()>), <tokio::runtime::scheduler::current_thread::CoreGuard>::enter<<tokio::runtime::scheduler::current_thread::CoreGuard>::block_on<core::pin::Pin<&mut dyn core::future::future::Future<Output = ()>>>::{closure#0}, core::option::Option<()>>::{closure#0}>::{closure#0}
             at .................................................../home/runner/.cargo.................................................../registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.54..../src/runtime/context.rs:186:38
  16: try_with<tokio::runtime::context::Context, tokio::runtime::context::set_scheduler::{closure_env#0}<(alloc::boxed::Box<tokio::runtime::scheduler::current_thread::Core, alloc::alloc::Global>, core::option::Option<()>), tokio::runtime::scheduler::current_thread::{impl#9}::enter::{closure_env#0}<tokio::runtime::scheduler::current_thread::{impl#9}::block_on::{closure_env#0}<core::pin::Pin<&mut dyn core::future::future::Future<Output=()>>>, core::option::Option<()>>>, (alloc::boxed::Box<tokio::runtime::scheduler::current_thread::Core, alloc::alloc::Global>, core::option::Option<()>)>
             at .../src/thread/local.rs:463:12
  17: <std::thread::local::LocalKey<tokio::runtime::context::Context>>::with::<tokio::runtime::context::set_scheduler<(alloc::boxed::Box<tokio::runtime::scheduler::current_thread::Core>, core::option::Option<()>), <tokio::runtime::scheduler::current_thread::CoreGuard>::enter<<tokio::runtime::scheduler::current_thread::CoreGuard>::block_on<core::pin::Pin<&mut dyn core::future::future::Future<Output = ()>>>::{closure#0}, core::option::Option<()>>::{closure#0}>::{closure#0}, (alloc::boxed::Box<tokio::runtime::scheduler::current_thread::Core>, core::option::Option<()>)>
             at .../src/thread/local.rs:427:20
  18: tokio::runtime::context::set_scheduler::<(alloc::boxed::Box<tokio::runtime::scheduler::current_thread::Core>, core::option::Option<()>), <tokio::runtime::scheduler::current_thread::CoreGuard>::enter<<tokio::runtime::scheduler::current_thread::CoreGuard>::block_on<core::pin::Pin<&mut dyn core::future::future::Future<Output = ()>>>::{closure#0}, core::option::Option<()>>::{closure#0}>
             at .................................................../home/runner/.cargo.................................................../registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.54..../src/runtime/context.rs:186:17
  19: <tokio::runtime::scheduler::current_thread::CoreGuard>::enter::<<tokio::runtime::scheduler::current_thread::CoreGuard>::block_on<core::pin::Pin<&mut dyn core::future::future::Future<Output = ()>>>::{closure#0}, core::option::Option<()>>
             at .................................................../home/runner/.cargo.................................................../registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.54..../scheduler/current_thread/mod.rs:906:27
  20: <tokio::runtime::scheduler::current_thread::CoreGuard>::block_on::<core::pin::Pin<&mut dyn core::future::future::Future<Output = ()>>>
             at .................................................../home/runner/.cargo.................................................../registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.54..../scheduler/current_thread/mod.rs:819:24
  21: {closure#0}<core::pin::Pin<&mut dyn core::future::future::Future<Output=()>>>
             at .................................................../home/runner/.cargo.................................................../registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.54..../scheduler/current_thread/mod.rs:216:33
  22: tokio::runtime::context::runtime::enter_runtime::<<tokio::runtime::scheduler::current_thread::CurrentThread>::block_on<core::pin::Pin<&mut dyn core::future::future::Future<Output = ()>>>::{closure#0}, ()>
             at .................................................../home/runner/.cargo.................................................../registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.54..../runtime/context/runtime.rs:65:16
  23: block_on<core::pin::Pin<&mut dyn core::future::future::Future<Output=()>>>
             at .................................................../home/runner/.cargo.................................................../registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.54..../scheduler/current_thread/mod.rs:204:9
  24: <tokio::runtime::runtime::Runtime>::block_on_inner::<core::pin::Pin<&mut dyn core::future::future::Future<Output = ()>>>
             at .................................................../home/runner/.cargo.................................................../registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.54..../src/runtime/runtime.rs:379:52
  25: block_on<core::pin::Pin<&mut dyn core::future::future::Future<Output=()>>>
             at .................................................../home/runner/.cargo.................................................../registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.54..../src/runtime/runtime.rs:348:18
  26: case_2_backtick
             at ./tests/hybrid_udtf.rs:1029:1
  27: hybrid_udtf::hybrid_field_path_payload::case_2_backtick::{closure#0}
             at ./tests/hybrid_udtf.rs:1029:10
  28: <hybrid_udtf::hybrid_field_path_payload::case_2_backtick::{closure#0} as core::ops::function::FnOnce<()>>::call_once
             at .../src/ops/function.rs:250:5
  29: <fn() -> core::result::Result<(), alloc::string::String> as core::ops::function::FnOnce<()>>::call_once
             at .../src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@ddupg

ddupg commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

I ran the regression test from #11551 on both revisions. It fails on main (168623492) and passes on this PR (b140a9ce7).

Could you include the test in this PR and add Closes #11551 to the PR description?

@wombatu-kun Thanks for reporting this! I’ve added the regression test and linked #11551 in the PR description, and I’ll keep working on the PR over the next few days.

@ddupg
ddupg force-pushed the codex/zonemap-distributed-optimize branch from 5b3ce72 to fca83c6 Compare November 30, 2026 11:29
ddupg added 6 commits December 2, 2026 18:50
Filter zones and null addresses against each source segment, and reject incomplete exact null bitmaps. Read reference settings without loading the index for fragment-local builds, and cover rewritten fragments in both merge paths.
Check that indexed IS NULL excludes a rewritten row after deferred compaction and default optimize. Remove an unused ZoneMap import left by the rebase.
@ddupg
ddupg force-pushed the codex/zonemap-distributed-optimize branch from fca83c6 to 3be1179 Compare December 2, 2026 11:13

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-index Vector index, linalg, tokenizer A-java Java bindings + JNI enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: ZoneMap can return non-null rows for IS NULL after a column rewrite and deferred compaction

2 participants