MCPcopy Create free account
hub / github.com/alibaba/zvec / handle_const_node

Method handle_const_node

src/db/sqlengine/parser/zvec_sql_parser.cc:551–583  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

549}
550
551Node::Ptr ZVecSQLParser::handle_const_node(VoidPtr node) {
552 Node::Ptr const_expr = nullptr;
553 SQLParser::ConstantContext *constant_node =
554 reinterpret_cast<SQLParser::ConstantContext *>(node);
555 if (constant_node->numeric()) {
556 const_expr =
557 std::make_shared<ConstantNode>(constant_node->numeric()->getText());
558 if (constant_node->numeric()->int_value()) {
559 const_expr->set_op(NodeOp::T_INT_VALUE);
560 } else if (constant_node->numeric()->float_value()) {
561 const_expr->set_op(NodeOp::T_FLOAT_VALUE);
562 }
563 } else if (constant_node->quoted_string()) {
564 std::string value = constant_node->quoted_string()->getText();
565 value = trim(value);
566 value = Util::normalize(value);
567 const_expr = std::make_shared<ConstantNode>(value);
568 const_expr->set_op(NodeOp::T_STRING_VALUE);
569 } else if (constant_node->vector_expr()) {
570 const_expr = handle_vector_expr_node(constant_node->vector_expr());
571 if (const_expr == nullptr) {
572 err_msg_ = "Parse failed. vector format error." +
573 constant_node->vector_expr()->getText();
574 LOG_ERROR("Parse failed. vector format error. [%s]",
575 constant_node->vector_expr()->getText().c_str());
576 return nullptr;
577 }
578 } else if (constant_node->bool_value()) {
579 const_expr = handle_bool_value_node(constant_node->bool_value());
580 }
581
582 return const_expr;
583}
584
585Node::Ptr ZVecSQLParser::handle_const_num_and_str_node(VoidPtr node) {
586 Node::Ptr const_expr = nullptr;

Callers

nothing calls this directly

Calls 9

numericMethod · 0.80
getTextMethod · 0.80
int_valueMethod · 0.80
quoted_stringMethod · 0.80
vector_exprMethod · 0.80
c_strMethod · 0.80
set_opMethod · 0.45
float_valueMethod · 0.45
bool_valueMethod · 0.45

Tested by

no test coverage detected