You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by ji...@apache.org on 2024/09/02 07:28:12 UTC

(doris-thirdparty) branch clucene updated: [fix](inverted index) Handle an empty segment index file (#239)

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 c5d02a7e411 [fix](inverted index) Handle an empty segment index file (#239)
c5d02a7e411 is described below

commit c5d02a7e41194b02444be6d684e3aeb4ff1b5595
Author: zzzxl <33...@users.noreply.github.com>
AuthorDate: Mon Sep 2 15:28:07 2024 +0800

    [fix](inverted index) Handle an empty segment index file (#239)
---
 src/core/CLucene/debug/error.h                  | 1 +
 src/core/CLucene/index/DirectoryIndexReader.cpp | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/core/CLucene/debug/error.h b/src/core/CLucene/debug/error.h
index 5c5c6203524..4724b460a3a 100644
--- a/src/core/CLucene/debug/error.h
+++ b/src/core/CLucene/debug/error.h
@@ -35,6 +35,7 @@
 #define CL_ERR_FieldReader 24
 #define CL_ERR_MaxBytesLength 25
 #define CL_ERR_FileNotFound 26
+#define CL_ERR_EmptyIndexSegment 27
 
 ////////////////////////////////////////////////////////
 //error try/throw/catch definitions
diff --git a/src/core/CLucene/index/DirectoryIndexReader.cpp b/src/core/CLucene/index/DirectoryIndexReader.cpp
index ba3a42ffb75..24f7c105e01 100644
--- a/src/core/CLucene/index/DirectoryIndexReader.cpp
+++ b/src/core/CLucene/index/DirectoryIndexReader.cpp
@@ -152,7 +152,9 @@ CL_NS_DEF(index)
 
       DirectoryIndexReader* reader;
 
-      if (infos->size() == 1) {          // index is optimized
+      if (infos->size() == 0) {
+        _CLTHROWA(CL_ERR_EmptyIndexSegment, "The number of index segments is 0, indicating incorrect index generation.");
+      } else if (infos->size() == 1) {          // index is optimized
         reader = SegmentReader::get(infos, infos->info(0), readBufferSize_, closeDirectory);
       } else {
         reader = _CLNEW MultiSegmentReader(directory, infos, closeDirectory, readBufferSize_);


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