xiaokang commented on code in PR #20116:
URL: https://github.com/apache/doris/pull/20116#discussion_r1207939510


##########
be/src/olap/rowset/segment_v2/inverted_index_writer.cpp:
##########
@@ -171,6 +171,12 @@ class InvertedIndexColumnWriterImpl : public 
InvertedIndexColumnWriter {
             auto chinese_analyzer = _CLNEW 
lucene::analysis::LanguageBasedAnalyzer();
             chinese_analyzer->setLanguage(L"chinese");
             chinese_analyzer->initDict(config::inverted_index_dict_path);
+            auto mode = 
get_parser_mode_string_from_properties(_index_meta->properties());
+            if (mode == INVERTED_INDEX_PARSER_COARSE_GRANULARITY) {
+                
chinese_analyzer->setMode(lucene::analysis::AnalyzerMode::Default);

Review Comment:
   Normally check special case in if branches and left default to else branch.



##########
be/src/olap/rowset/segment_v2/inverted_index_writer.cpp:
##########
@@ -215,13 +221,9 @@ class InvertedIndexColumnWriterImpl : public 
InvertedIndexColumnWriter {
     }
 
     void new_fulltext_field(const char* field_value_data, size_t 
field_value_size) {
-        if (_parser_type == InvertedIndexParserType::PARSER_ENGLISH) {
+        if (_parser_type == InvertedIndexParserType::PARSER_ENGLISH ||
+            _parser_type == InvertedIndexParserType::PARSER_CHINESE) {
             new_char_token_stream(field_value_data, field_value_size, _field);
-        } else if (_parser_type == InvertedIndexParserType::PARSER_CHINESE) {

Review Comment:
   Is there any risk to merge english and chinese parser? 



##########
regression-test/suites/inverted_index_p0/test_chinese_analyzer.groovy:
##########
@@ -0,0 +1,55 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+
+suite("test_chinese_analyzer"){
+    // prepare test table
+
+
+    def timeout = 60000
+    def delta_time = 1000
+    def alter_res = "null"
+    def useTime = 0
+
+    def indexTblName = "chinese_analyzer_test"
+
+    sql "DROP TABLE IF EXISTS ${indexTblName}"
+    // create 1 replica table
+    sql """
+       CREATE TABLE IF NOT EXISTS ${indexTblName}(
+               `id`int(11)NULL,
+               `c` text NULL,
+               INDEX c_idx(`c`) USING INVERTED 
PROPERTIES("parser"="chinese","parser_mode"="fine_grained") COMMENT ''

Review Comment:
   Add another column and index with coarse_graind parser_mode and test match 
an the column



##########
be/src/olap/rowset/segment_v2/inverted_index_reader.h:
##########
@@ -78,76 +78,72 @@ enum class InvertedIndexQueryType {
 class InvertedIndexReader {
 public:
     explicit InvertedIndexReader(io::FileSystemSPtr fs, const std::string& 
path,
-                                 const uint32_t index_id)
-            : _fs(std::move(fs)), _path(path), _index_id(index_id) {}
+                                 const TabletIndex* index_meta)
+            : _fs(std::move(fs)), _path(path), _index_meta(*index_meta) {}
     virtual ~InvertedIndexReader() = default;
 
     // create a new column iterator. Client should delete returned iterator
-    virtual Status new_iterator(const TabletIndex* index_meta, 
OlapReaderStatistics* stats,
-                                InvertedIndexIterator** iterator) = 0;
+    virtual Status new_iterator(OlapReaderStatistics* stats, 
InvertedIndexIterator** iterator) = 0;
     virtual Status query(OlapReaderStatistics* stats, const std::string& 
column_name,
                          const void* query_value, InvertedIndexQueryType 
query_type,
-                         InvertedIndexParserType analyser_type, 
roaring::Roaring* bit_map) = 0;
+                         roaring::Roaring* bit_map) = 0;
     virtual Status try_query(OlapReaderStatistics* stats, const std::string& 
column_name,
                              const void* query_value, InvertedIndexQueryType 
query_type,
-                             InvertedIndexParserType analyser_type, uint32_t* 
count) = 0;
+                             uint32_t* count) = 0;
 
     Status read_null_bitmap(InvertedIndexQueryCacheHandle* cache_handle,
                             lucene::store::Directory* dir = nullptr);
 
     virtual InvertedIndexReaderType type() = 0;
     bool indexExists(io::Path& index_file_path);
 
-    uint32_t get_index_id() const { return _index_id; }
+    uint32_t get_index_id() const { return _index_meta.index_id(); }
 
 protected:
     bool _is_match_query(InvertedIndexQueryType query_type);
     friend class InvertedIndexIterator;
     io::FileSystemSPtr _fs;
     std::string _path;
-    uint32_t _index_id;
+    TabletIndex _index_meta;

Review Comment:
   It's more concise to move _index_meta from IndexIterator to IndexReader. But 
the life cycle of IndexIterator, IndexReader, and _index_meta need to be 
checked more carefully.



-- 
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