Tanya-W commented on code in PR #14211:
URL: https://github.com/apache/doris/pull/14211#discussion_r1058149955


##########
fe/fe-core/src/main/java/org/apache/doris/analysis/MatchPredicate.java:
##########
@@ -0,0 +1,241 @@
+// 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.
+
+package org.apache.doris.analysis;
+
+import org.apache.doris.catalog.ArrayType;
+import org.apache.doris.catalog.Function;
+import org.apache.doris.catalog.FunctionSet;
+import org.apache.doris.catalog.ScalarFunction;
+import org.apache.doris.catalog.Type;
+import org.apache.doris.common.AnalysisException;
+import org.apache.doris.thrift.TExprNode;
+import org.apache.doris.thrift.TExprNodeType;
+import org.apache.doris.thrift.TExprOpcode;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.util.Objects;
+
+/**
+ * filed MATCH query_str
+ */
+public class MatchPredicate extends Predicate {
+    private static final Logger LOG = 
LogManager.getLogger(MatchPredicate.class);
+
+    public enum Operator {
+        MATCH_ANY("MATCH_ANY", "match_any", TExprOpcode.MATCH_ANY),
+        MATCH_ALL("MATCH_ALL", "match_all", TExprOpcode.MATCH_ALL),
+        MATCH_PHRASE("MATCH_PHRASE", "match_phrase", TExprOpcode.MATCH_PHRASE),
+        MATCH_ELEMENT_EQ("MATCH_ELEMENT_EQ", "match_element_eq", 
TExprOpcode.MATCH_ELEMENT_EQ),
+        MATCH_ELEMENT_LT("MATCH_ELEMENT_LT", "match_element_lt", 
TExprOpcode.MATCH_ELEMENT_LT),
+        MATCH_ELEMENT_GT("MATCH_ELEMENT_GT", "match_element_gt", 
TExprOpcode.MATCH_ELEMENT_GT),
+        MATCH_ELEMENT_LE("MATCH_ELEMENT_LE", "match_element_le", 
TExprOpcode.MATCH_ELEMENT_LE),
+        MATCH_ELEMENT_GE("MATCH_ELEMENT_GE", "match_element_ge", 
TExprOpcode.MATCH_ELEMENT_GE);
+
+
+        private final String description;
+        private final String name;
+        private final TExprOpcode opcode;
+
+        Operator(String description,
+                 String name,
+                 TExprOpcode opcode) {
+            this.description = description;
+            this.name = name;
+            this.opcode = opcode;
+        }
+
+        @Override
+        public String toString() {
+            return description;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public TExprOpcode getOpcode() {
+            return opcode;
+        }
+    }
+
+    public static void initBuiltins(FunctionSet functionSet) {
+        String symbolNotUsed = "symbol_not_used";
+
+        for (Type t : Type.getNumericDateTimeTypes()) {
+            
functionSet.addBuiltinBothScalaAndVectorized(ScalarFunction.createBuiltinOperator(
+                    Operator.MATCH_ELEMENT_EQ.getName(),
+                    symbolNotUsed,
+                    Lists.<Type>newArrayList(new ArrayType(t), t),
+                    Type.BOOLEAN));
+            
functionSet.addBuiltinBothScalaAndVectorized(ScalarFunction.createBuiltinOperator(
+                    Operator.MATCH_ELEMENT_LT.getName(),
+                    symbolNotUsed,
+                    Lists.<Type>newArrayList(new ArrayType(t), t),
+                    Type.BOOLEAN));
+            
functionSet.addBuiltinBothScalaAndVectorized(ScalarFunction.createBuiltinOperator(
+                    Operator.MATCH_ELEMENT_GT.getName(),
+                    symbolNotUsed,
+                    Lists.<Type>newArrayList(new ArrayType(t), t),
+                    Type.BOOLEAN));
+            
functionSet.addBuiltinBothScalaAndVectorized(ScalarFunction.createBuiltinOperator(
+                    Operator.MATCH_ELEMENT_LE.getName(),
+                    symbolNotUsed,
+                    Lists.<Type>newArrayList(new ArrayType(t), t),
+                    Type.BOOLEAN));
+            
functionSet.addBuiltinBothScalaAndVectorized(ScalarFunction.createBuiltinOperator(
+                    Operator.MATCH_ELEMENT_GE.getName(),
+                    symbolNotUsed,
+                    Lists.<Type>newArrayList(new ArrayType(t), t),
+                    Type.BOOLEAN));
+        }
+        
functionSet.addBuiltinBothScalaAndVectorized(ScalarFunction.createBuiltinOperator(
+                Operator.MATCH_ANY.getName(),
+                symbolNotUsed,
+                Lists.<Type>newArrayList(Type.VARCHAR, Type.VARCHAR),
+                Type.BOOLEAN));
+        
functionSet.addBuiltinBothScalaAndVectorized(ScalarFunction.createBuiltinOperator(
+                Operator.MATCH_ANY.getName(),
+                symbolNotUsed,
+                Lists.<Type>newArrayList(new ArrayType(Type.VARCHAR), 
Type.VARCHAR),
+                Type.BOOLEAN));
+
+        
functionSet.addBuiltinBothScalaAndVectorized(ScalarFunction.createBuiltinOperator(
+                Operator.MATCH_ALL.getName(),
+                symbolNotUsed,
+                Lists.<Type>newArrayList(Type.VARCHAR, Type.VARCHAR),
+                Type.BOOLEAN));
+        
functionSet.addBuiltinBothScalaAndVectorized(ScalarFunction.createBuiltinOperator(
+                Operator.MATCH_ALL.getName(),
+                symbolNotUsed,
+                Lists.<Type>newArrayList(new ArrayType(Type.VARCHAR), 
Type.VARCHAR),
+                Type.BOOLEAN));
+
+        
functionSet.addBuiltinBothScalaAndVectorized(ScalarFunction.createBuiltinOperator(
+                Operator.MATCH_PHRASE.getName(),
+                symbolNotUsed,
+                Lists.<Type>newArrayList(Type.VARCHAR, Type.VARCHAR),
+                Type.BOOLEAN));
+        
functionSet.addBuiltinBothScalaAndVectorized(ScalarFunction.createBuiltinOperator(
+                Operator.MATCH_PHRASE.getName(),
+                symbolNotUsed,
+                Lists.<Type>newArrayList(new ArrayType(Type.VARCHAR), 
Type.VARCHAR),
+                Type.BOOLEAN));
+    }
+
+    private final Operator op;
+
+    public MatchPredicate(Operator op, Expr e1, Expr e2) {
+        super();
+        this.op = op;
+        Preconditions.checkNotNull(e1);
+        children.add(e1);
+        Preconditions.checkNotNull(e2);
+        children.add(e2);
+        // TODO: Calculate selectivity
+        selectivity = Expr.DEFAULT_SELECTIVITY;
+    }
+
+    public Boolean isMatchElement(Operator op) {
+        return Objects.equals(op.getName(), "match_element_eq") || 
Objects.equals(op.getName(), "match_element_lt")

Review Comment:
   updated



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to