You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/10/13 09:25:37 UTC

[GitHub] [doris] zhannngchen commented on a diff in pull request #13336: [fix](jsonreader) teach jsonreader to release memory

zhannngchen commented on code in PR #13336:
URL: https://github.com/apache/doris/pull/13336#discussion_r994388402


##########
be/src/exec/json_scanner.cpp:
##########
@@ -343,6 +346,8 @@ Status JsonReader::_parse_json_doc(size_t* size, bool* eof) {
         return Status::OK();
     }
 
+    // clear memory here.
+    _origin_json_doc.GetAllocator().Clear();

Review Comment:
   Why not just create a new `Document` each time we need to parse? It's not reasonable to make _origin_json_doc as a class member variable?



##########
be/src/exec/json_scanner.h:
##########
@@ -178,7 +178,15 @@ class JsonReader {
     std::vector<std::vector<JsonPath>> _parsed_jsonpaths;
     std::vector<JsonPath> _parsed_json_root;
 
-    rapidjson::Document _origin_json_doc; // origin json document object from parsed json string
+    char _value_buffer[4 * 1024 * 1024];
+    char _parse_buffer[512 * 1024];
+
+    typedef rapidjson::GenericDocument<rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator<>,
+                                       rapidjson::MemoryPoolAllocator<>>
+            Document;
+    rapidjson::MemoryPoolAllocator<> _value_allocator;
+    rapidjson::MemoryPoolAllocator<> _parse_allocator;

Review Comment:
   Dose `crtAllocator` a better choice?



-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org