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

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


The following commit(s) were added to refs/heads/master by this push:
     new 6dbe07bd3b [Enhancement](inverted index) use conjunction query to 
accelerate fulltext equal query (#24373)
6dbe07bd3b is described below

commit 6dbe07bd3be740819cd48425ba15f8cc5577ca4b
Author: airborne12 <airborn...@gmail.com>
AuthorDate: Fri Sep 15 15:34:57 2023 +0800

    [Enhancement](inverted index) use conjunction query to accelerate fulltext 
equal query (#24373)
---
 .../rowset/segment_v2/inverted_index_reader.cpp    |  8 +---
 .../inverted_index_p0/test_equal_on_fulltext.out   |  8 ++++
 .../test_equal_on_fulltext.groovy                  | 52 ++++++++++++++++++++++
 3 files changed, 62 insertions(+), 6 deletions(-)

diff --git a/be/src/olap/rowset/segment_v2/inverted_index_reader.cpp 
b/be/src/olap/rowset/segment_v2/inverted_index_reader.cpp
index cef35a9f51..8ab7eaade0 100644
--- a/be/src/olap/rowset/segment_v2/inverted_index_reader.cpp
+++ b/be/src/olap/rowset/segment_v2/inverted_index_reader.cpp
@@ -280,7 +280,8 @@ Status FullTextIndexReader::query(OlapReaderStatistics* 
stats, RuntimeState* run
         roaring::Roaring query_match_bitmap;
         bool null_bitmap_already_read = false;
         if (query_type == InvertedIndexQueryType::MATCH_PHRASE_QUERY ||
-            query_type == InvertedIndexQueryType::MATCH_ALL_QUERY) {
+            query_type == InvertedIndexQueryType::MATCH_ALL_QUERY ||
+            query_type == InvertedIndexQueryType::EQUAL_QUERY) {
             std::wstring wstr_tokens;
             for (auto& token : analyse_result) {
                 wstr_tokens += token;
@@ -381,11 +382,6 @@ Status FullTextIndexReader::query(OlapReaderStatistics* 
stats, RuntimeState* run
                     query_match_bitmap |= *term_match_bitmap;
                     break;
                 }
-                case InvertedIndexQueryType::EQUAL_QUERY: {
-                    
SCOPED_RAW_TIMER(&stats->inverted_index_query_bitmap_op_timer);
-                    query_match_bitmap &= *term_match_bitmap;
-                    break;
-                }
                 default: {
                     return 
Status::Error<ErrorCode::INVERTED_INDEX_NOT_SUPPORTED>(
                             "fulltext query do not support query type other 
than match.");
diff --git a/regression-test/data/inverted_index_p0/test_equal_on_fulltext.out 
b/regression-test/data/inverted_index_p0/test_equal_on_fulltext.out
new file mode 100644
index 0000000000..722fc00aea
--- /dev/null
+++ b/regression-test/data/inverted_index_p0/test_equal_on_fulltext.out
@@ -0,0 +1,8 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !sql --
+2      I am a person
+
+-- !sql --
+1      I am the person
+2      I am a person
+
diff --git 
a/regression-test/suites/inverted_index_p0/test_equal_on_fulltext.groovy 
b/regression-test/suites/inverted_index_p0/test_equal_on_fulltext.groovy
new file mode 100644
index 0000000000..6d3a1bd06c
--- /dev/null
+++ b/regression-test/suites/inverted_index_p0/test_equal_on_fulltext.groovy
@@ -0,0 +1,52 @@
+// 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_equal_on_fulltext", "p0"){
+    // prepare test table
+
+
+    def timeout = 60000
+    def delta_time = 1000
+    def alter_res = "null"
+    def useTime = 0
+
+    def indexTblName = "test_equal_on_fulltext"
+
+    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"="unicode") 
COMMENT ''
+       ) ENGINE=OLAP
+       DUPLICATE KEY(`id`)
+       COMMENT 'OLAP'
+       DISTRIBUTED BY HASH(`id`) BUCKETS 1
+       PROPERTIES(
+               "replication_allocation" = "tag.location.default: 1"
+       );
+    """
+    
+    def var_result = sql "show variables"
+    logger.info("show variales result: " + var_result )
+
+    sql "INSERT INTO $indexTblName VALUES (1, 'I am the person'), (2, 'I am a 
person'), (3, 'I am your person');"
+    qt_sql "SELECT * FROM $indexTblName WHERE c = 'I am a person' ORDER BY id;"
+    qt_sql "SELECT * FROM $indexTblName WHERE c in ('I am a person', 'I am the 
person') ORDER BY id;"
+}


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

Reply via email to