feat: enlarge topK limit (#348)
This commit is contained in:
@@ -52,7 +52,7 @@ constexpr uint32_t kMaxScalarFieldSize = 1024;
|
||||
|
||||
constexpr uint32_t kMaxVectorFieldSize = 5;
|
||||
|
||||
constexpr uint32_t kMaxQueryTopk = 1024;
|
||||
constexpr uint32_t kMaxQueryTopk = 100000;
|
||||
|
||||
constexpr uint32_t kMaxOutputFieldSize = 1024;
|
||||
|
||||
|
||||
+29
-21
@@ -1203,53 +1203,61 @@ bool Doc::operator==(const Doc &other) const {
|
||||
|
||||
Status VectorQuery::validate(const FieldSchema *schema) const {
|
||||
if ((uint32_t)topk_ > kMaxQueryTopk) {
|
||||
return Status::InvalidArgument("query validate failed: topk[", topk_,
|
||||
"] is too large, max is ", kMaxQueryTopk);
|
||||
return Status::InvalidArgument("Invalid query: topk[", topk_,
|
||||
"] exceeds the maximum allowed value of ",
|
||||
kMaxQueryTopk);
|
||||
}
|
||||
if (output_fields_.has_value() &&
|
||||
output_fields_->size() > kMaxOutputFieldSize) {
|
||||
return Status::InvalidArgument(
|
||||
"query validate failed: output_fields is too large, max is ",
|
||||
"Invalid query: too many output fields, the maximum allowed is ",
|
||||
kMaxOutputFieldSize);
|
||||
}
|
||||
|
||||
if (schema == nullptr) {
|
||||
// support query with vector
|
||||
if (query_vector_.empty() && query_sparse_indices_.empty()) {
|
||||
// No vector provided — this is a scalar-only filter query.
|
||||
return Status::OK();
|
||||
} else {
|
||||
// If a query vector was provided, the field must exist as a vector field
|
||||
// since we are doing vector similarity search.
|
||||
return Status::InvalidArgument(
|
||||
"Invalid query: query vector is provided, but query field[",
|
||||
field_name_,
|
||||
"] does not exist or is not a vector field in the collection");
|
||||
}
|
||||
|
||||
return Status::InvalidArgument("query validate failed: vector_field[",
|
||||
field_name_,
|
||||
"] not defined in the collection schema");
|
||||
}
|
||||
// validate dense/sparse vector
|
||||
if (schema->is_dense_vector()) {
|
||||
// validate dimension
|
||||
// Validate dimension
|
||||
auto dim = schema->dimension();
|
||||
switch (schema->data_type()) {
|
||||
case DataType::VECTOR_FP16:
|
||||
if (dim * sizeof(float16_t) != query_vector_.size()) {
|
||||
return Status::InvalidArgument(
|
||||
"query validate failed: dimension is invalid");
|
||||
"Invalid query: dimension mismatch, expected ", dim, " but got ",
|
||||
query_vector_.size() / sizeof(float16_t), " (FP16)");
|
||||
}
|
||||
break;
|
||||
case DataType::VECTOR_FP32:
|
||||
if (dim * sizeof(float) != query_vector_.size()) {
|
||||
return Status::InvalidArgument(
|
||||
"query validate failed: dimension is invalid");
|
||||
"Invalid query: dimension mismatch, expected ", dim, " but got ",
|
||||
query_vector_.size() / sizeof(float), " (FP32)");
|
||||
}
|
||||
break;
|
||||
case DataType::VECTOR_FP64:
|
||||
if (dim * sizeof(double) != query_vector_.size()) {
|
||||
return Status::InvalidArgument(
|
||||
"query validate failed: dimension is invalid");
|
||||
"Invalid query: dimension mismatch, expected ", dim, " but got ",
|
||||
query_vector_.size() / sizeof(double), " (FP64)");
|
||||
}
|
||||
break;
|
||||
case DataType::VECTOR_INT8:
|
||||
if (dim * sizeof(int8_t) != query_vector_.size()) {
|
||||
return Status::InvalidArgument(
|
||||
"query validate failed: dimension is invalid");
|
||||
"Invalid query: dimension mismatch, expected ", dim, " but got ",
|
||||
query_vector_.size() / sizeof(int8_t), " (INT8)");
|
||||
}
|
||||
break;
|
||||
case DataType::VECTOR_INT16:
|
||||
@@ -1257,22 +1265,22 @@ Status VectorQuery::validate(const FieldSchema *schema) const {
|
||||
case DataType::VECTOR_BINARY32:
|
||||
case DataType::VECTOR_BINARY64:
|
||||
return Status::NotSupported(
|
||||
"query validate failed: unsupported dense vector type");
|
||||
"Invalid query: dense vector type of field[", field_name_,
|
||||
"] is not supported");
|
||||
default:
|
||||
return Status::InvalidArgument(
|
||||
"query validate failed: field is not dense vector");
|
||||
return Status::InvalidArgument("Invalid query: field[", field_name_,
|
||||
"] is not a dense vector field");
|
||||
}
|
||||
} else if (schema->is_sparse_vector()) {
|
||||
// validate sparse indices size
|
||||
// Validate sparse indices size
|
||||
if (query_sparse_indices_.size() > kSparseMaxDimSize * sizeof(uint32_t)) {
|
||||
return Status::InvalidArgument(
|
||||
"query validate failed: the number of sparse indices exceeds the "
|
||||
"maximum limit ",
|
||||
"Invalid query: too many sparse indices, the maximum allowed is ",
|
||||
kSparseMaxDimSize);
|
||||
}
|
||||
} else {
|
||||
return Status::InvalidArgument(
|
||||
"query validate failed: field is not vector");
|
||||
return Status::InvalidArgument("Invalid query: field[", field_name_,
|
||||
"] is not a vector field");
|
||||
}
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user