Skip to content

feat: collect zone map write seeds for unindexed columns from dataset config - #11373

Draft
LuQQiu wants to merge 17 commits into
lance-format:mainfrom
LuQQiu:lu/zone-write-seeds-config
Draft

LuQQiu wants to merge 17 commits into
lance-format:mainfrom
LuQQiu:lu/zone-write-seeds-config

Conversation

@LuQQiu

@LuQQiu LuQQiu commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Zone map write seeds are collected today only for columns that already have a ZoneMap index with use_seeds = true. Data written before such an index exists carries no seed, so the first index build (and every build over older fragments) scans the column.

This PR adds a dataset-level switch so that writes embed seeds for scalar columns that have no seeded ZoneMap index yet. A ZoneMap built later on such a column reuses the seeds instead of scanning.

Dataset config

Set with Dataset::update_config; all three are validated in the commit that sets them (legacy UpdateConfig / Overwrite and the composite action path), the same way the lance.auto_cleanup.* keys are.

Key Values Absent
lance.zone_write_seeds.enabled "true" / "false" off
lance.zone_write_seeds.rows_per_zone integer in 1..=u32::MAX 8192
lance.zone_write_seeds.store_null_bitmap "true" / "false" true

Unknown keys under the lance.zone_write_seeds. prefix are rejected. A value already present in a manifest written by a build without validation is read leniently (warning and default).

Behaviour

  • A column with a usable ZoneMap index that requests seeds keeps today's rule: the seed follows the index (the smallest rows_per_zone when there are several, and the indexes' null-bitmap policy). The dataset config does not change it.
  • Any other top-level column of a supported type gets a seed sized by rows_per_zone when the setting is on. A ZoneMap index with use_seeds = false does not suppress it.
  • Supported types: boolean, integers, floats, decimals, date, time, timestamp, duration, string and binary (including the large variants). Not seeded from the config: nested types and vectors, dictionary, fixed-size binary (zone statistics compute no bounds for it), blob columns and extension-typed columns.
  • Enabling the setting publishes FLAG_ZONE_WRITE_SEEDS in that commit. Writes based on an earlier version stay unseeded, as before.
  • Disabling stops collection for later writes; existing seeds and the feature flag stay. Changing rows_per_zone applies to later files; older files keep their records.
  • Binary-copy compaction carries seeds as before; the declared zone size of the output follows the same precedence (seeded index, else the config, else the writer default). index_rows_per_zone now considers only indexes with use_seeds = true and takes their minimum; previously the last ZoneMap index of any kind won.
  • With store_null_bitmap = false a configured seed records null counts only and serves ZoneMaps created with store_null_bitmap = false. With the default it serves both kinds.

Limitations

  • The write that creates a dataset is not seeded: the setting lives in the dataset config, which the creating write does not have yet. Create, set the config, then append. Seeding the creating write is left to a follow-up.
  • Overwrite does not collect seeds (unchanged).
  • Only top-level columns are covered; fields nested in a struct are not.

Tests

  • Config parsing and mutation-time validation on both commit paths, including an invalid intermediate value repaired within one composite and an inherited invalid value with an unrelated update.
  • Seeds on unindexed columns; vector and struct columns stay unseeded; no seed before the flag is published; lifecycle (enable, disable, resize, reopen).
  • Precedence between a seeded index and the config; a use_seeds = false index.
  • Round trip per type (seed written, index built from the seed, filters equal to an unindexed scan) for 18 types.
  • Null positions: default and explicit true serve an index with and without a null bitmap; false falls back to a scan for a bitmap index.
  • Binary-copy compaction of inputs with different seed sizes, asserting full reuse.

Measurements

Single-column tables, 100M rows appended in one call to local NVMe (1M rows per file), same binary and identical pre-generated data for every arm, 3 repetitions, median. aarch64, 16 cores. Index: ZoneMap with rows_per_zone = 1,000,000.

Append wall time relative to the setting off, 2% nulls at random positions:

