Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions internal/core/src/pb/plan.pb.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion internal/core/src/pb/plan.pb.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions internal/core/src/query/Expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ static const std::map<std::string, ArithOpType> arith_op_mapping_ = {
{"mul", ArithOpType::Mul},
{"div", ArithOpType::Div},
{"mod", ArithOpType::Mod},
{"band", ArithOpType::BAnd},
{"bxor", ArithOpType::BXOr},
{"bor", ArithOpType::BOr},
};

static const std::map<ArithOpType, std::string> mapping_arith_op_ = {
Expand All @@ -152,6 +155,9 @@ static const std::map<ArithOpType, std::string> mapping_arith_op_ = {
{ArithOpType::Mul, "mul"},
{ArithOpType::Div, "div"},
{ArithOpType::Mod, "mod"},
{ArithOpType::BAnd, "band"},
{ArithOpType::BOr, "bor"},
{ArithOpType::BXOr, "bxor"},
};

struct BinaryArithOpEvalRangeExpr : Expr {
Expand Down
191 changes: 191 additions & 0 deletions internal/core/src/query/visitors/ExecExprVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,53 @@ class ExecExprVisitor : ExprVisitor {
BitsetTypeOpt bitset_opt_;
};
} // namespace impl
template <typename T>
inline T
_bitand(T a, T b) {
return a & b;
}
inline double
_bitand(double a, double b) {
PanicInfo("unsupported bitand between doubles");
return 0;
}
inline float
_bitand(float a, float b) {
PanicInfo("unsupported bitand between floats");
return 0;
}

template <typename T>
inline T
_bitxor(T a, T b) {
return a ^ b;
}
inline double
_bitxor(double a, double b) {
PanicInfo("unsupported bitxor between doubles");
return 0;
}
inline float
_bitxor(float a, float b) {
PanicInfo("unsupported bitxor between floats");
return 0;
}

template <typename T>
inline T
_bitor(T a, T b) {
return a | b;
}
inline double
_bitor(double a, double b) {
PanicInfo("unsupported bitor between doubles");
return 0;
}
inline float
_bitor(float a, float b) {
PanicInfo("unsupported bitor between floats");
return 0;
}

void
ExecExprVisitor::visit(LogicalUnaryExpr& expr) {
Expand Down Expand Up @@ -603,6 +650,42 @@ ExecExprVisitor::ExecBinaryArithOpEvalRangeVisitorDispatcher(
return ExecDataRangeVisitorImpl<T>(
expr.column_.field_id, index_func, elem_func);
}
case ArithOpType::BAnd: {
auto index_func = [val, right_operand](Index* index,
size_t offset) {
auto x = index->Reverse_Lookup(offset);
return _bitand(x, right_operand) == val;
};
auto elem_func = [val, right_operand](MayConstRef<T> x) {
return _bitand(x, right_operand) == val;
};
return ExecDataRangeVisitorImpl<T>(
expr.column_.field_id, index_func, elem_func);
}
case ArithOpType::BXOr: {
auto index_func = [val, right_operand](Index* index,
size_t offset) {
auto x = index->Reverse_Lookup(offset);
return _bitxor(x, right_operand) == val;
};
auto elem_func = [val, right_operand](MayConstRef<T> x) {
return _bitxor(x, right_operand) == val;
};
return ExecDataRangeVisitorImpl<T>(
expr.column_.field_id, index_func, elem_func);
}
case ArithOpType::BOr: {
auto index_func = [val, right_operand](Index* index,
size_t offset) {
auto x = index->Reverse_Lookup(offset);
return _bitor(x, right_operand) == val;
};
auto elem_func = [val, right_operand](MayConstRef<T> x) {
return _bitor(x, right_operand) == val;
};
return ExecDataRangeVisitorImpl<T>(
expr.column_.field_id, index_func, elem_func);
}
default: {
PanicInfo("unsupported arithmetic operation");
}
Expand Down Expand Up @@ -670,6 +753,42 @@ ExecExprVisitor::ExecBinaryArithOpEvalRangeVisitorDispatcher(
return ExecDataRangeVisitorImpl<T>(
expr.column_.field_id, index_func, elem_func);
}
case ArithOpType::BAnd: {
auto index_func = [val, right_operand](Index* index,
size_t offset) {
auto x = index->Reverse_Lookup(offset);
return _bitand(x, right_operand) != val;
};
auto elem_func = [val, right_operand](MayConstRef<T> x) {
return _bitand(x, right_operand) != val;
};
return ExecDataRangeVisitorImpl<T>(
expr.column_.field_id, index_func, elem_func);
}
case ArithOpType::BXOr: {
auto index_func = [val, right_operand](Index* index,
size_t offset) {
auto x = index->Reverse_Lookup(offset);
return _bitxor(x, right_operand) != val;
};
auto elem_func = [val, right_operand](MayConstRef<T> x) {
return _bitxor(x, right_operand) != val;
};
return ExecDataRangeVisitorImpl<T>(
expr.column_.field_id, index_func, elem_func);
}
case ArithOpType::BOr: {
auto index_func = [val, right_operand](Index* index,
size_t offset) {
auto x = index->Reverse_Lookup(offset);
return _bitor(x, right_operand) != val;
};
auto elem_func = [val, right_operand](MayConstRef<T> x) {
return _bitor(x, right_operand) != val;
};
return ExecDataRangeVisitorImpl<T>(
expr.column_.field_id, index_func, elem_func);
}
default: {
PanicInfo("unsupported arithmetic operation");
}
Expand Down Expand Up @@ -790,6 +909,42 @@ ExecExprVisitor::ExecBinaryArithOpEvalRangeVisitorDispatcherJson(
return ExecDataRangeVisitorImpl<milvus::Json>(
expr.column_.field_id, index_func, elem_func);
}
case ArithOpType::BAnd: {
auto index_func = [val, right_operand](Index* index,
size_t offset) {
return false;
};
auto elem_func = [&](const milvus::Json& json) {
BinaryArithRangeJSONCompare(
_bitand(x.value(), right_operand) == val);
};
return ExecDataRangeVisitorImpl<milvus::Json>(
expr.column_.field_id, index_func, elem_func);
}
case ArithOpType::BXOr: {
auto index_func = [val, right_operand](Index* index,
size_t offset) {
return false;
};
auto elem_func = [&](const milvus::Json& json) {
BinaryArithRangeJSONCompare(
_bitxor(x.value(), right_operand) == val);
};
return ExecDataRangeVisitorImpl<milvus::Json>(
expr.column_.field_id, index_func, elem_func);
}
case ArithOpType::BOr: {
auto index_func = [val, right_operand](Index* index,
size_t offset) {
return false;
};
auto elem_func = [&](const milvus::Json& json) {
BinaryArithRangeJSONCompare(
_bitor(x.value(), right_operand) == val);
};
return ExecDataRangeVisitorImpl<milvus::Json>(
expr.column_.field_id, index_func, elem_func);
}
default: {
PanicInfo("unsupported arithmetic operation");
}
Expand Down Expand Up @@ -858,6 +1013,42 @@ ExecExprVisitor::ExecBinaryArithOpEvalRangeVisitorDispatcherJson(
return ExecDataRangeVisitorImpl<milvus::Json>(
expr.column_.field_id, index_func, elem_func);
}
case ArithOpType::BAnd: {
auto index_func = [val, right_operand](Index* index,
size_t offset) {
return false;
};
auto elem_func = [&](const milvus::Json& json) {
BinaryArithRangeJSONCompare(
_bitand(x.value(), right_operand) != val);
};
return ExecDataRangeVisitorImpl<milvus::Json>(
expr.column_.field_id, index_func, elem_func);
}
case ArithOpType::BXOr: {
auto index_func = [val, right_operand](Index* index,
size_t offset) {
return false;
};
auto elem_func = [&](const milvus::Json& json) {
BinaryArithRangeJSONCompare(
_bitxor(x.value(), right_operand) != val);
};
return ExecDataRangeVisitorImpl<milvus::Json>(
expr.column_.field_id, index_func, elem_func);
}
case ArithOpType::BOr: {
auto index_func = [val, right_operand](Index* index,
size_t offset) {
return false;
};
auto elem_func = [&](const milvus::Json& json) {
BinaryArithRangeJSONCompare(
_bitor(x.value(), right_operand) != val);
};
return ExecDataRangeVisitorImpl<milvus::Json>(
expr.column_.field_id, index_func, elem_func);
}
default: {
PanicInfo("unsupported arithmetic operation");
}
Expand Down
Loading