shikhae6 commented on PR #4968:
URL: https://github.com/apache/calcite/pull/4968#issuecomment-4862425971
@julianhyde
I have proposed an alternate solution in Jira , here are the details:
I was treating the listener as part of the program definition, but it is
really runtime/session state.
I’m thinking of changing the approach so the listener is not passed to
Programs.of at all. Instead, callers would continue to attach the listener to
the runtime planner for the current planning session:
planner.addListener(listener);
Program program = Programs.of(hepProgram, noDag, metadataProvider);
program.run(planner, rel, traits, materializations, lattices);
Then, inside the existing Programs.of(HepProgram, boolean,
RelMetadataProvider) implementation, when it creates the internal HepPlanner,
it would propagate the listener from the runtime planner passed to Program.run.
if (planner instanceof AbstractRelOptPlanner) {
RelOptListener listener = ((AbstractRelOptPlanner) planner).getListener();
if (listener != null)
{ hepPlanner.addListener(listener); }
}
This keeps Program stateless and reusable, while preserving the listener’s
session lifetime. It also makes the behavior generally useful: any listener
registered on the runtime planner will receive events from the internal HEP
planner used by this program, rather than requiring a special Programs.of
overload with listener.
If this direction sounds reasonable, I’ll remove the new overload and update
the test to register the listener on the planner passed into Program.run, then
verify that HEP rule events are forwarded through that session listener.
--
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]