siddharthteotia commented on a change in pull request #7830: URL: https://github.com/apache/pinot/pull/7830#discussion_r764503815
########## File path: pinot-core/src/main/java/org/apache/pinot/core/operator/filter/BlockDrivenAndFilterOperator.java ########## @@ -0,0 +1,126 @@ +/** + * 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.ArrayList; +import java.util.List; +import javax.annotation.Nullable; +import org.apache.pinot.core.common.BlockDocIdSet; +import org.apache.pinot.core.common.Operator; +import org.apache.pinot.core.operator.VisitableOperator; +import org.apache.pinot.core.operator.blocks.FilterBlock; +import org.apache.pinot.core.operator.blocks.TransformBlock; +import org.apache.pinot.core.operator.dociditerators.ArrayBasedDocIdIterator; +import org.apache.pinot.core.operator.docidsets.AndDocIdSet; +import org.apache.pinot.core.operator.docidsets.ArrayBasedDocIdSet; +import org.apache.pinot.core.operator.docidsets.BitmapDocIdSet; +import org.apache.pinot.core.operator.docidsets.FilterBlockDocIdSet; +import org.apache.pinot.segment.spi.Constants; +import org.roaringbitmap.buffer.ImmutableRoaringBitmap; + +/** + * Performs an AND operation on top of a Filter Block DocIDSet + * and a block from the given filter operator. + */ +public class BlockDrivenAndFilterOperator extends BaseFilterOperator + implements VisitableOperator { + private static final String OPERATOR_NAME = "BlockDrivenAndFilterOperator"; + + private final BaseFilterOperator _filterOperator; + private FilterBlockDocIdSet _filterBlockDocIdSet; + private final int _numDocs; + + public BlockDrivenAndFilterOperator(BaseFilterOperator filterOperator, int numDocs) { + _filterOperator = filterOperator; + _numDocs = numDocs; + } + + @Override + public FilterBlock getNextBlock() { + + if (_filterBlockDocIdSet != null) { + List<FilterBlockDocIdSet> filterBlockDocIdSets = new ArrayList<>(2); + + filterBlockDocIdSets.add(_filterBlockDocIdSet); + filterBlockDocIdSets.add(_filterOperator.nextBlock().getBlockDocIdSet()); + + return new FilterBlock(new AndDocIdSet(filterBlockDocIdSets)); + } + + return _filterOperator.nextBlock(); + } + + @Override + public String getOperatorName() { + return OPERATOR_NAME; + } + + @Override + public List<Operator> getChildOperators() { + return null; + } + + @Nullable + @Override + public String toExplainString() { + return null; + } + + @Override + public <T> void accept(T incomingObject) { Review comment: I am going to pull the code locally to understand the flow better. But, is it correct that this is being called to accept the outer transform block for the main WHERE clause ? Is there a strong need to add these visit/accept semantics ? The flow from execution perspective is not super clear at this point on how to use these methods. When we know that BlockDrivenAndFilterOperator is going to be created (at least as of now) for FILTER aggregation queries, then we know the execution plan ahead of time. So, I don't think we need any custom transformation to happen on the nodes of a tree (which is where Visitor pattern might be more helpful afaik). The use does not look very intuitive to me so far. -- 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...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org