yiguolei commented on code in PR #20028:
URL: https://github.com/apache/doris/pull/20028#discussion_r1206130316


##########
be/src/olap/rowset/segment_v2/inverted_index_writer.cpp:
##########
@@ -85,7 +85,26 @@ class InvertedIndexColumnWriterImpl : public 
InvertedIndexColumnWriter {
         _field_name = std::wstring(field_name.begin(), field_name.end());
     }
 
-    ~InvertedIndexColumnWriterImpl() override = default;
+    ~InvertedIndexColumnWriterImpl() override {
+        // The close function is expected to be called when the column writer 
finishes its operations.
+        // If it's not called, it indicates that an unexpected event has 
occurred.
+        // This destructor checks if the close() function has been called. If 
not, it attempts to release memory.
+        if (_index_writer) {
+            _CLDELETE(_index_writer)
+        }
+
+        if (_doc) {
+            _CLDELETE(_doc)
+        }
+
+        if (_analyzer) {

Review Comment:
           _index_writer = _CLNEW lucene::index::IndexWriter(_dir.get(), 
_analyzer, create, true);
           _index_writer->setMaxBufferedDocs(MAX_BUFFER_DOCS);
           
_index_writer->setRAMBufferSizeMB(config::inverted_index_ram_buffer_size);
           _index_writer->setMaxFieldLength(MAX_FIELD_LEN);
           _index_writer->setMergeFactor(MERGE_FACTOR);
           _index_writer->setUseCompoundFile(false);
   These method will also failed or throw exception. The _index_Writer maybe 
not deleted. So could you please use smart pointer to manage index_writer?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to