You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2021/12/02 03:26:35 UTC

[GitHub] [druid] yuanlihan commented on a change in pull request #11987: Add two new array functions to Druid

yuanlihan commented on a change in pull request #11987:
URL: https://github.com/apache/druid/pull/11987#discussion_r760735640



##########
File path: core/src/main/java/org/apache/druid/math/expr/Function.java
##########
@@ -3422,6 +3422,100 @@ ExprEval doApply(ExprEval lhsExpr, ExprEval rhsExpr)
     }
   }
 
+  class ArrayContainsContiguousSubarrayFunction extends ArraysFunction
+  {
+    @Override
+    public String name()
+    {
+      return "array_contains_contiguous_subarray";
+    }
+
+    @Override
+    public boolean hasArrayOutput()
+    {
+      return true;
+    }
+
+    @Nullable
+    @Override
+    public ExpressionType getOutputType(Expr.InputBindingInspector inputTypes, List<Expr> args)
+    {
+      return ExpressionType.LONG;
+    }
+
+    @Override
+    ExprEval doApply(ExprEval lhsExpr, ExprEval rhsExpr)

Review comment:
       Hi @LakshSingla, thanks for the comment.
   > The implementation seems to have complexity of O(length1 * (length1-length2)), which seems suboptimal if we used something like KMP. Maybe something like Collections#indexOfSublist can be better, but it seems that it might be using the same algorithm underneath. In any case, I think it could be optimized further, and we might not wanna go with the naive implementation if the operands we expect have can have a decent length. String searching
   
   I got your point that you're concerned about the performance of the array function here. Actually, during SQL function translation, it'll try to void necessary array comparing by leveraging a serial of dimension filters which can use Druid's bitmap index to speed up filtering. 
   
   




-- 
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-unsubscribe@druid.apache.org

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



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