Skip to content

Optimize Typesense vector query construction - #6151

Closed
chabinhwang wants to merge 1 commit into
spring-projects:mainfrom
chabinhwang:refactor/typesense-vector-query-allocation
Closed

Optimize Typesense vector query construction#6151
chabinhwang wants to merge 1 commit into
spring-projects:mainfrom
chabinhwang:refactor/typesense-vector-query-allocation

Conversation

@chabinhwang

Copy link
Copy Markdown
Contributor

Summary

  • Build the Typesense vector query directly from the embedding float[] instead of creating a boxed Stream<Float> and intermediate List before String.join.
  • Add focused tests to lock the generated vector query format, including the empty-embedding edge case.

Why

This preserves the existing Typesense vector query string format while reducing temporary allocations during similarity search request construction.

Validation

  • ./mvnw -pl vector-stores/spring-ai-typesense-store -Dtest=TypesenseVectorStoreTests test
  • ./mvnw -pl vector-stores/spring-ai-typesense-store package
  • git diff --check

Notes

No associated issue; this is a small internal allocation optimization with behavior-preserving tests.

Build the vector query directly from the embedding array so search behavior stays identical without boxing floats into a temporary list.

Constraint: Spring AI pull requests require DCO sign-off and focused reviewable changes
Rejected: Changing Typesense query semantics | performance-only PR should preserve the request format
Confidence: high
Scope-risk: narrow
Directive: Keep vector query formatting compatible with existing Typesense requests
Tested: ./mvnw -pl vector-stores/spring-ai-typesense-store -Dtest=TypesenseVectorStoreTests test; ./mvnw -pl vector-stores/spring-ai-typesense-store package; git diff --check
Not-tested: Full repository ./mvnw package
Signed-off-by: chabinhwang <7chabin@gmail.com>
@chabinhwang

Copy link
Copy Markdown
Contributor Author

Superseded by #6707, which is rebased on current main, corrects the buffer capacity estimate so it actually avoids the resize, and adds format tests for the sign and scientific-notation cases. Closing this one to avoid a duplicate.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants