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

[INLONG-11089][Manager] Optimize Sort filter function #11090

Merged
merged 2 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ public static List<FilterFunction> createFilterFunctions(FilterDefinition filter
.map(filterRule -> createFilterFunction(filterRule, transformName)).collect(Collectors.toList());
// Move logicOperator to preFunction
for (int index = filterFunctions.size() - 1; index > 0; index--) {
SingleValueFilterFunction function = (SingleValueFilterFunction) filterFunctions.get(index);
SingleValueFilterFunction preFunction = (SingleValueFilterFunction) filterFunctions.get(index - 1);
FilterFunction function = filterFunctions.get(index);
FilterFunction preFunction = filterFunctions.get(index - 1);
function.setLogicOperator(preFunction.getLogicOperator());
}
((SingleValueFilterFunction) filterFunctions.get(0)).setLogicOperator(EmptyOperator.getInstance());
(filterFunctions.get(0)).setLogicOperator(EmptyOperator.getInstance());
return filterFunctions;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import org.apache.inlong.sort.protocol.transformation.function.MultiValueFilterFunction;
import org.apache.inlong.sort.protocol.transformation.function.SingleValueFilterFunction;

import lombok.Data;
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonSubTypes;
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonTypeInfo;

Expand All @@ -33,6 +35,9 @@
@JsonSubTypes.Type(value = MultiValueFilterFunction.class, name = "multiValueFilter"),
@JsonSubTypes.Type(value = BetweenFunction.class, name = "betweenFunction")
})
public interface FilterFunction extends Function {
@Data
public abstract class FilterFunction implements Function {

@JsonProperty("logicOperator")
protected LogicOperator logicOperator;
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import javax.annotation.Nonnull;

import java.io.Serializable;
import java.util.Arrays;
import java.util.List;

Expand All @@ -38,7 +39,7 @@
*/
@JsonTypeName("betweenFunction")
@Data
public class BetweenFunction implements FilterFunction {
public class BetweenFunction extends FilterFunction implements Serializable {

@Nonnull
@JsonProperty("field")
Expand All @@ -49,9 +50,6 @@ public class BetweenFunction implements FilterFunction {
@Nonnull
@JsonProperty("end")
private final FunctionParam end;
@Nonnull
@JsonProperty("logicOperator")
private final LogicOperator logicOperator;

@JsonCreator
public BetweenFunction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonTypeName;

import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
Expand All @@ -40,16 +41,14 @@
@JsonTypeName("multiValueFilter")
@Data
@NoArgsConstructor
public class MultiValueFilterFunction implements FilterFunction {
public class MultiValueFilterFunction extends FilterFunction implements Serializable {

@JsonProperty("source")
private FunctionParam source;
@JsonProperty("targets")
private List<FunctionParam> targets;
@JsonProperty("compareOperator")
private MultiValueCompareOperator compareOperator;
@JsonProperty("logicOperator")
private LogicOperator logicOperator;

@JsonCreator
public MultiValueFilterFunction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
@JsonTypeName("singleValueFilter")
@Data
@NoArgsConstructor
public class SingleValueFilterFunction implements FilterFunction, Serializable {
public class SingleValueFilterFunction extends FilterFunction implements Serializable {

private static final long serialVersionUID = 8953419088907830331L;

Expand All @@ -49,8 +49,6 @@ public class SingleValueFilterFunction implements FilterFunction, Serializable {
private FunctionParam target;
@JsonProperty("compareOperator")
private SingleValueCompareOperator compareOperator;
@JsonProperty("logicOperator")
private LogicOperator logicOperator;

@JsonCreator
public SingleValueFilterFunction(
Expand Down
Loading