Type off (s) on, no null positions on, null positions Index build, scan → from seeds (s)
int32 0.46 +54% +113% 0.40 → 0.008
int64 0.54 +40% +88% 0.41 → 0.008
float32 0.52 +88% +140% 0.41 → 0.009
float64 0.70 +68% +104% 0.45 → 0.008
date32 0.42 +58% +121% 0.39 → 0.008
timestamp (ms) 1.09 +20% +44% 0.40 → 0.008
boolean 0.26 +254% +352% 0.46 → 0.008
decimal128 1.07 +28% +54% 0.52 → 0.008
utf8, 16 chars 9.97 +6% +9% 0.69 → 0.010
binary, 64 bytes 7.90 +6% +11% 1.33 → 0.012
utf8, 256 chars (7.9M rows) 9.98 +1% +1% 1.82 → 0.030

The absolute cost for narrow types is 2 to 7 ns per row; the percentage is high because writing a narrow column to local disk is itself very cheap. Seed size 8192 instead of 1,000,000 adds a few percentage points.

Null positions, int64, by null fraction (random positions, the worst case for the bitmap):

Nulls on, no null positions on, null positions Extra bytes per 1M-row file with positions
0% +56% +55% 2 KB
2% +40% +88% 162 KB
30% +100% +351% 526 KB

A ZoneMap that stores a null bitmap builds from seeds with positions in 0.034 s (2% nulls) and 0.084 s (30%) instead of 0.41 s and 0.47 s by scan; seeds without positions cannot serve it. Peak RSS showed no difference between arms. Every arm verified the committed config, both feature-flag words and the presence of the seed in each appended file before timing, and compared filtered counts with and without the index afterwards.

🤖 Generated with Claude Code

… config

Add two dataset config keys. `lance.zone_write_seeds.enabled` makes writes
embed a zone map seed for every top-level column of a supported scalar type
that no seeded ZoneMap index covers, so a ZoneMap index created later can be
built from seeds instead of scanning. `lance.zone_write_seeds.rows_per_zone`
sets the rows per seed zone for those columns (default 8192). A column with a
seeded ZoneMap index keeps following that index. The commit that enables the
setting also sets the seed feature flags; binary-copy compaction declares the
same zone size for carried seeds.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added the enhancement New feature or request label Nov 23, 2026
Reject an invalid lance.zone_write_seeds.* value in the commit that sets it,
as the auto-cleanup keys are validated, instead of falling back on later
writes. Add lifecycle, per-type round-trip and binary-copy carry tests.

Co-Authored-By: Claude <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

⚠️ JUnit XML file not found

The CLI was unable to find any JUnit XML files to upload.
For more help, visit our troubleshooting guide.

LuQQiu and others added 15 commits November 22, 2026 18:00
Zone statistics have no min/max for fixed-size binary, so a seed for such a
column is always rejected by the index build. Also check unseeded nested
columns in the test through every file of the fragment.

Co-Authored-By: Claude <noreply@anthropic.com>
Check the final manifest once after all actions, as the auto-cleanup settings
are checked. Assert seed reuse in the binary-copy carry test and add value
predicates to the per-type round trip.

Co-Authored-By: Claude <noreply@anthropic.com>
A Lance field stores view types as their base string or binary type, so the
case asserted on a type the gate never sees.

Co-Authored-By: Claude <noreply@anthropic.com>
Add lance.zone_write_seeds.store_null_bitmap (default true) so seeds collected
from the dataset config can serve a zone map that stores a null bitmap.

Co-Authored-By: Claude <noreply@anthropic.com>
Adds a matrix over seed size, index size, fragment length and batch size
that checks which fragments are reused, partly scanned or scanned, and
compares indexed results row by row with the generator and an unindexed
scan.

Co-Authored-By: Claude <noreply@anthropic.com>
A partly reused fragment is reported as both partial and scanned, and
scanned rows include the unseeded creating fragment. Corrects the
expectation for 8-row records over 20-row index zones.

Co-Authored-By: Claude <noreply@anthropic.com>
Asserts the exact outcome for a seed coarser than the index and adds
8192 and 1,000,000-row zone sizes over a fragment length neither divides.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Reads every persisted zone of the index built from configured seeds and
checks its span, bounds and null count against values computed from the
generator, including the unseeded creating fragment and short final zones.

Co-Authored-By: Claude <noreply@anthropic.com>
…ndex

Checks reuse, stored zone statistics and query results for integer,
float, string, timestamp, boolean and decimal columns where reused and
scanned zones mix.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>

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

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant