From c5beef16a9633d2cff1d7b516dda34b458e459e9 Mon Sep 17 00:00:00 2001 From: yukun Date: Wed, 22 Sep 2021 18:07:54 +0800 Subject: [PATCH] Add error msgs in segcore visitors (#8306) Signed-off-by: fishpenguin --- .../src/query/visitors/ShowExprVisitor.cpp | 26 +++++++++---------- .../query/visitors/ShowPlanNodeVisitor.cpp | 4 +-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/internal/core/src/query/visitors/ShowExprVisitor.cpp b/internal/core/src/query/visitors/ShowExprVisitor.cpp index a77a681500..92c648ce02 100644 --- a/internal/core/src/query/visitors/ShowExprVisitor.cpp +++ b/internal/core/src/query/visitors/ShowExprVisitor.cpp @@ -59,11 +59,11 @@ class ShowExprNodeVisitor : ExprVisitor { void ShowExprVisitor::visit(LogicalUnaryExpr& expr) { - Assert(!ret_.has_value()); + AssertInfo(!ret_.has_value(), "[ShowExprVisitor]Ret json already has value before visit"); using OpType = LogicalUnaryExpr::OpType; // TODO: use magic_enum if available - Assert(expr.op_type_ == OpType::LogicalNot); + AssertInfo(expr.op_type_ == OpType::LogicalNot, "[ShowExprVisitor]Expr op type isn't LogicNot"); auto op_name = "LogicalNot"; Json extra{ @@ -75,7 +75,7 @@ ShowExprVisitor::visit(LogicalUnaryExpr& expr) { void ShowExprVisitor::visit(LogicalBinaryExpr& expr) { - Assert(!ret_.has_value()); + AssertInfo(!ret_.has_value(), "[ShowExprVisitor]Ret json already has value before visit"); using OpType = LogicalBinaryExpr::OpType; // TODO: use magic_enum if available @@ -103,14 +103,14 @@ template static Json TermExtract(const TermExpr& expr_raw) { auto expr = dynamic_cast*>(&expr_raw); - Assert(expr); + AssertInfo(expr, "[ShowExprVisitor]TermExpr cast to TermExprImpl failed"); return Json{expr->terms_}; } void ShowExprVisitor::visit(TermExpr& expr) { - Assert(!ret_.has_value()); - Assert(datatype_is_vector(expr.data_type_) == false); + AssertInfo(!ret_.has_value(), "[ShowExprVisitor]Ret json already has value before visit"); + AssertInfo(datatype_is_vector(expr.data_type_) == false, "[ShowExprVisitor]Data type of expr isn't vector type"); auto terms = [&] { switch (expr.data_type_) { case DataType::BOOL: @@ -146,7 +146,7 @@ UnaryRangeExtract(const UnaryRangeExpr& expr_raw) { using proto::plan::OpType; using proto::plan::OpType_Name; auto expr = dynamic_cast*>(&expr_raw); - Assert(expr); + AssertInfo(expr, "[ShowExprVisitor]UnaryRangeExpr cast to UnaryRangeExprImpl failed"); Json res{{"expr_type", "UnaryRange"}, {"field_offset", expr->field_offset_.get()}, {"data_type", datatype_name(expr->data_type_)}, @@ -157,8 +157,8 @@ UnaryRangeExtract(const UnaryRangeExpr& expr_raw) { void ShowExprVisitor::visit(UnaryRangeExpr& expr) { - Assert(!ret_.has_value()); - Assert(datatype_is_vector(expr.data_type_) == false); + AssertInfo(!ret_.has_value(), "[ShowExprVisitor]Ret json already has value before visit"); + AssertInfo(datatype_is_vector(expr.data_type_) == false, "[ShowExprVisitor]Data type of expr isn't vector type"); switch (expr.data_type_) { case DataType::BOOL: ret_ = UnaryRangeExtract(expr); @@ -192,7 +192,7 @@ BinaryRangeExtract(const BinaryRangeExpr& expr_raw) { using proto::plan::OpType; using proto::plan::OpType_Name; auto expr = dynamic_cast*>(&expr_raw); - Assert(expr); + AssertInfo(expr, "[ShowExprVisitor]BinaryRangeExpr cast to BinaryRangeExprImpl failed"); Json res{{"expr_type", "BinaryRange"}, {"field_offset", expr->field_offset_.get()}, {"data_type", datatype_name(expr->data_type_)}, @@ -205,8 +205,8 @@ BinaryRangeExtract(const BinaryRangeExpr& expr_raw) { void ShowExprVisitor::visit(BinaryRangeExpr& expr) { - Assert(!ret_.has_value()); - Assert(datatype_is_vector(expr.data_type_) == false); + AssertInfo(!ret_.has_value(), "[ShowExprVisitor]Ret json already has value before visit"); + AssertInfo(datatype_is_vector(expr.data_type_) == false, "[ShowExprVisitor]Data type of expr isn't vector type"); switch (expr.data_type_) { case DataType::BOOL: ret_ = BinaryRangeExtract(expr); @@ -238,7 +238,7 @@ void ShowExprVisitor::visit(CompareExpr& expr) { using proto::plan::OpType; using proto::plan::OpType_Name; - Assert(!ret_.has_value()); + AssertInfo(!ret_.has_value(), "[ShowExprVisitor]Ret json already has value before visit"); Json res{{"expr_type", "Compare"}, {"left_field_offset", expr.left_field_offset_.get()}, diff --git a/internal/core/src/query/visitors/ShowPlanNodeVisitor.cpp b/internal/core/src/query/visitors/ShowPlanNodeVisitor.cpp index 6662dfdd71..e981d788e5 100644 --- a/internal/core/src/query/visitors/ShowPlanNodeVisitor.cpp +++ b/internal/core/src/query/visitors/ShowPlanNodeVisitor.cpp @@ -63,7 +63,7 @@ ShowPlanNodeVisitor::visit(FloatVectorANNS& node) { }; if (node.predicate_.has_value()) { ShowExprVisitor expr_show; - Assert(node.predicate_.value()); + AssertInfo(node.predicate_.value(), "[ShowPlanNodeVisitor]Can't get value from node predict"); json_body["predicate"] = expr_show.call_child(node.predicate_->operator*()); } else { json_body["predicate"] = "None"; @@ -85,7 +85,7 @@ ShowPlanNodeVisitor::visit(BinaryVectorANNS& node) { }; if (node.predicate_.has_value()) { ShowExprVisitor expr_show; - Assert(node.predicate_.value()); + AssertInfo(node.predicate_.value(), "[ShowPlanNodeVisitor]Can't get value from node predict"); json_body["predicate"] = expr_show.call_child(node.predicate_->operator*()); } else { json_body["predicate"] = "None";