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

Method traverse_to_replace

src/db/sqlengine/parser/zvec_cached_sql_parser.cc:167–206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165}
166
167int ZVecCachedSQLParser::traverse_to_replace(Node::Ptr ptr,
168 Node::Ptr vector_node) {
169 if (ptr->op() == NodeOp::T_VECTOR_MATRIX_VALUE) {
170 Node *parent = dynamic_cast<Node *>(ptr->parent());
171 if (parent == nullptr) {
172 LOG_WARN("wrong parent node in cache. [%s]", ptr->to_string().c_str());
173 return -1;
174 }
175 if (parent->left() == ptr) {
176 parent->set_left(vector_node);
177 replace_flag_ = true;
178 } else if (parent->right() == ptr) {
179 parent->set_right(vector_node);
180 replace_flag_ = true;
181 } else {
182 LOG_WARN("wrong node in cache. [%s]", ptr->to_string().c_str());
183 return -1;
184 }
185 return 0;
186 }
187
188 if (ptr->left() != nullptr) {
189 if (traverse_to_replace(ptr->left(), vector_node) < 0) {
190 return -1;
191 }
192 if (replace_flag_) {
193 return 0;
194 }
195 }
196 if (ptr->right() != nullptr) {
197 if (traverse_to_replace(ptr->right(), vector_node) != 0) {
198 return -1;
199 }
200 if (replace_flag_) {
201 return 0;
202 }
203 }
204
205 return 0;
206}
207
208Node::Ptr ZVecCachedSQLParser::parse_filter(const std::string &filter,
209 bool need_formatted_tree) {

Callers

nothing calls this directly

Calls 6

opMethod · 0.80
parentMethod · 0.80
c_strMethod · 0.80
set_leftMethod · 0.80
set_rightMethod · 0.80
to_stringMethod · 0.45

Tested by

no test coverage detected