Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move InList related simplify to one place #9037

Merged
merged 7 commits into from
Feb 4, 2024
Merged

Conversation

guojidan
Copy link
Contributor

@guojidan guojidan commented Jan 29, 2024

Which issue does this PR close?

Part of #8970.

Rationale for this change

move all InList related simplify to one place

Are these changes tested?

no

Are there any user-facing changes?

no

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this contribution @guojidan -- I have a suggestion to make things even simpler here for your consideration

impl TreeNodeRewriter for InListSimplifier {
type N = Expr;

fn mutate(&mut self, expr: Expr) -> Result<Expr> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder what the the reason to have multiple different simplifiers? As written now, each TreeNodeRewriter makes a different pass over the expression tree. I think we could make a single pass.

For example, could we have a single function in this module like `fn simplify(expr: Expr) -> Result```

That was called as part of Expr::Simplifier::mutate? I think that could make the code simpler as well as more performant

@alamb
Copy link
Contributor

alamb commented Feb 2, 2024

Hi @guojidan -- I wonder if you are still working on this PR? What do you think about moving all the rewrites into the same pass?

@alamb alamb marked this pull request as draft February 2, 2024 21:51
@guojidan
Copy link
Contributor Author

guojidan commented Feb 4, 2024

Hi @guojidan -- I wonder if you are still working on this PR? What do you think about moving all the rewrites into the same pass?

all rewrites means all inlist rewrites?

@alamb
Copy link
Contributor

alamb commented Feb 4, 2024

all rewrites means all inlist rewrites?

Yes, sorry this is what i meant -- all the InList code

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @guojidan -- this looks good to me. I think as a follow on PR it would be nice to consolidate all the InList rewrites into a single pass (rather than ShortenInListSimplifier and InListSimplifier but this PR seems like a good step in that direction

Thanks again

@alamb
Copy link
Contributor

alamb commented Feb 4, 2024

In my opinion we could merge this PR or if you prefer you could consolidate the passes into a single Struct as part of this PR as well. Let me know what you you prefer.

@alamb alamb marked this pull request as ready for review February 4, 2024 13:00
@guojidan
Copy link
Contributor Author

guojidan commented Feb 4, 2024

In my opinion we could merge this PR or if you prefer you could consolidate the passes into a single Struct as part of this PR as well. Let me know what you you prefer.

Hi @alamb , consolidate ShortenInListSimplifier and InListSimplifier need more time(because they will have logical conflicts), So I want deal them in other PR 😄

@alamb
Copy link
Contributor

alamb commented Feb 4, 2024

Thanks again @guojidan !

@alamb alamb merged commit 5f18aa7 into apache:main Feb 4, 2024
22 checks passed
@guojidan guojidan deleted the inlist branch February 4, 2024 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
optimizer Optimizer rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants