Skip to content

refactor(sqlite-provider): switch from pack_key to monotonic integer keys#5

Merged
anoop-narang merged 3 commits into
mainfrom
refactor/monotonic-sqlite-keys
Mar 17, 2026
Merged

refactor(sqlite-provider): switch from pack_key to monotonic integer keys#5
anoop-narang merged 3 commits into
mainfrom
refactor/monotonic-sqlite-keys

Conversation

@anoop-narang
Copy link
Copy Markdown
Collaborator

Summary

  • Replace pack_key(file_idx, rg_idx, local_offset) with monotonic integer keys (0, 1, 2, ...) in SqliteLookupProvider
  • Remove layout: &DatasetLayout parameter from open_or_build() and build_table()
  • DatasetLayout, pack_key, and unpack_key remain exported — ParquetLookupProvider still uses them

Both SqliteLookupProvider and USearch treat keys as opaque integers, so the bit-packed encoding was unnecessary complexity with artificial 16-bit capacity limits on file_idx/rg_idx.

Test plan

  • All 6 SQLite provider tests pass with monotonic keys
  • ParquetLookupProvider tests unaffected (still use pack_key)
  • Optimizer and execution tests pass

Comment thread src/sqlite_provider.rs
/// connections (WAL allows N concurrent readers).
///
/// `local_parquet_files`, `layout`, `schema`, and `parquet_col_indices`
/// `local_parquet_files`, `schema`, and `parquet_col_indices`
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: callers pairing this provider with a USearch index now need to use monotonic keys (0, 1, 2, …) when calling index.add() — the previous implicit contract was pack_key(file_idx, rg_idx, lo). Worth a one-liner here so the contract is visible at the call site:

Suggested change
/// `local_parquet_files`, `schema`, and `parquet_col_indices`
/// are only used if the table does not yet exist. Row keys are assigned
/// as monotonic integers (0, 1, 2, …) in file-iteration order; any
/// USearch index used alongside this provider must use the same scheme.

claude[bot]
claude Bot previously approved these changes Mar 17, 2026
…keys

SqliteLookupProvider treats keys as opaque INTEGER PRIMARY KEY and
USearch treats them as opaque u64 labels — the bit-packed encoding
via pack_key was unnecessary complexity. Replace with a simple
monotonic counter (0, 1, 2, ...) which removes the DatasetLayout
dependency from open_or_build/build_table and lifts the artificial
16-bit capacity limits on file_idx/rg_idx.
@anoop-narang anoop-narang merged commit 3c3b8cf into main Mar 17, 2026
5 checks passed
@anoop-narang anoop-narang deleted the refactor/monotonic-sqlite-keys branch March 17, 2026 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant