xiaokang commented on code in PR #152:
URL: https://github.com/apache/doris-thirdparty/pull/152#discussion_r1429137157


##########
src/core/CLucene/index/IndexWriter.cpp:
##########
@@ -1246,39 +1246,30 @@ void 
IndexWriter::indexCompaction(std::vector<lucene::store::Directory *> &src_d
     CND_CONDITION(dest_dirs.size() > 0, "Destination directory not found.");
     this->_trans_vec = std::move(trans_vec);
 
-    // order mapping: dir -> segment info -> segment reader
-    addIndexesSegments(src_dirs);
-
     // create segment readers
-    int32_t totDocCount = 0;
-    int numSegments = segmentInfos->size();
-    assert(numSegments > 0);
+    int numIndices = src_dirs.size();
 
     //Set of IndexReaders
     if (infoStream != NULL) {
-        message(string("src index dir size: ") + Misc::toString(numSegments));
+        message(string("src index dir size: ") + Misc::toString(numIndices));
     }
-    for (int32_t i = 0; i < numSegments; i++) {
-        SegmentInfo *si = segmentInfos->info(i);
-        IndexReader *reader = SegmentReader::get(si, MERGE_READ_BUFFER_SIZE, 
false /* mergeDocStores */);
+    for (int32_t i = 0; i < numIndices; i++) {
+        IndexReader* reader = lucene::index::IndexReader::open(src_dirs[i], 
MERGE_READ_BUFFER_SIZE, false);

Review Comment:
   add comment to explain why change si to src_dir[i] 



##########
src/core/CLucene/index/IndexWriter.cpp:
##########
@@ -1618,11 +1606,25 @@ void IndexWriter::mergeTerms(bool hasProx) {
 
         match[matchSize++] = queue->pop();
         Term *smallestTerm = match[0]->term;
-        // std::wstring ws = smallestTerm->text();
-        // std::string name = std::string(ws.begin(), ws.end());
-        // std::cout << name << std::endl;
-
         SegmentMergeInfo *top = queue->top();
+        if (infoStream != nullptr) {
+            std::wstring ws = smallestTerm->text();
+            std::wstring f = smallestTerm->field();
+            std::string name = std::string(ws.begin(), ws.end());
+            std::string field = std::string(f.begin(), f.end());
+            message("smallestTerm name: " + name);
+            message("smallestTerm field: " + field);
+
+            if (top != nullptr) {
+                Term* topTerm = top->term;

Review Comment:
   Are these wstring and string variables just for debug message? If true, add 
debug check for performance.



##########
src/core/CLucene/index/IndexWriter.cpp:
##########
@@ -1515,9 +1506,9 @@ void 
IndexWriter::addIndexesSegments(std::vector<lucene::store::Directory *> &di
         {
             SCOPED_LOCK_MUTEX(this->THIS_LOCK)
             for (auto dir: dirs) {
-                SegmentInfos sis;// read infos from dir
-                sis.read(dir);
-                segmentInfos->insert(&sis, true);
+                SegmentInfos* sis = new SegmentInfos(); // Create SegmentInfos 
on heap

Review Comment:
   where is sis deleted?



-- 
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: dev-unsubscr...@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@doris.apache.org
For additional commands, e-mail: dev-h...@doris.apache.org

Reply via email to