HappenLee commented on code in PR #51300:
URL: https://github.com/apache/doris/pull/51300#discussion_r2115200186


##########
be/src/util/jsonb_parser_simd.h:
##########
@@ -56,219 +56,171 @@
  * and modified by Doris
  */
 
-#ifndef JSONB_JSONBJSONPARSERSIMD_H
-#define JSONB_JSONBJSONPARSERSIMD_H
-
+#pragma once
 #include <simdjson.h>
 
 #include <cmath>
 #include <limits>
 
+#include "common/status.h"
 #include "jsonb_document.h"
-#include "jsonb_error.h"
 #include "jsonb_writer.h"
 #include "string_parser.hpp"
 
 namespace doris {
-
+#include "common/compile_check_begin.h"
 using int128_t = __int128;
-class JsonbParserTSIMD {
-public:
-    JsonbParserTSIMD() : err_(JsonbErrType::E_NONE) {}
-
-    explicit JsonbParserTSIMD(JsonbOutStream& os) : writer_(os), 
err_(JsonbErrType::E_NONE) {}
-
-    // parse a UTF-8 JSON string
-    bool parse(const std::string& str) { return parse(str.c_str(), 
str.size()); }
-
-    // parse a UTF-8 JSON c-style string (NULL terminated)
-    bool parse(const char* c_str) { return parse(c_str, strlen(c_str)); }
-
+struct JsonbParser {
     // parse a UTF-8 JSON string with length
-    bool parse(const char* pch, size_t len) {
-        // reset state before parse
-        reset();
-
+    // will reset writer before parse
+    static Status parse(const char* pch, size_t len, JsonbWriter& writer) {
         if (!pch || len == 0) {
-            err_ = JsonbErrType::E_EMPTY_DOCUMENT;
-            VLOG_DEBUG << "empty json string";
-            return false;
+            return Status::InternalError("Empty JSON document");
         }
-
-        // parse json using simdjson, return false on exception
+        writer.reset();
         try {
+            simdjson::ondemand::parser simdjson_parser;

Review Comment:
   why contruct a new parser not just constuct a new writer need pass from param



-- 
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

Reply via email to