2021-04-29 16:48:06 +08:00
|
|
|
syntax = "proto3";
|
|
|
|
package milvus.proto.plan;
|
|
|
|
|
|
|
|
option go_package = "github.com/milvus-io/milvus/internal/proto/planpb";
|
|
|
|
import "schema.proto";
|
|
|
|
|
2021-07-13 14:37:03 +08:00
|
|
|
enum OpType {
|
|
|
|
Invalid = 0;
|
|
|
|
GreaterThan = 1;
|
|
|
|
GreaterEqual = 2;
|
|
|
|
LessThan = 3;
|
|
|
|
LessEqual = 4;
|
|
|
|
Equal = 5;
|
|
|
|
NotEqual = 6;
|
2022-04-29 13:35:49 +08:00
|
|
|
PrefixMatch = 7; // startsWith
|
|
|
|
PostfixMatch = 8; // endsWith
|
2021-07-13 14:37:03 +08:00
|
|
|
};
|
|
|
|
|
2022-04-24 16:43:45 +08:00
|
|
|
enum ArithOpType {
|
|
|
|
Unknown = 0;
|
|
|
|
Add = 1;
|
|
|
|
Sub = 2;
|
|
|
|
Mul = 3;
|
|
|
|
Div = 4;
|
|
|
|
Mod = 5;
|
|
|
|
};
|
|
|
|
|
2021-04-29 16:48:06 +08:00
|
|
|
message GenericValue {
|
|
|
|
oneof val {
|
|
|
|
bool bool_val = 1;
|
|
|
|
int64 int64_val = 2;
|
|
|
|
double float_val = 3;
|
2022-04-02 17:43:29 +08:00
|
|
|
string string_val = 4;
|
2021-04-29 16:48:06 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
message QueryInfo {
|
|
|
|
int64 topk = 1;
|
|
|
|
string metric_type = 3;
|
|
|
|
string search_params = 4;
|
2021-10-08 17:39:55 +08:00
|
|
|
int64 round_decimal = 5;
|
2021-04-29 16:48:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
message ColumnInfo {
|
|
|
|
int64 field_id = 1;
|
|
|
|
schema.DataType data_type = 2;
|
2021-06-07 17:21:36 +08:00
|
|
|
bool is_primary_key = 3;
|
|
|
|
bool is_autoID = 4;
|
2021-04-29 16:48:06 +08:00
|
|
|
}
|
|
|
|
|
2022-04-29 13:35:49 +08:00
|
|
|
// For example: a startsWith "prefix", a >= "str", b < 2 and etc,
|
|
|
|
// where both a and b are field in schema.
|
2021-07-25 10:23:19 +08:00
|
|
|
message UnaryRangeExpr {
|
2021-04-29 16:48:06 +08:00
|
|
|
ColumnInfo column_info = 1;
|
2021-07-25 10:23:19 +08:00
|
|
|
OpType op = 2;
|
|
|
|
GenericValue value = 3;
|
|
|
|
}
|
|
|
|
|
2022-04-29 13:35:49 +08:00
|
|
|
// For example: "str1" < a <= "str9", 1 <= b < 9 and etc,
|
|
|
|
// where both a and b are field in schema.
|
2021-07-25 10:23:19 +08:00
|
|
|
message BinaryRangeExpr {
|
|
|
|
ColumnInfo column_info = 1;
|
|
|
|
bool lower_inclusive = 2;
|
|
|
|
bool upper_inclusive = 3;
|
|
|
|
GenericValue lower_value = 4;
|
|
|
|
GenericValue upper_value = 5;
|
2021-04-29 16:48:06 +08:00
|
|
|
}
|
|
|
|
|
2022-04-29 13:35:49 +08:00
|
|
|
// For example: a startsWith b, a >= b, a < b, a == b and etc,
|
|
|
|
// where both a and b are field in schema.
|
2021-07-13 14:37:03 +08:00
|
|
|
message CompareExpr {
|
2021-07-25 10:23:19 +08:00
|
|
|
ColumnInfo left_column_info = 1;
|
|
|
|
ColumnInfo right_column_info = 2;
|
|
|
|
OpType op = 3;
|
2021-07-13 14:37:03 +08:00
|
|
|
}
|
|
|
|
|
2022-04-29 13:35:49 +08:00
|
|
|
// For example: a in ["term0", "term1"], b in [1, 2, 3, 4] and etc,
|
|
|
|
// where both a and b are field in schema.
|
2021-04-29 16:48:06 +08:00
|
|
|
message TermExpr {
|
|
|
|
ColumnInfo column_info = 1;
|
|
|
|
repeated GenericValue values = 2;
|
|
|
|
}
|
|
|
|
|
2022-04-29 13:35:49 +08:00
|
|
|
// !(expr).
|
2021-04-29 16:48:06 +08:00
|
|
|
message UnaryExpr {
|
2021-07-13 14:37:03 +08:00
|
|
|
enum UnaryOp {
|
2021-04-29 16:48:06 +08:00
|
|
|
Invalid = 0;
|
|
|
|
Not = 1;
|
|
|
|
};
|
|
|
|
UnaryOp op = 1;
|
|
|
|
Expr child = 2;
|
|
|
|
}
|
|
|
|
|
2022-04-29 13:35:49 +08:00
|
|
|
// (expr) op (expr), where op is of (LogicalAnd, LogicalOr).
|
2021-04-29 16:48:06 +08:00
|
|
|
message BinaryExpr {
|
|
|
|
enum BinaryOp {
|
|
|
|
Invalid = 0;
|
|
|
|
LogicalAnd = 1;
|
|
|
|
LogicalOr = 2;
|
|
|
|
}
|
2021-04-30 15:19:52 +08:00
|
|
|
BinaryOp op = 1;
|
|
|
|
Expr left = 2;
|
|
|
|
Expr right = 3;
|
2021-04-29 16:48:06 +08:00
|
|
|
}
|
|
|
|
|
2022-04-24 16:43:45 +08:00
|
|
|
message BinaryArithOp {
|
|
|
|
ColumnInfo column_info = 1;
|
|
|
|
ArithOpType arith_op = 2;
|
|
|
|
GenericValue right_operand = 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
message BinaryArithOpEvalRangeExpr {
|
|
|
|
ColumnInfo column_info = 1;
|
|
|
|
ArithOpType arith_op = 2;
|
|
|
|
GenericValue right_operand = 3;
|
|
|
|
OpType op = 4;
|
|
|
|
GenericValue value = 5;
|
|
|
|
}
|
|
|
|
|
2021-04-29 16:48:06 +08:00
|
|
|
message Expr {
|
|
|
|
oneof expr {
|
2021-07-25 10:23:19 +08:00
|
|
|
TermExpr term_expr = 1;
|
|
|
|
UnaryExpr unary_expr = 2;
|
|
|
|
BinaryExpr binary_expr = 3;
|
|
|
|
CompareExpr compare_expr = 4;
|
|
|
|
UnaryRangeExpr unary_range_expr = 5;
|
|
|
|
BinaryRangeExpr binary_range_expr = 6;
|
2022-04-24 16:43:45 +08:00
|
|
|
BinaryArithOpEvalRangeExpr binary_arith_op_eval_range_expr = 7;
|
2021-04-29 16:48:06 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
message VectorANNS {
|
|
|
|
bool is_binary = 1;
|
|
|
|
int64 field_id = 2;
|
|
|
|
Expr predicates = 3;
|
|
|
|
QueryInfo query_info = 4;
|
|
|
|
string placeholder_tag = 5; // always be "$0"
|
|
|
|
}
|
|
|
|
|
|
|
|
message PlanNode {
|
|
|
|
oneof node {
|
|
|
|
VectorANNS vector_anns = 1;
|
2021-09-03 17:12:55 +08:00
|
|
|
Expr predicates = 2;
|
2021-04-29 16:48:06 +08:00
|
|
|
}
|
2021-09-03 17:12:55 +08:00
|
|
|
repeated int64 output_field_ids = 3;
|
2021-06-04 10:38:34 +08:00
|
|
|
}
|