github-actions[bot] commented on code in PR #14211:
URL: https://github.com/apache/doris/pull/14211#discussion_r1058183476


##########
be/src/exprs/match_predicate.h:
##########
@@ -0,0 +1,85 @@
+// 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.
+
+#ifndef DORIS_BE_SRC_QUERY_EXPRS_MATCH_PREDICATE_H
+#define DORIS_BE_SRC_QUERY_EXPRS_MATCH_PREDICATE_H
+
+#include <memory>
+#include <string>
+
+#include "exprs/predicate.h"
+#include "gen_cpp/Exprs_types.h"
+#include "olap/column_predicate.h"
+#include "runtime/string_search.hpp"
+
+namespace doris {
+
+enum class MatchType;
+
+class MatchPredicateExpr : public Predicate {
+public:
+    MatchPredicateExpr(const TExprNode& node) : Predicate(node) {}
+    virtual ~MatchPredicateExpr() {}

Review Comment:
   warning: use '= default' to define a trivial destructor 
[modernize-use-equals-default]
   
   ```suggestion
       virtual ~MatchPredicateExpr() = default;
   ```
   



##########
be/src/exprs/match_predicate.h:
##########
@@ -0,0 +1,85 @@
+// 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.
+
+#ifndef DORIS_BE_SRC_QUERY_EXPRS_MATCH_PREDICATE_H
+#define DORIS_BE_SRC_QUERY_EXPRS_MATCH_PREDICATE_H
+
+#include <memory>
+#include <string>
+
+#include "exprs/predicate.h"
+#include "gen_cpp/Exprs_types.h"
+#include "olap/column_predicate.h"
+#include "runtime/string_search.hpp"
+
+namespace doris {
+
+enum class MatchType;
+
+class MatchPredicateExpr : public Predicate {
+public:
+    MatchPredicateExpr(const TExprNode& node) : Predicate(node) {}
+    virtual ~MatchPredicateExpr() {}
+    Expr* clone(ObjectPool* pool) const override {
+        return pool->add(new MatchPredicateExpr(*this));
+    }
+
+    static bool is_valid(std::string fn_name) {
+        return fn_name == "match_any" || fn_name == "match_all" ||
+               fn_name == "match_phrase" || fn_name == "match_element_eq" ||
+               fn_name == "match_element_lt" || fn_name == "match_element_gt" 
||
+               fn_name == "match_element_le" || fn_name == "match_element_ge";
+    }
+
+protected:
+    friend class Expr;
+};
+
+class MatchPredicate : public ColumnPredicate {
+public:
+    static void init() {}
+
+public:

Review Comment:
   warning: redundant access specifier has the same accessibility as the 
previous access specifier [readability-redundant-access-specifiers]
   
   ```suggestion
   
   ```
   **be/src/exprs/match_predicate.h:52:** previously declared here
   ```cpp
   public:
   ^
   ```
   



##########
be/src/exprs/match_predicate.h:
##########
@@ -0,0 +1,85 @@
+// 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.
+
+#ifndef DORIS_BE_SRC_QUERY_EXPRS_MATCH_PREDICATE_H
+#define DORIS_BE_SRC_QUERY_EXPRS_MATCH_PREDICATE_H
+
+#include <memory>
+#include <string>
+
+#include "exprs/predicate.h"
+#include "gen_cpp/Exprs_types.h"
+#include "olap/column_predicate.h"
+#include "runtime/string_search.hpp"
+
+namespace doris {
+
+enum class MatchType;
+
+class MatchPredicateExpr : public Predicate {
+public:
+    MatchPredicateExpr(const TExprNode& node) : Predicate(node) {}
+    virtual ~MatchPredicateExpr() {}

Review Comment:
   warning: prefer using 'override' or (rarely) 'final' instead of 'virtual' 
[modernize-use-override]
   
   ```suggestion
       ~MatchPredicateExpr() override {}
   ```
   



##########
be/src/olap/rowset/segment_v2/segment_iterator.cpp:
##########
@@ -180,6 +185,9 @@ Status SegmentIterator::_init() {
     _row_bitmap.addRange(0, _segment->num_rows());
     RETURN_IF_ERROR(_init_return_column_iterators());
     RETURN_IF_ERROR(_init_bitmap_index_iterators());
+    if (is_vec) {

Review Comment:
   warning: unknown type name 'is_vec'; did you mean 'iovec'? 
[clang-diagnostic-error]
   
   ```suggestion
       if (iovec) {
   ```
   **/usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h:25:** 'iovec' 
declared here
   ```cpp
   struct iovec
          ^
   ```
   



##########
be/src/olap/rowset/segment_v2/segment_iterator.cpp:
##########
@@ -180,6 +185,9 @@
     _row_bitmap.addRange(0, _segment->num_rows());
     RETURN_IF_ERROR(_init_return_column_iterators());
     RETURN_IF_ERROR(_init_bitmap_index_iterators());
+    if (is_vec) {

Review Comment:
   warning: expected unqualified-id [clang-diagnostic-error]
   ```cpp
       if (is_vec) {
                 ^
   ```
   



##########
be/src/olap/rowset/segment_v2/segment_iterator.cpp:
##########
@@ -1106,6 +1185,57 @@
     return Status::OK();
 }
 
+void SegmentIterator::_output_index_return_column(uint16_t* sel_rowid_idx, 
uint16_t select_size, vectorized::Block* block) {
+    if (block->rows() == 0) {
+        return;
+    }
+
+    for (auto column_sign : _rowid_result_for_index) {
+        block->insert({vectorized::ColumnUInt8::create(),
+                       std::make_shared<vectorized::DataTypeUInt8>(), 
column_sign.first});
+        if (!column_sign.second.first) {
+            // predicate not in compound query
+            block->get_by_name(column_sign.first).column =
+                    
vectorized::DataTypeUInt8().create_column_const(block->rows(), 1u);
+            continue;
+        }
+        _build_index_return_column(sel_rowid_idx, select_size, block, 
column_sign.first, column_sign.second.second);
+    }
+}
+
+void SegmentIterator::_build_index_return_column(uint16_t* sel_rowid_idx, 
uint16_t select_size,

Review Comment:
   warning: pointer parameter 'sel_rowid_idx' can be pointer to const 
[readability-non-const-parameter]
   
   ```suggestion
   void SegmentIterator::_build_index_return_column(const uint16_t* 
sel_rowid_idx, uint16_t select_size,
   ```
   
   be/src/olap/rowset/segment_v2/segment_iterator.h:174:
   ```diff
   -     void _build_index_return_column(uint16_t* sel_rowid_idx, uint16_t 
select_size,
   +     void _build_index_return_column(const uint16_t* sel_rowid_idx, 
uint16_t select_size,
   ```
   



##########
be/src/exprs/match_predicate.h:
##########
@@ -0,0 +1,85 @@
+// 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.
+
+#ifndef DORIS_BE_SRC_QUERY_EXPRS_MATCH_PREDICATE_H
+#define DORIS_BE_SRC_QUERY_EXPRS_MATCH_PREDICATE_H
+
+#include <memory>
+#include <string>
+
+#include "exprs/predicate.h"
+#include "gen_cpp/Exprs_types.h"
+#include "olap/column_predicate.h"
+#include "runtime/string_search.hpp"
+
+namespace doris {
+
+enum class MatchType;
+
+class MatchPredicateExpr : public Predicate {
+public:
+    MatchPredicateExpr(const TExprNode& node) : Predicate(node) {}
+    virtual ~MatchPredicateExpr() {}
+    Expr* clone(ObjectPool* pool) const override {
+        return pool->add(new MatchPredicateExpr(*this));
+    }
+
+    static bool is_valid(std::string fn_name) {
+        return fn_name == "match_any" || fn_name == "match_all" ||
+               fn_name == "match_phrase" || fn_name == "match_element_eq" ||
+               fn_name == "match_element_lt" || fn_name == "match_element_gt" 
||
+               fn_name == "match_element_le" || fn_name == "match_element_ge";
+    }
+
+protected:
+    friend class Expr;
+};
+
+class MatchPredicate : public ColumnPredicate {
+public:
+    static void init() {}
+
+public:
+    MatchPredicate(uint32_t column_id, const std::string& value, MatchType 
match_type);
+
+    virtual PredicateType type() const override;

Review Comment:
   warning: 'virtual' is redundant since the function is already declared 
'override' [modernize-use-override]
   
   ```suggestion
       PredicateType type() const override;
   ```
   



##########
be/src/exprs/match_predicate.h:
##########
@@ -0,0 +1,85 @@
+// 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.
+
+#ifndef DORIS_BE_SRC_QUERY_EXPRS_MATCH_PREDICATE_H
+#define DORIS_BE_SRC_QUERY_EXPRS_MATCH_PREDICATE_H
+
+#include <memory>
+#include <string>
+
+#include "exprs/predicate.h"
+#include "gen_cpp/Exprs_types.h"
+#include "olap/column_predicate.h"
+#include "runtime/string_search.hpp"
+
+namespace doris {
+
+enum class MatchType;
+
+class MatchPredicateExpr : public Predicate {
+public:
+    MatchPredicateExpr(const TExprNode& node) : Predicate(node) {}
+    virtual ~MatchPredicateExpr() {}
+    Expr* clone(ObjectPool* pool) const override {
+        return pool->add(new MatchPredicateExpr(*this));
+    }
+
+    static bool is_valid(std::string fn_name) {
+        return fn_name == "match_any" || fn_name == "match_all" ||
+               fn_name == "match_phrase" || fn_name == "match_element_eq" ||
+               fn_name == "match_element_lt" || fn_name == "match_element_gt" 
||
+               fn_name == "match_element_le" || fn_name == "match_element_ge";
+    }
+
+protected:
+    friend class Expr;
+};
+
+class MatchPredicate : public ColumnPredicate {
+public:
+    static void init() {}
+
+public:
+    MatchPredicate(uint32_t column_id, const std::string& value, MatchType 
match_type);
+
+    virtual PredicateType type() const override;
+
+    //evaluate predicate on Bitmap
+    virtual Status evaluate(BitmapIndexIterator* iterator, uint32_t num_rows,
+                            roaring::Roaring* roaring) const override {
+        LOG(FATAL) << "Not Implemented MatchPredicate::evaluate";
+    }
+
+    //evaluate predicate on inverted
+    Status evaluate(const Schema& schema, InvertedIndexIterator* iterator,
+                     uint32_t num_rows, roaring::Roaring* bitmap) const 
override;
+
+private:
+    InvertedIndexQueryType _to_inverted_index_query_type(MatchType match_type) 
const;
+    std::string _debug_string() const override {
+        std::string info = "MatchPredicate";
+        return info;
+    }
+
+private:

Review Comment:
   warning: redundant access specifier has the same accessibility as the 
previous access specifier [readability-redundant-access-specifiers]
   
   ```suggestion
   
   ```
   **be/src/exprs/match_predicate.h:70:** previously declared here
   ```cpp
   private:
   ^
   ```
   



##########
be/src/exprs/match_predicate.h:
##########
@@ -0,0 +1,85 @@
+// 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.
+
+#ifndef DORIS_BE_SRC_QUERY_EXPRS_MATCH_PREDICATE_H
+#define DORIS_BE_SRC_QUERY_EXPRS_MATCH_PREDICATE_H
+
+#include <memory>
+#include <string>
+
+#include "exprs/predicate.h"
+#include "gen_cpp/Exprs_types.h"
+#include "olap/column_predicate.h"
+#include "runtime/string_search.hpp"
+
+namespace doris {
+
+enum class MatchType;
+
+class MatchPredicateExpr : public Predicate {
+public:
+    MatchPredicateExpr(const TExprNode& node) : Predicate(node) {}
+    virtual ~MatchPredicateExpr() {}
+    Expr* clone(ObjectPool* pool) const override {
+        return pool->add(new MatchPredicateExpr(*this));
+    }
+
+    static bool is_valid(std::string fn_name) {
+        return fn_name == "match_any" || fn_name == "match_all" ||
+               fn_name == "match_phrase" || fn_name == "match_element_eq" ||
+               fn_name == "match_element_lt" || fn_name == "match_element_gt" 
||
+               fn_name == "match_element_le" || fn_name == "match_element_ge";
+    }
+
+protected:
+    friend class Expr;
+};
+
+class MatchPredicate : public ColumnPredicate {
+public:
+    static void init() {}
+
+public:
+    MatchPredicate(uint32_t column_id, const std::string& value, MatchType 
match_type);
+
+    virtual PredicateType type() const override;
+
+    //evaluate predicate on Bitmap
+    virtual Status evaluate(BitmapIndexIterator* iterator, uint32_t num_rows,

Review Comment:
   warning: 'virtual' is redundant since the function is already declared 
'override' [modernize-use-override]
   
   ```suggestion
       Status evaluate(BitmapIndexIterator* iterator, uint32_t num_rows,
   ```
   



##########
be/src/olap/rowset/segment_v2/segment_iterator.h:
##########
@@ -166,6 +170,16 @@ class SegmentIterator : public RowwiseIterator {
 
     void _update_max_row(const vectorized::Block* block);
 
+    std::string _gen_predicate_result_sign(ColumnPredicate* predicate);
+
+    void _build_index_return_column(uint16_t* sel_rowid_idx, uint16_t 
select_size,
+                                    vectorized::Block* block,
+                                    const std::string& 
index_result_column_sign,
+                                    const roaring::Roaring& index_result);
+
+    void _output_index_return_column(uint16_t* sel_rowid_idx, uint16_t 
select_size, vectorized::Block* block);
+
+private:

Review Comment:
   warning: redundant access specifier has the same accessibility as the 
previous access specifier [readability-redundant-access-specifiers]
   
   ```suggestion
   
   ```
   **be/src/olap/rowset/segment_v2/segment_iterator.h:82:** previously declared 
here
   ```cpp
   private:
   ^
   ```
   



##########
be/src/olap/rowset/segment_v2/inverted_index_reader.h:
##########
@@ -0,0 +1,103 @@
+// 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.
+
+#pragma once
+
+#include <roaring/roaring.hh>
+
+#include "common/status.h"
+#include "env/env.h"
+#include "gen_cpp/segment_v2.pb.h"
+#include "gutil/macros.h"
+#include "io/fs/file_system.h"
+#include "olap/olap_common.h"
+#include "olap/inverted_index_parser.h"
+#include "olap/rowset/segment_v2/common.h"
+#include "olap/tablet_schema.h"
+
+namespace doris {
+
+namespace segment_v2 {
+
+class InvertedIndexIterator;
+
+enum class InvertedIndexReaderType {
+    UNKNOWN = -1,
+};
+
+enum class InvertedIndexQueryType {
+    UNKNOWN_QUERY = -1,
+    EQUAL_QUERY = 0,
+    LESS_THAN_QUERY = 1,
+    LESS_EQUAL_QUERY = 2,
+    GREATER_THAN_QUERY = 3,
+    GREATER_EQUAL_QUERY = 4,
+    MATCH_ANY_QUERY = 5,
+    MATCH_ALL_QUERY = 6,
+    MATCH_PHRASE_QUERY = 7,
+};
+
+class InvertedIndexReader {
+public:
+    explicit InvertedIndexReader(io::FileSystem* fs, const std::string& path,
+                                 const uint32_t index_id)
+            : _fs(fs), _path(path), _index_id(index_id) {};
+    virtual ~InvertedIndexReader() = default;
+
+    // create a new column iterator. Client should delete returned iterator
+    virtual Status new_iterator(const TabletIndex* index_meta,
+                                InvertedIndexIterator** iterator) = 0;
+    virtual Status query(const std::string& column_name, const void* 
query_value,
+                         InvertedIndexQueryType query_type, 
InvertedIndexParserType analyser_type,
+                         roaring::Roaring* bit_map) = 0;
+    virtual Status try_query(const std::string& column_name, const void* 
query_value,
+                         InvertedIndexQueryType query_type, 
InvertedIndexParserType analyser_type,
+                         uint32_t* count) = 0;
+
+    virtual InvertedIndexReaderType type() = 0;
+    bool indexExists(io::Path& index_file_path);
+    uint32_t get_index_id() { return _index_id; }

Review Comment:
   warning: method 'get_index_id' can be made const 
[readability-make-member-function-const]
   
   ```suggestion
       uint32_t get_index_id() const { return _index_id; }
   ```
   



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