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


##########
pinot-broker/src/main/java/org/apache/pinot/broker/routing/segmentpruner/SegmentNameSegmentPruner.java:
##########
@@ -0,0 +1,164 @@
+/**
+ * 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.broker.routing.segmentpruner;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.apache.helix.model.ExternalView;
+import org.apache.helix.model.IdealState;
+import org.apache.pinot.common.request.BrokerRequest;
+import org.apache.pinot.common.request.Expression;
+import org.apache.pinot.common.request.Function;
+import org.apache.pinot.common.request.Identifier;
+import org.apache.pinot.spi.utils.CommonConstants;
+import org.apache.pinot.sql.FilterKind;
+
+
+public class SegmentNameSegmentPruner implements SegmentPruner {
+
+  @Override
+  public void init(IdealState idealState, ExternalView externalView, 
Set<String> onlineSegments) {
+  }
+
+  @Override
+  public void onAssignmentChange(IdealState idealState, ExternalView 
externalView, Set<String> onlineSegments) {
+  }
+
+  @Override
+  public void refreshSegment(String segment) {
+  }
+
+  @Override
+  public Set<String> prune(BrokerRequest brokerRequest, Set<String> segments) {
+    Expression filterExpression = 
brokerRequest.getPinotQuery().getFilterExpression();
+    if (filterExpression == null || !isEligibleForPruning(filterExpression)) {

Review Comment:
   We want to avoid iterating over all the segments or make a clone of the set 
because that can be expensive. Instead we can extract the included and excluded 
segment list from the filter, and then only iterate over the list. We only need 
to make a copy of the set when excluded segment list exists.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to