Jackie-Jiang commented on a change in pull request #8411: URL: https://github.com/apache/pinot/pull/8411#discussion_r838008174
########## File path: pinot-core/src/main/java/org/apache/pinot/core/operator/filter/BitmapCollection.java ########## @@ -0,0 +1,103 @@ +/** + * 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 org.roaringbitmap.buffer.BufferFastAggregation; +import org.roaringbitmap.buffer.ImmutableRoaringBitmap; +import org.roaringbitmap.buffer.MutableRoaringBitmap; + + +public class BitmapCollection { Review comment: Add some javadoc for this class and the methods ########## File path: pinot-core/src/main/java/org/apache/pinot/core/plan/AggregationPlanNode.java ########## @@ -178,6 +179,11 @@ private TransformOperator buildTransformOperatorForFilteredAggregates(BaseFilter BaseFilterOperator filterOperator = filterPlanNode.run(); // Use metadata/dictionary to solve the query if possible Review comment: This comment does not match the logic ########## File path: pinot-core/src/main/java/org/apache/pinot/core/operator/query/FastFilteredCountOperator.java ########## @@ -0,0 +1,81 @@ +/** + * 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.query; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import org.apache.pinot.core.common.Operator; +import org.apache.pinot.core.operator.BaseOperator; +import org.apache.pinot.core.operator.ExecutionStatistics; +import org.apache.pinot.core.operator.blocks.IntermediateResultsBlock; +import org.apache.pinot.core.operator.filter.BaseFilterOperator; +import org.apache.pinot.core.query.aggregation.function.AggregationFunction; +import org.apache.pinot.segment.spi.SegmentMetadata; + + +@SuppressWarnings("rawtypes") +public class FastFilteredCountOperator extends BaseOperator<IntermediateResultsBlock> { + private static final String OPERATOR_NAME = "FastFilteredCount"; Review comment: ```suggestion private static final String OPERATOR_NAME = "FastFilteredCountOperator"; ``` ########## File path: pinot-core/src/main/java/org/apache/pinot/core/plan/AggregationPlanNode.java ########## @@ -253,4 +259,10 @@ private static boolean isFitForNonScanBasedPlan(AggregationFunction[] aggregatio } return true; } + + private static boolean canOptimizeFilteredCount(BaseFilterOperator filterOperator, + AggregationFunction[] aggregationFunctions) { + return filterOperator.canOptimizeCount() && (aggregationFunctions.length == 1 + && aggregationFunctions[0].getType() == COUNT); Review comment: Suggest changing the order of the checks because `canOptimizeCount()` can be more costly ```suggestion return aggregationFunctions.length == 1 && aggregationFunctions[0].getType() == COUNT && filterOperator.canOptimizeCount(); ``` ########## File path: pinot-core/src/main/java/org/apache/pinot/core/operator/query/FastFilteredCountOperator.java ########## @@ -0,0 +1,81 @@ +/** + * 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.query; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import org.apache.pinot.core.common.Operator; +import org.apache.pinot.core.operator.BaseOperator; +import org.apache.pinot.core.operator.ExecutionStatistics; +import org.apache.pinot.core.operator.blocks.IntermediateResultsBlock; +import org.apache.pinot.core.operator.filter.BaseFilterOperator; +import org.apache.pinot.core.query.aggregation.function.AggregationFunction; +import org.apache.pinot.segment.spi.SegmentMetadata; + + +@SuppressWarnings("rawtypes") +public class FastFilteredCountOperator extends BaseOperator<IntermediateResultsBlock> { + private static final String OPERATOR_NAME = "FastFilteredCount"; + private static final String EXPLAIN_NAME = "FAST_FILTERED_COUNT"; + + private final BaseFilterOperator _filterOperator; + private final AggregationFunction[] _aggregationFunctions; + private final SegmentMetadata _segmentMetadata; + + private long _docsCounted; + + public FastFilteredCountOperator(AggregationFunction[] aggregationFunctions, BaseFilterOperator filterOperator, + SegmentMetadata segmentMetadata) { + _filterOperator = filterOperator; + _segmentMetadata = segmentMetadata; + _aggregationFunctions = aggregationFunctions; + } + + @Override + public String getOperatorName() { + return OPERATOR_NAME; + } + + @Override + public String toExplainString() { + return EXPLAIN_NAME; + } + + @SuppressWarnings("rawtypes") + @Override + public List<Operator> getChildOperators() { + return Collections.singletonList(_filterOperator); + } + + @Override + protected IntermediateResultsBlock getNextBlock() { + long count = _filterOperator.getNumMatchingDocs(); + List<Object> aggregates = new ArrayList<>(1); + aggregates.add(count); + _docsCounted += count; + return new IntermediateResultsBlock(_aggregationFunctions, aggregates, false); + } + + @Override + public ExecutionStatistics getExecutionStatistics() { + return new ExecutionStatistics(_docsCounted, 0, 0, Review comment: Add some comment about having this behavior for backward compatible -- 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