feat: fetch() with outputFields parameter (closes #176) - #191
Merged
Conversation
- Extend zvec_collection_fetch FFI binding with optional output fields
(output_fields/output_field_count), building std::optional only when
count > 0 (nullopt = all fields, matching upstream C API)
- ZVecCollection::fetch() accepts fetch(['pk1','pk2'], ['name']) while
keeping the legacy variadic fetch('pk1','pk2') BC-compatible; full
input validation via ZVecException
- Per-entry null guard on output_fields in the C++ wrapper
- Add tests/test_fetch_output_fields.phpt (8 scenarios)
- Update README API listing and CHANGELOG
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closes #176
Adds optional output-field selection to
ZVecCollection::fetch(), matching upstream zvec v0.5.0+ (alibaba/zvec#358) and the Go SDK'sFetch(pks, FetchOptions).Changes
ffi/zvec_ffi.h,zvec_ffi.cc,zvec_ffi_php.h):zvec_collection_fetchextended withoutput_fields/output_field_countparameters; buildsstd::optionalonly when count > 0 (nullopt= all fields, exact upstream semantics fromc_api.cc). Per-entry null guard added.src/ZVec.php):fetch(array|string ...$args)— BC-compatible dual form: legacyfetch('a', 'b')and newfetch(['a','b'], ['name','score']). Full input validation viaZVecException(empty/non-string PKs, non-array/non-string/empty output fields, extra arguments).tests/test_fetch_output_fields.phpt— 8 scenarios: subset selection, BC all-fields, array form, unknown-fields-ignored, 3 validation throws, extra-args throw.Testing
./build_ffi.shclean on macOS/arm64)test_dbs/empty)Code Review
Notes
include_vectorintentionally not exposed (out of scope for fetch() with outputFields parameter (zvec v0.5.0) #176): vector fields are always present in fetched docs, matching the upstream default.