JunRuiLee opened a new pull request, #537:
URL: https://github.com/apache/paimon-rust/pull/537
### Purpose
Part of #514.
Expose primary-key / append vector search to C/C++/Go consumers (e.g. Doris)
via the `paimon-c` FFI bindings. Today `bindings/c/` covers ordinary reads and
write/commit but has no vector-search entry; this adds one, wrapping the
existing Rust `VectorSearchBuilder`.
The entry is **storage-type agnostic**: the same C call works whether the
table is primary-key (PK-vector) or append/data-evolution, because it wraps
`VectorSearchBuilder::execute_scored()`, which already auto-routes by table
type. It returns scored hits (row-ids + similarity scores), mirroring the
user-facing vector-search contract in Spark (`_score` metadata column) and
Python.
An optional scalar `WHERE` filter is passed through to
`VectorSearchBuilder::with_filter`: it works on primary-key tables (residual
filter), and an append/data-evolution table surfaces a clean `InvalidInput`
error at execute time (a capability gap reported honestly, not a panic). The C
API stays a single unified entry — callers never pick a function by table type.
### Brief change log
- `feat(c)`: new `bindings/c/src/vector_search.rs` —
`paimon_table_new_vector_search_builder` → setters (`with_vector_column`,
`with_query_vector`, `with_limit`, `with_options`, `with_filter`) →
`execute_scored` returning `paimon_result_vector_search { result: { row_ids,
scores, len }, error }`, plus `paimon_vector_search_result_free`.
- Structs split per the crate's convention: opaque handle / state / result
in `types.rs`, `paimon_result_*` in `result.rs`, `extern "C"` functions + ABI
signature guards in the new module.
- Contracts: empty result → `len == 0` with null `row_ids`/`scores`; an
empty/null query vector is rejected at the setter with `InvalidInput`;
`with_filter` consumes the predicate on success and retains it on a null
builder (mirrors `paimon_read_builder_with_filter`).
- No `crates/paimon` change — this is a thin FFI layer over the finished
read kernel.
### Tests
- `bindings/c/src/tests.rs`: end-to-end C-entry tests over both storage
types (PK-vector and append/DE, each compared against the Rust
`VectorSearchBuilder::execute_scored()` reference); a PK-vector residual filter
that excludes an ANN neighbor; a DE + filter clean-`InvalidInput` case; setter
validation; filter-ownership on a null builder; and empty-result safety.
- `cargo test -p paimon-c` green (43 tests); `cargo clippy -p paimon-c
--all-targets -- -D warnings` and `cargo fmt --check` clean.
### API and Format
- No on-disk format change. New C ABI symbols only (add-only; each guarded
by a compile-time signature assertion). No existing signature changed.
### Documentation
- Doc comments on the new FFI functions; no user-facing docs change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]