You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2020/05/29 08:05:51 UTC

[GitHub] [incubator-pinot] siddharthteotia commented on a change in pull request #5444: Enhance and simplify the filtering

siddharthteotia commented on a change in pull request #5444:
URL: https://github.com/apache/incubator-pinot/pull/5444#discussion_r432321846



##########
File path: pinot-core/src/main/java/org/apache/pinot/core/operator/filter/SortedIndexBasedFilterOperator.java
##########
@@ -0,0 +1,145 @@
+/**
+ * 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.base.Preconditions;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import org.apache.pinot.common.utils.Pairs.IntPair;
+import org.apache.pinot.core.common.DataSource;
+import org.apache.pinot.core.io.reader.impl.v1.SortedIndexReader;
+import org.apache.pinot.core.operator.blocks.FilterBlock;
+import org.apache.pinot.core.operator.docidsets.SortedDocIdSet;
+import org.apache.pinot.core.operator.filter.predicate.PredicateEvaluator;
+import org.apache.pinot.core.operator.filter.predicate.RangePredicateEvaluatorFactory.OfflineDictionaryBasedRangePredicateEvaluator;
+
+
+@SuppressWarnings("rawtypes")
+public class SortedIndexBasedFilterOperator extends BaseFilterOperator {
+  private static final String OPERATOR_NAME = "SortedIndexBasedFilterOperator";
+
+  private final PredicateEvaluator _predicateEvaluator;
+  private final SortedIndexReader _sortedIndexReader;
+  private final int _numDocs;
+
+  SortedIndexBasedFilterOperator(PredicateEvaluator predicateEvaluator, DataSource dataSource, int numDocs) {
+    _predicateEvaluator = predicateEvaluator;
+    _sortedIndexReader = (SortedIndexReader) dataSource.getInvertedIndex();
+    _numDocs = numDocs;
+  }
+
+  @Override
+  protected FilterBlock getNextBlock() {
+    // At this point, we need to create a list of matching docId ranges. There are two kinds of operators:
+    //
+    // - "Additive" operators, such as EQ, IN and RANGE build up a list of ranges and merge overlapping/adjacent ones,
+    //   clipping the ranges to [startDocId; endDocId]
+    //
+    // - "Subtractive" operators, such as NEQ and NOT IN build up a list of ranges that do not match and build a list of
+    //   matching intervals by subtracting a list of non-matching intervals from the given range of
+    //   [startDocId; endDocId]
+    //
+    // For now, we don't look at the cardinality of the column's dictionary, although we should do that if someone

Review comment:
       (nit): should just be cardinality of the column (since size of dictionary is equal to cardinality)




----------------------------------------------------------------
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:
users@infra.apache.org



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