kishoreg commented on a change in pull request #4365: Adding support for 
udf/expression in filter predicates
URL: https://github.com/apache/incubator-pinot/pull/4365#discussion_r298646311
 
 

 ##########
 File path: 
pinot-core/src/main/java/org/apache/pinot/core/operator/filter/ExpressionFilterOperator.java
 ##########
 @@ -0,0 +1,381 @@
+/**
+ * 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.pinot.core.operator.filter;
+
+import com.google.common.collect.Lists;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import org.apache.pinot.common.request.transform.TransformExpressionTree;
+import org.apache.pinot.core.common.BlockDocIdIterator;
+import org.apache.pinot.core.common.BlockDocIdSet;
+import org.apache.pinot.core.common.BlockValSet;
+import org.apache.pinot.core.common.Constants;
+import org.apache.pinot.core.common.DataBlockCache;
+import org.apache.pinot.core.common.DataFetcher;
+import org.apache.pinot.core.common.DataSource;
+import org.apache.pinot.core.common.Predicate;
+import org.apache.pinot.core.indexsegment.IndexSegment;
+import org.apache.pinot.core.operator.DocIdSetOperator;
+import org.apache.pinot.core.operator.ProjectionOperator;
+import org.apache.pinot.core.operator.blocks.DocIdSetBlock;
+import org.apache.pinot.core.operator.blocks.FilterBlock;
+import org.apache.pinot.core.operator.blocks.ProjectionBlock;
+import org.apache.pinot.core.operator.blocks.TransformBlock;
+import 
org.apache.pinot.core.operator.dociditerators.RangelessBitmapDocIdIterator;
+import org.apache.pinot.core.operator.dociditerators.ScanBasedDocIdIterator;
+import org.apache.pinot.core.operator.docidsets.BitmapDocIdSet;
+import org.apache.pinot.core.operator.docidsets.FilterBlockDocIdSet;
+import org.apache.pinot.core.operator.filter.predicate.PredicateEvaluator;
+import 
org.apache.pinot.core.operator.filter.predicate.PredicateEvaluatorProvider;
+import org.apache.pinot.core.operator.transform.TransformOperator;
+import org.apache.pinot.core.operator.transform.TransformResultMetadata;
+import org.apache.pinot.core.operator.transform.function.TransformFunction;
+import 
org.apache.pinot.core.operator.transform.function.TransformFunctionFactory;
+import org.apache.pinot.core.plan.DocIdSetPlanNode;
+import org.apache.pinot.core.segment.index.readers.Dictionary;
+import org.roaringbitmap.IntIterator;
+import org.roaringbitmap.RoaringBitmap;
+import org.roaringbitmap.buffer.MutableRoaringBitmap;
+
+
+public class ExpressionFilterOperator extends BaseFilterOperator {
+  private static final String OPERATOR_NAME = "ExpressionFilterOperator";
+  private final int _numDocs;
+  private TransformFunction _transformFunction;
+  private final PredicateEvaluator _predicateEvaluator;
+  private final TransformResultMetadata _resultMetadata;
+  private final Map<String, DataSource> _dataSourceMap;
+  private TransformExpressionTree _expression;
+
+  public ExpressionFilterOperator(IndexSegment segment, 
TransformExpressionTree expression, Predicate predicate) {
+    _expression = expression;
+    Set<String> columns = new HashSet<>();
+    expression.getColumns(columns);
+    _dataSourceMap = new HashMap<>();
+    for (String column : columns) {
+      _dataSourceMap.put(column, segment.getDataSource(column));
+    }
+    _transformFunction = TransformFunctionFactory.get(expression, 
_dataSourceMap);
 
 Review comment:
      ```expression.getColumns(columns);``` This method go over the expression 
recursively and collects all the columns.
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to