You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by "Jackie-Jiang (via GitHub)" <gi...@apache.org> on 2023/07/21 08:54:44 UTC

[GitHub] [pinot] Jackie-Jiang commented on a diff in pull request #11078: Filtering NULL support.

Jackie-Jiang commented on code in PR #11078:
URL: https://github.com/apache/pinot/pull/11078#discussion_r1270418833


##########
pinot-core/src/main/java/org/apache/pinot/core/operator/filter/NullHandlingSupportedFilterOperator.java:
##########
@@ -0,0 +1,68 @@
+/**
+ * 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 java.util.Arrays;
+import org.apache.pinot.core.common.BlockDocIdSet;
+import org.apache.pinot.core.operator.blocks.FilterBlock;
+import org.apache.pinot.core.operator.docidsets.AndDocIdSet;
+import org.apache.pinot.core.operator.docidsets.BitmapDocIdSet;
+import org.apache.pinot.core.operator.docidsets.MatchAllDocIdSet;
+import org.apache.pinot.core.query.request.context.QueryContext;
+import org.apache.pinot.segment.spi.datasource.DataSource;
+import org.apache.pinot.segment.spi.index.reader.NullValueVectorReader;
+
+
+public abstract class NullHandlingSupportedFilterOperator extends BaseFilterOperator {
+  protected final QueryContext _queryContext;
+  protected final DataSource _dataSource;
+  protected final int _numDocs;
+
+  protected NullHandlingSupportedFilterOperator(QueryContext queryContext, DataSource dataSource, int numDocs) {
+    _queryContext = queryContext;
+    _dataSource = dataSource;
+    _numDocs = numDocs;
+  }
+
+  @Override
+  protected FilterBlock getNextBlock() {
+    if (_queryContext.isNullHandlingEnabled()) {
+      return new FilterBlock(excludeNulls(getNextBlockWithoutNullHandling()));
+    } else {
+      return new FilterBlock(getNextBlockWithoutNullHandling());
+    }
+  }
+
+  protected abstract BlockDocIdSet getNextBlockWithoutNullHandling();
+
+  private BlockDocIdSet excludeNulls(BlockDocIdSet blockDocIdSet) {
+    return new AndDocIdSet(

Review Comment:
   Do not create `AndDocIdSet` when there is no null value



##########
pinot-core/src/main/java/org/apache/pinot/core/operator/filter/NullHandlingSupportedFilterOperator.java:
##########
@@ -0,0 +1,68 @@
+/**
+ * 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 java.util.Arrays;
+import org.apache.pinot.core.common.BlockDocIdSet;
+import org.apache.pinot.core.operator.blocks.FilterBlock;
+import org.apache.pinot.core.operator.docidsets.AndDocIdSet;
+import org.apache.pinot.core.operator.docidsets.BitmapDocIdSet;
+import org.apache.pinot.core.operator.docidsets.MatchAllDocIdSet;
+import org.apache.pinot.core.query.request.context.QueryContext;
+import org.apache.pinot.segment.spi.datasource.DataSource;
+import org.apache.pinot.segment.spi.index.reader.NullValueVectorReader;
+
+
+public abstract class NullHandlingSupportedFilterOperator extends BaseFilterOperator {

Review Comment:
   Do we need this extra layer of abstract class? In the end state all filter should have null handling and we can just put the new methods into `BaseFilterOperator`



##########
pinot-core/src/main/java/org/apache/pinot/core/operator/filter/NullHandlingSupportedFilterOperator.java:
##########
@@ -0,0 +1,68 @@
+/**
+ * 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 java.util.Arrays;
+import org.apache.pinot.core.common.BlockDocIdSet;
+import org.apache.pinot.core.operator.blocks.FilterBlock;
+import org.apache.pinot.core.operator.docidsets.AndDocIdSet;
+import org.apache.pinot.core.operator.docidsets.BitmapDocIdSet;
+import org.apache.pinot.core.operator.docidsets.MatchAllDocIdSet;
+import org.apache.pinot.core.query.request.context.QueryContext;
+import org.apache.pinot.segment.spi.datasource.DataSource;
+import org.apache.pinot.segment.spi.index.reader.NullValueVectorReader;
+
+
+public abstract class NullHandlingSupportedFilterOperator extends BaseFilterOperator {
+  protected final QueryContext _queryContext;
+  protected final DataSource _dataSource;
+  protected final int _numDocs;
+
+  protected NullHandlingSupportedFilterOperator(QueryContext queryContext, DataSource dataSource, int numDocs) {
+    _queryContext = queryContext;
+    _dataSource = dataSource;
+    _numDocs = numDocs;
+  }
+
+  @Override
+  protected FilterBlock getNextBlock() {
+    if (_queryContext.isNullHandlingEnabled()) {
+      return new FilterBlock(excludeNulls(getNextBlockWithoutNullHandling()));
+    } else {
+      return new FilterBlock(getNextBlockWithoutNullHandling());
+    }
+  }
+
+  protected abstract BlockDocIdSet getNextBlockWithoutNullHandling();
+
+  private BlockDocIdSet excludeNulls(BlockDocIdSet blockDocIdSet) {
+    return new AndDocIdSet(
+        Arrays.asList(blockDocIdSet, fromNonNullBitmap()),
+        _queryContext.getQueryOptions());

Review Comment:
   (format) Format seems incorrect



##########
pinot-core/src/main/java/org/apache/pinot/core/operator/docidsets/BitmapDocIdSet.java:
##########
@@ -27,6 +27,13 @@ public class BitmapDocIdSet implements BlockDocIdSet {
   private final BitmapDocIdIterator _iterator;
 
   public BitmapDocIdSet(ImmutableRoaringBitmap docIds, int numDocs) {
+    this(docIds, numDocs, false);
+  }
+
+  public BitmapDocIdSet(ImmutableRoaringBitmap docIds, int numDocs, boolean exclusive) {

Review Comment:
   I'd suggest flipping the bitmap on the caller side before creating a `BitmapDocIdSet` which IMO is more clear



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

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