-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[core] Introduce PredicateUtils to refactor Predicate handle #4469
Changes from all commits
dfaac78
e79c558
b8c80f7
9ad4e26
d973c87
1698c93
188bf2c
8b4aba9
3f1b0d1
cb36eb2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* 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.paimon.predicate; | ||
|
||
import org.apache.paimon.utils.Preconditions; | ||
|
||
import java.util.List; | ||
import java.util.function.Consumer; | ||
|
||
/** A utils to handle {@link Predicate}. */ | ||
public class PredicateUtils { | ||
|
||
/** | ||
* Method for handling with CompoundPredicate. | ||
* | ||
* @param predicate CompoundPredicate to traverse handle | ||
* @param leafName LeafPredicate name | ||
* @param matchConsumer leafName matched handle | ||
* @param unMatchConsumer leafName unmatched handle | ||
*/ | ||
public static void traverseCompoundPredicate( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just return There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Get it, would modify as suggestion,Thanks @JingsongLi There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm traveling outside, would modify it in these two days. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. move the pr to a new pr #4486 close it first. |
||
Predicate predicate, | ||
String leafName, | ||
Consumer<Predicate> matchConsumer, | ||
Consumer<Predicate> unMatchConsumer) { | ||
Preconditions.checkArgument( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if (predicate is in predicate): just get elements from it. |
||
predicate instanceof CompoundPredicate, | ||
"PredicateUtils.traverseCompoundPredicate only supports processing Predicates of CompoundPredicate type."); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PredicateUtils.traverseCompoundPredicate only supports processing Predicates of CompoundPredicate type There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. addressed |
||
CompoundPredicate compoundPredicate = (CompoundPredicate) predicate; | ||
List<Predicate> children = compoundPredicate.children(); | ||
for (Predicate leaf : children) { | ||
if (leaf instanceof LeafPredicate | ||
&& (((LeafPredicate) leaf).function() instanceof Equal) | ||
&& leaf.visit(LeafPredicateExtractor.INSTANCE).get(leafName) != null | ||
&& matchConsumer != null) { | ||
matchConsumer.accept(leaf); | ||
} else { | ||
if (unMatchConsumer != null) { | ||
unMatchConsumer.accept(leaf); | ||
} | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
InPredicateVisitor?