sohardforaname commented on code in PR #12182:
URL: https://github.com/apache/doris/pull/12182#discussion_r959670173


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/RuntimeFilterGenerator.java:
##########
@@ -0,0 +1,188 @@
+// 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.doris.nereids.processor.post;
+
+import org.apache.doris.analysis.SlotRef;
+import org.apache.doris.analysis.TupleId;
+import org.apache.doris.common.IdGenerator;
+import org.apache.doris.nereids.CascadesContext;
+import org.apache.doris.nereids.glue.translator.PlanTranslatorContext;
+import org.apache.doris.nereids.trees.expressions.EqualTo;
+import org.apache.doris.nereids.trees.expressions.ExprId;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.SlotReference;
+import org.apache.doris.nereids.trees.plans.JoinType;
+import org.apache.doris.nereids.trees.plans.Plan;
+import org.apache.doris.nereids.trees.plans.physical.PhysicalHashJoin;
+import org.apache.doris.nereids.trees.plans.physical.PhysicalOlapScan;
+import org.apache.doris.nereids.trees.plans.physical.PhysicalPlan;
+import org.apache.doris.nereids.trees.plans.physical.RuntimeFilter;
+import org.apache.doris.planner.HashJoinNode;
+import org.apache.doris.planner.HashJoinNode.DistributionMode;
+import org.apache.doris.planner.OlapScanNode;
+import org.apache.doris.planner.RuntimeFilterGenerator.FilterSizeLimits;
+import org.apache.doris.planner.RuntimeFilterId;
+import org.apache.doris.qe.SessionVariable;
+import org.apache.doris.thrift.TRuntimeFilterType;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.stream.Collectors;
+
+/**
+ * generate runtime filter
+ */
+public class RuntimeFilterGenerator extends PlanPostprocessor {
+
+    private static final IdGenerator<RuntimeFilterId> GENERATOR = 
RuntimeFilterId.createGenerator();
+
+    private final Map<ExprId, List<RuntimeFilter>> filtersByExprId = 
Maps.newHashMap();
+
+    private final Map<ExprId, List<RuntimeFilter.RuntimeFilterTarget>> 
filterTargetByTid = Maps.newHashMap();
+
+    private final List<org.apache.doris.planner.RuntimeFilter> origFilters = 
Lists.newArrayList();
+
+    private final SessionVariable sessionVariable;
+
+    private final FilterSizeLimits limits;
+
+    public RuntimeFilterGenerator(SessionVariable sessionVariable) {
+        this.sessionVariable = sessionVariable;
+        this.limits = new FilterSizeLimits(sessionVariable);
+    }
+
+    @Override
+    public PhysicalPlan visitPhysicalHashJoin(PhysicalHashJoin<Plan, Plan> 
join, CascadesContext ctx) {
+        Plan left = join.left();
+        Plan right = join.right();
+        if (join.getJoinType() == JoinType.INNER_JOIN) {
+            List<EqualTo> eqPreds = join.getHashJoinConjuncts().stream()
+                    .map(EqualTo.class::cast).collect(Collectors.toList());
+            List<TRuntimeFilterType> legalTypes = 
Arrays.stream(TRuntimeFilterType.values()).filter(type ->
+                    (type.getValue() & sessionVariable.getRuntimeFilterType()) 
> 0).collect(Collectors.toList());
+            List<RuntimeFilter> runtimeFilters = Lists.newArrayList();
+            AtomicInteger cnt = new AtomicInteger();
+            final PhysicalHashJoin<Plan, Plan> joinReplica = join;

Review Comment:
   for the exprOrder for OriginRuntimeFilter



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/RuntimeFilterGenerator.java:
##########
@@ -0,0 +1,188 @@
+// 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.doris.nereids.processor.post;
+
+import org.apache.doris.analysis.SlotRef;
+import org.apache.doris.analysis.TupleId;
+import org.apache.doris.common.IdGenerator;
+import org.apache.doris.nereids.CascadesContext;
+import org.apache.doris.nereids.glue.translator.PlanTranslatorContext;
+import org.apache.doris.nereids.trees.expressions.EqualTo;
+import org.apache.doris.nereids.trees.expressions.ExprId;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.SlotReference;
+import org.apache.doris.nereids.trees.plans.JoinType;
+import org.apache.doris.nereids.trees.plans.Plan;
+import org.apache.doris.nereids.trees.plans.physical.PhysicalHashJoin;
+import org.apache.doris.nereids.trees.plans.physical.PhysicalOlapScan;
+import org.apache.doris.nereids.trees.plans.physical.PhysicalPlan;
+import org.apache.doris.nereids.trees.plans.physical.RuntimeFilter;
+import org.apache.doris.planner.HashJoinNode;
+import org.apache.doris.planner.HashJoinNode.DistributionMode;
+import org.apache.doris.planner.OlapScanNode;
+import org.apache.doris.planner.RuntimeFilterGenerator.FilterSizeLimits;
+import org.apache.doris.planner.RuntimeFilterId;
+import org.apache.doris.qe.SessionVariable;
+import org.apache.doris.thrift.TRuntimeFilterType;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.stream.Collectors;
+
+/**
+ * generate runtime filter
+ */
+public class RuntimeFilterGenerator extends PlanPostprocessor {
+
+    private static final IdGenerator<RuntimeFilterId> GENERATOR = 
RuntimeFilterId.createGenerator();
+
+    private final Map<ExprId, List<RuntimeFilter>> filtersByExprId = 
Maps.newHashMap();
+
+    private final Map<ExprId, List<RuntimeFilter.RuntimeFilterTarget>> 
filterTargetByTid = Maps.newHashMap();
+
+    private final List<org.apache.doris.planner.RuntimeFilter> origFilters = 
Lists.newArrayList();
+
+    private final SessionVariable sessionVariable;
+
+    private final FilterSizeLimits limits;
+
+    public RuntimeFilterGenerator(SessionVariable sessionVariable) {
+        this.sessionVariable = sessionVariable;
+        this.limits = new FilterSizeLimits(sessionVariable);
+    }
+
+    @Override
+    public PhysicalPlan visitPhysicalHashJoin(PhysicalHashJoin<Plan, Plan> 
join, CascadesContext ctx) {
+        Plan left = join.left();
+        Plan right = join.right();
+        if (join.getJoinType() == JoinType.INNER_JOIN) {
+            List<EqualTo> eqPreds = join.getHashJoinConjuncts().stream()
+                    .map(EqualTo.class::cast).collect(Collectors.toList());
+            List<TRuntimeFilterType> legalTypes = 
Arrays.stream(TRuntimeFilterType.values()).filter(type ->
+                    (type.getValue() & sessionVariable.getRuntimeFilterType()) 
> 0).collect(Collectors.toList());
+            List<RuntimeFilter> runtimeFilters = Lists.newArrayList();
+            AtomicInteger cnt = new AtomicInteger();
+            final PhysicalHashJoin<Plan, Plan> joinReplica = join;

Review Comment:
   > why create this variable
   
   for the exprOrder for OriginRuntimeFilter



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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to