github-actions[bot] commented on code in PR #24801: URL: https://github.com/apache/doris/pull/24801#discussion_r1566828289
########## be/src/util/jsonb_document.h: ########## @@ -1269,6 +1272,53 @@ } } +inline int JsonbValue::depth() const { + switch (type_) { + case JsonbType::T_Int8: + case JsonbType::T_Int16: + case JsonbType::T_Int32: + case JsonbType::T_Int64: + case JsonbType::T_Double: + case JsonbType::T_Float: + case JsonbType::T_Int128: + case JsonbType::T_String: + case JsonbType::T_Binary: + case JsonbType::T_Null: + case JsonbType::T_True: + case JsonbType::T_False: { + return 1; + } + case JsonbType::T_Object: { + int base_depth = 1; + int numElem = ((ObjectVal*)this)->numElem(); + if (numElem == 0) return base_depth; + + int max_depth = base_depth; + + for (int i = 0; i < numElem; ++i) { + JsonbKeyValue* key = ((ObjectVal*)this)->getJsonbKeyValue(i); + JsonbValue* value = ((ObjectVal*)this)->find(key->getKeyStr(), key->klen()); + int current_depth = base_depth + value->depth(); + if (current_depth > max_depth) max_depth = current_depth; + } + return max_depth; + } + case JsonbType::T_Array: { + int base_depth = 1; + int numElem = ((ArrayVal*)this)->numElem(); + if (numElem == 0) return base_depth; Review Comment: warning: statement should be inside braces [readability-braces-around-statements] ```suggestion if (numElem == 0) { return base_depth; } ``` ########## be/src/util/jsonb_document.h: ########## @@ -1269,6 +1272,53 @@ inline int JsonbValue::length() const { } } +inline int JsonbValue::depth() const { + switch (type_) { + case JsonbType::T_Int8: + case JsonbType::T_Int16: + case JsonbType::T_Int32: + case JsonbType::T_Int64: + case JsonbType::T_Double: + case JsonbType::T_Float: + case JsonbType::T_Int128: + case JsonbType::T_String: + case JsonbType::T_Binary: + case JsonbType::T_Null: + case JsonbType::T_True: + case JsonbType::T_False: { + return 1; + } + case JsonbType::T_Object: { + int base_depth = 1; + int numElem = ((ObjectVal*)this)->numElem(); + if (numElem == 0) return base_depth; Review Comment: warning: statement should be inside braces [readability-braces-around-statements] ```suggestion if (numElem == 0) { return base_depth; } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org