michaelbraun opened a new pull request, #5264: URL: https://github.com/apache/calcite/pull/5264
AbstractRelNode's default deepEquals()/deepHashCode() builds a RelDigestWriter and a PairList and re-runs explainTerms() on both sides for every comparison. These methods back RelNode.getRelDigest(), which HepPlanner and VolcanoPlanner use for their digest-based node dedup, and which RexSubQuery uses for its own equals()/hashCode() -- so the cost is paid on essentially every structural comparison of a plan, not just occasionally. LogicalJoin, LogicalFilter and LogicalProject already avoid this: their abstract core classes expose protected deepEquals0()/deepHashCode0() helpers that compare fields directly, and the final Logical* subclasses override deepEquals()/deepHashCode() to call them, per AbstractRelNode's own javadoc recommendation. LogicalUnion, LogicalIntersect and LogicalMinus never received the same treatment, despite being equally eligible: all three are final, and SetOp's explainTerms() output (inputs, "all") is already their complete identity. This PR adds deepEquals0()/deepHashCode0() helpers to SetOp, mirroring Join's, and overrides deepEquals()/deepHashCode() on LogicalUnion, LogicalIntersect and LogicalMinus only -- other subclasses (EnumerableUnion, JdbcUnion, BindableUnion, etc.) are non-final and keep the safe digest-based default. A new JMH benchmark (SetOpDigestBenchmark) isolates HepPlanner's digest dedup for UNION/INTERSECT/MINUS trees, separate from rule matching or plan construction. Across tree sizes and duplicate-branch ratios it shows roughly 5-20% lower wall-clock time for HepPlanner.setRoot() and a small consistent allocation reduction. LargePlanBenchmark also gets an INTERSECT variant alongside its existing UNION one. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
