This is an automated email from the ASF dual-hosted git repository.

jianliangqi pushed a commit to branch clucene
in repository https://gitbox.apache.org/repos/asf/doris-thirdparty.git


The following commit(s) were added to refs/heads/clucene by this push:
     new 9e60ec66 [fix](keyword) fix the keyword type index length limit (#114)
9e60ec66 is described below

commit 9e60ec666b3ccf7dd8b7c3e331ac03ccf87d5845
Author: zzzxl <[email protected]>
AuthorDate: Fri Aug 25 17:24:57 2023 +0800

    [fix](keyword) fix the keyword type index length limit (#114)
---
 src/core/CLucene/debug/error.h             |  1 +
 src/core/CLucene/index/IndexWriter.cpp     | 11 ++++-------
 src/core/CLucene/index/SDocumentWriter.cpp | 14 ++++++++++----
 3 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/src/core/CLucene/debug/error.h b/src/core/CLucene/debug/error.h
index 821d9e13..0c48db3d 100644
--- a/src/core/CLucene/debug/error.h
+++ b/src/core/CLucene/debug/error.h
@@ -33,6 +33,7 @@
 #define CL_ERR_MergeAborted 22
 #define CL_ERR_OutOfMemory 23
 #define CL_ERR_FieldReader 24
+#define CL_ERR_MaxBytesLength 25
 
 ////////////////////////////////////////////////////////
 //error try/throw/catch definitions
diff --git a/src/core/CLucene/index/IndexWriter.cpp 
b/src/core/CLucene/index/IndexWriter.cpp
index 87cfaa5a..fe269a92 100644
--- a/src/core/CLucene/index/IndexWriter.cpp
+++ b/src/core/CLucene/index/IndexWriter.cpp
@@ -722,13 +722,10 @@ void IndexWriter::addDocument(Document *doc, Analyzer 
*an) {
                         message(string("hit exception adding document"));
 
                     {
-                        SCOPED_LOCK_MUTEX(this->THIS_LOCK)
-                        // If docWriter has some aborted files that were
-                        // never incref'd, then we clean them up here
-                        if (docWriter != NULL) {
-                            const std::vector<std::string> *files = 
docWriter->abortedFiles();
-                            if (files != NULL)
-                                deleter->deleteNewFiles(*files);
+                        std::vector<std::string> files;
+                        directory->list(files);
+                        for (auto& file : files) {
+                            directory->deleteFile(file.c_str());
                         }
                     }
                 })
diff --git a/src/core/CLucene/index/SDocumentWriter.cpp 
b/src/core/CLucene/index/SDocumentWriter.cpp
index e304999b..a91f67d2 100644
--- a/src/core/CLucene/index/SDocumentWriter.cpp
+++ b/src/core/CLucene/index/SDocumentWriter.cpp
@@ -319,7 +319,7 @@ void 
SDocumentsWriter<T>::ThreadState::FieldData::processField(Analyzer *sanalyz
 
             // docFieldsFinal.values[j] = NULL;
         }
-    } catch (exception &ae) {
+    } catch (CLuceneError& ae) {
         throw ae;
     }
 }
@@ -536,6 +536,12 @@ void 
SDocumentsWriter<T>::ThreadState::FieldData::addPosition(Token *token) {
 
             const int32_t textLen1 = 1 + tokenTextLen;
             if (textLen1 + threadState->scharPool->tUpto > CHAR_BLOCK_SIZE) {
+                if (textLen1 > CHAR_BLOCK_SIZE) {
+                    std::string errmsg = "bytes can be at most " +
+                                         std::to_string(CHAR_BLOCK_SIZE - 1) +
+                                         " in length; got " + 
std::to_string(tokenTextLen);
+                    _CLTHROWA(CL_ERR_MaxBytesLength, errmsg.c_str());
+                }
                 threadState->scharPool->nextBuffer();
             }
             T *text = threadState->scharPool->buffer;
@@ -835,7 +841,7 @@ bool SDocumentsWriter<T>::updateDocument(Document *doc, 
Analyzer *sanalyzer) {
                     finishDocument(state);)
             success = true;
         }
-        _CLFINALLY(
+    _CLFINALLY(
                 if (!success) {
                     // If this thread state had decided to flush, we
                     // must clear it so another thread can flush
@@ -844,8 +850,8 @@ bool SDocumentsWriter<T>::updateDocument(Document *doc, 
Analyzer *sanalyzer) {
                         flushPending = false;
                     }
                 })
-    } catch (exception &ae) {
-        abort(nullptr);
+    } catch (CLuceneError& ae) {
+        throw ae;
     }
 
     return state->doFlushAfter;


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

Reply via email to