morrySnow commented on code in PR #13659: URL: https://github.com/apache/doris/pull/13659#discussion_r1032952933
########## fe/fe-core/src/main/java/org/apache/doris/nereids/NereidsPlanner.java: ########## @@ -96,6 +121,7 @@ public void plan(StatementBase queryStmt, org.apache.doris.thrift.TQueryOptions String memo = cascadesContext.getMemo().toString(); System.out.println(memo); LOG.info(memo); Review Comment: we should remove these old traces, ########## fe/fe-core/src/main/java/org/apache/doris/nereids/NereidsPlanner.java: ########## @@ -71,6 +93,9 @@ public class NereidsPlanner extends Planner { public NereidsPlanner(StatementContext statementContext) { this.statementContext = statementContext; + if (ConnectContext.get().getSessionVariable().isEnableNereidsTrace()) { + EventChannel.getDefaultChannel().start(); + } Review Comment: each statement has a brand new NereidsPlanner. So why start channel here? we need to start channel for each statement? ########## fe/fe-core/src/main/java/org/apache/doris/nereids/NereidsPlanner.java: ########## @@ -59,6 +69,18 @@ public class NereidsPlanner extends Planner { public static final Logger LOG = LogManager.getLogger(NereidsPlanner.class); + static { + EventChannel.getDefaultChannel() + .addEnhancers(ImmutableList.of(new AddCounterEventEnhancer())) + .addConsumers(ImmutableList.of( + new LogConsumer(CounterEvent.class, LOG), + new LogConsumer(TransformEvent.class, LOG), + new LogConsumer(EnforcerEvent.class, LOG), + new LogConsumer(GroupMergeEvent.class, LOG), + new LogConsumer(CostStateUpdateEvent.class, LOG), + new LogConsumer(StatsStateEvent.class, LOG))); Review Comment: init channel in this class is weired. we need to init it in a event related class ########## fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java: ########## @@ -634,6 +641,40 @@ public void initFuzzyModeVariables() { this.enableShareHashTableForBroadcastJoin = random.nextBoolean(); } + /** + * syntax: + * all -> use all event + * all except event_1, event_2, ..., event_n -> use all events excluding the event_1~n + * event_1, event_2, ..., event_n -> use event_1~n + */ + @VariableMgr.VarAttr(name = NEREIDS_EVENT_MODE) + public String nereidsEventMode = "all"; Review Comment: nereidsTraceEventMode ########## fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java: ########## @@ -634,6 +641,40 @@ public void initFuzzyModeVariables() { this.enableShareHashTableForBroadcastJoin = random.nextBoolean(); } + /** + * syntax: + * all -> use all event + * all except event_1, event_2, ..., event_n -> use all events excluding the event_1~n + * event_1, event_2, ..., event_n -> use event_1~n + */ + @VariableMgr.VarAttr(name = NEREIDS_EVENT_MODE) + public String nereidsEventMode = "all"; + + private Set<Class<? extends Event>> parsedNereidsEventMode = EventSwitchParser.parse(Lists.newArrayList("all")); + + public void setEnableNereidsTrace(boolean enableNereidsTrace) { + this.enableNereidsTrace = enableNereidsTrace; + } + + public String getNereidsEventMode() { + return nereidsEventMode; + } + + public void setNereidsEventMode(String nereidsEventMode) throws UnsupportedOperationException { Review Comment: add check to this function is useless. Doris use reflection to set session vairable value. do not call setXX at all ########## fe/fe-core/src/main/java/org/apache/doris/nereids/memo/Memo.java: ########## @@ -82,10 +96,16 @@ public Map<GroupExpression, GroupExpression> getGroupExpressions() { * is the corresponding group expression of the plan */ public CopyInResult copyIn(Plan plan, @Nullable Group target, boolean rewrite) { - if (rewrite) { - return doRewrite(plan, target); - } else { - return doCopyIn(plan, target); + CopyInResult result = rewrite ? doRewrite(plan, target) : doCopyIn(plan, target); Review Comment: change back to if else statement for easy read -- 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