Skip to content

Migrate CAGRA merge() to caller-concatenated dataset + offsets contract - #2507

Open
HowardHuang1 wants to merge 5 commits into
NVIDIA:mainfrom
HowardHuang1:HH-migrate-merge-dataset-to-take-inputs-concat-buffer-and-offset-26_10
Open

Migrate CAGRA merge() to caller-concatenated dataset + offsets contract#2507
HowardHuang1 wants to merge 5 commits into
NVIDIA:mainfrom
HowardHuang1:HH-migrate-merge-dataset-to-take-inputs-concat-buffer-and-offset-26_10

Conversation

@HowardHuang1

@HowardHuang1 HowardHuang1 commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Addresses issue #2401.

merge() previously allocated the merged dataset buffer and copied each input index's rows into it internally, hiding memory allocation and copies from the caller. This migrates it to the same explicit caller-owned-buffer contract already used by extend(): callers concatenate every input index's dataset (applying any row filter) into a single buffer themselves, and pass per-index offsets marking where each index's rows start. merge() now only builds/merges the graph and binds the returned index to that buffer.

A new merged_dataset_offsets() helper is added for the bitset-filtered case, where the caller can't otherwise derive per-index surviving row counts; unfiltered callers can compute offsets directly (cumulative index sizes) without it.

  • C++: cagra::merge() and Fastener/rebuild internals updated; new cagra::merged_dataset_offsets().
  • C API: cuvsCagraMerge/cuvsCagraMergeWithParams updated to match; new cuvsCagraMergedDatasetOffsets.
  • Java: CagraIndex.merge() public API updated to the same contract (breaking); real in-repo consumer (cuvs-lucene) and tests updated.
  • Rust, Python, Go: new merge wrappers added (none existed before), matching the C API's contract and modeled on each language's existing extend()/update_dataset() conventions.

Also fixes an unrelated pre-existing build break in cpp/src/core/bloom_filter.cu (cuco::default_filter_policy renamed to cuco::bloom_filter_policy in the pinned cuCollections version), needed to get any build of libcuvs compiling in this environment.

@HowardHuang1
HowardHuang1 requested review from a team as code owners August 26, 2026 04:26
@copy-pr-bot

copy-pr-bot Bot commented Aug 26, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@HowardHuang1 HowardHuang1 self-assigned this Aug 26, 2026
@HowardHuang1 HowardHuang1 added breaking Introduces a breaking change Enhancement labels Aug 26, 2026
merge() previously allocated the merged dataset buffer and copied each
input index's rows into it internally, hiding memory allocation and
copies from the caller. This migrates it to the same explicit
caller-owned-buffer contract already used by extend(): callers
concatenate every input index's dataset (applying any row filter)
into a single buffer themselves, and pass per-index offsets marking
where each index's rows start. merge() now only builds/merges the
graph and binds the returned index to that buffer.

A new merged_dataset_offsets() helper is added for the bitset-filtered
case, where the caller can't otherwise derive per-index surviving row
counts; unfiltered callers can compute offsets directly (cumulative
index sizes) without it.

- C++: cagra::merge() and Fastener/rebuild internals updated; new
  cagra::merged_dataset_offsets().
- C API: cuvsCagraMerge/cuvsCagraMergeWithParams updated to match; new
  cuvsCagraMergedDatasetOffsets.
- Java: CagraIndex.merge() public API updated to the same contract
  (breaking); real in-repo consumer (cuvs-lucene) and tests updated.
- Rust, Python, Go: new merge wrappers added (none existed before),
  matching the C API's contract and modeled on each language's
  existing extend()/update_dataset() conventions.

Also fixes an unrelated pre-existing build break in
cpp/src/core/bloom_filter.cu (cuco::default_filter_policy renamed to
cuco::bloom_filter_policy in the pinned cuCollections version), needed
to get any build of libcuvs compiling in this environment.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@HowardHuang1
HowardHuang1 force-pushed the HH-migrate-merge-dataset-to-take-inputs-concat-buffer-and-offset-26_10 branch from 46bed89 to 87a0075 Compare August 26, 2026 04:33
@HowardHuang1 HowardHuang1 added the improvement Improves an existing functionality label Aug 26, 2026
@HowardHuang1

Copy link
Copy Markdown
Contributor Author

/ok to test 87a0075

…taset-to-take-inputs-concat-buffer-and-offset-26_10
@HowardHuang1

Copy link
Copy Markdown
Contributor Author

/ok to test 50dd606

HowardHuang1 and others added 3 commits August 27, 2026 10:21
…taset-to-take-inputs-concat-buffer-and-offset-26_10
Rust: regenerate cuvs-sys bindings.rs for the offsets-based merge
contract, and switch the merge tests from PaddedDataset::new (owning
copy, rejects already-aligned sources) to DatasetView::new, mirroring
how Index::build picks a view.

Go: add MakePaddedDatasetAuto, mirroring BuildIndex's existing
padded-vs-standard branch, so merge_test.go can build its merged
buffer without needing its own cgo import (which isn't allowed in
_test.go files).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…taset-to-take-inputs-concat-buffer-and-offset-26_10
@HowardHuang1

Copy link
Copy Markdown
Contributor Author

/ok to test a83394f

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

Labels

breaking Introduces a breaking change Enhancement improvement Improves an existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant