Skip to content

feat(query): add VectorViewClause zero-copy path and unify validate#478

Open
egolearner wants to merge 3 commits into
alibaba:mainfrom
egolearner:feat/vectorview-zero-copy-validate
Open

feat(query): add VectorViewClause zero-copy path and unify validate#478
egolearner wants to merge 3 commits into
alibaba:mainfrom
egolearner:feat/vectorview-zero-copy-validate

Conversation

@egolearner

@egolearner egolearner commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator
  • Add VectorViewClause (string_view-based) as zero-copy counterpart to VectorClause; variant now holds VectorClause | VectorViewClause | FtsClause
  • Add QueryTarget::get_vector_view() unified accessor via std::visit, returns optional regardless of which variant is held
  • Split validate_and_sanitize into QueryTarget::validate (read-only) + sanitize_sparse_vector (mutate); validate handles both VectorClause and VectorViewClause via get_vector_view()
  • Collection::Query passes original request directly to sqlengine when no sparse sanitization is needed; only copies when sort is required
  • Change build_query_info/BuildSQLInfoFromSearchQuery to take const SearchQuery& so VectorMatrixNode string_views point to caller's data
  • sqlengine internals use get_vector_view() instead of get_vector_view_clause()

@egolearner egolearner marked this pull request as draft June 9, 2026 07:00
@egolearner egolearner force-pushed the feat/vectorview-zero-copy-validate branch 2 times, most recently from d5f7b9d to 91bba29 Compare June 9, 2026 07:25
@egolearner egolearner changed the title feat(query): add VectorViewClause zero-copy path and unify validate WIP feat(query): add VectorViewClause zero-copy path and unify validate Jun 9, 2026
@egolearner egolearner marked this pull request as ready for review June 9, 2026 07:34
@egolearner egolearner requested a review from richyreachy as a code owner June 9, 2026 07:34
@egolearner egolearner force-pushed the feat/vectorview-zero-copy-validate branch from 91bba29 to 1e4e19e Compare June 9, 2026 07:35
Comment thread src/db/collection.cc
@@ -1724,8 +1736,10 @@ Result<DocPtrList> CollectionImpl::Query(const MultiQuery &query) const {
sq.include_doc_id_ = query.include_doc_id_;
sq.output_fields_ = query.output_fields;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这里是不是漏了对SearchQuery的validate?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

fixed

if (n <= 1) {
return false;
}
bool already_sorted = true;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

写入过程应该还需要这段逻辑

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

改为先调用need_sanitize_sparse判断是否需要排序

@egolearner egolearner force-pushed the feat/vectorview-zero-copy-validate branch from 1e4e19e to ffb9009 Compare June 16, 2026 14:28
- Add VectorViewClause (string_view-based) as zero-copy counterpart to
  VectorClause; variant now holds VectorClause | VectorViewClause | FtsClause
- Add QueryTarget::get_vector_view() unified accessor via std::visit,
  returns optional<VectorViewClause> regardless of which variant is held
- Split validate_and_sanitize into QueryTarget::validate (read-only) +
  sanitize_sparse_vector (mutate); validate handles both VectorClause and
  VectorViewClause via get_vector_view()
- Collection::Query passes original request directly to sqlengine when no
  sparse sanitization is needed; only copies when sort is required
- Change build_query_info/BuildSQLInfoFromSearchQuery to take const
  SearchQuery& so VectorMatrixNode string_views point to caller's data
- sqlengine internals use get_vector_view() instead of get_vector_view_clause()
@egolearner egolearner force-pushed the feat/vectorview-zero-copy-validate branch from ffb9009 to a057644 Compare June 17, 2026 11:53
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.

2 participants