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

[core] Introduce PredicateUtils to refactor Predicate handle #4469

Closed
wants to merge 10 commits into from

Conversation

xuzifu666
Copy link
Member

@xuzifu666 xuzifu666 commented Nov 6, 2024

Purpose

Linked issue: close #xxx

  1. Follow up [core] Optizime IN filter pushdown to snapshot/tag/schema system tables #4436 , refactor related logic to a util class to duplicate codes;
  2. Fix incidental ut failed due to order in schema test.

Tests

API and Format

Documentation

Preconditions.checkState(
predicate instanceof CompoundPredicate,
"PredicateUtils##handleCompoundPredicate should handle with a CompoundPredicate.");

Copy link
Contributor

Choose a reason for hiding this comment

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

PredicateUtils.traverseCompoundPredicate only supports processing Predicates of CompoundPredicate type

Copy link
Member Author

Choose a reason for hiding this comment

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

addressed

leafName,
(Predicate p) -> {
handleLeafPredicate(p, leafName);
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Can handleLeafPredicate method also be extracted to the util?

Copy link
Member Author

Choose a reason for hiding this comment

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

I had considered about it,this method common logic is less,extract may cost more codes,so keep as current maybe better. Thanks~ @LinMingQiang

@LinMingQiang
Copy link
Contributor

+1

snapshotIds.add((Long) ((LeafPredicate) p).literals().get(0));
}
},
(Predicate p) -> {
Copy link
Contributor

Choose a reason for hiding this comment

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

(Predicate p) -> snapshotIds = null

String leafName,
Consumer<Predicate> matchConsumer,
Consumer<Predicate> unMatchConsumer) {
Preconditions.checkState(
Copy link
Contributor

Choose a reason for hiding this comment

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

May be use Preconditions.checkArgument instead better?

schemaIds.add((Long) ((LeafPredicate) p).literals().get(0));
}
},
(Predicate p) -> {
Copy link
Contributor

Choose a reason for hiding this comment

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

(Predicate p) -> schemaIds = null

PredicateUtils.traverseCompoundPredicate(
predicate,
leafName,
(Predicate p) -> {
Copy link
Contributor

Choose a reason for hiding this comment

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

May replaced with expression lambda better?

(Predicate p) -> handleLeafPredicate(p, leafName)

}
},
(Predicate p) -> {
schemaIds = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not schemaIds.clear()?

}
},
(Predicate p) -> {
snapshotIds = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not snapshotIds.clear()?

Copy link
Member Author

@xuzifu666 xuzifu666 Nov 7, 2024

Choose a reason for hiding this comment

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

had just set to null which more efficient.

}
},
(Predicate p) -> {
predicateMap = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not predicateMap.clear();

Copy link
Member Author

Choose a reason for hiding this comment

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

had just set to null which more efficient.

@xuzifu666 xuzifu666 closed this Nov 7, 2024
@xuzifu666 xuzifu666 reopened this Nov 7, 2024
@xuzifu666 xuzifu666 changed the title [core] Introduce PredicateUtils to refactor Predicate handle [wip][core] Introduce PredicateUtils to refactor Predicate handle Nov 7, 2024
@xuzifu666 xuzifu666 changed the title [wip][core] Introduce PredicateUtils to refactor Predicate handle [core] Introduce PredicateUtils to refactor Predicate handle Nov 7, 2024
@xuzifu666
Copy link
Member Author

@wwj6591812 had addressed, Thanks for review.

import java.util.function.Consumer;

/** A utils to handle {@link Predicate}. */
public class PredicateUtils {
Copy link
Contributor

Choose a reason for hiding this comment

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

InPredicateVisitor?

* @param matchConsumer leafName matched handle
* @param unMatchConsumer leafName unmatched handle
*/
public static void traverseCompoundPredicate(
Copy link
Contributor

Choose a reason for hiding this comment

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

extractInElements

String leafName,
Consumer<Predicate> matchConsumer,
Consumer<Predicate> unMatchConsumer) {
Preconditions.checkArgument(
Copy link
Contributor

Choose a reason for hiding this comment

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

if (predicate is in predicate): just get elements from it.

* @param matchConsumer leafName matched handle
* @param unMatchConsumer leafName unmatched handle
*/
public static void traverseCompoundPredicate(
Copy link
Contributor

Choose a reason for hiding this comment

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

Just return Optional<List<Object>>, elements of in.

Copy link
Member Author

Choose a reason for hiding this comment

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

Get it, would modify as suggestion,Thanks @JingsongLi

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm traveling outside, would modify it in these two days.

Copy link
Member Author

@xuzifu666 xuzifu666 Nov 9, 2024

Choose a reason for hiding this comment

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

move the pr to a new pr #4486 close it first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants