This repository has been archived by the owner on Aug 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 186
/
Filter.java
76 lines (65 loc) 路 2.19 KB
/
Filter.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the "license" file accompanying this file. This file 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 com.amazon.opendistroforelasticsearch.sql.ppl.plans.logical;
import com.amazon.opendistroforelasticsearch.sql.ppl.node.AbstractNodeVisitor;
import com.amazon.opendistroforelasticsearch.sql.ppl.plans.expression.Expression;
import com.amazon.opendistroforelasticsearch.sql.ppl.plans.logical.builder.UnresolvedPlanBuilder;
import com.google.common.collect.ImmutableList;
import java.util.List;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
/**
* Logical plan node of Filter, the interface for building filters in queries
*/
@ToString
@EqualsAndHashCode(callSuper = false)
@Getter
public class Filter extends UnresolvedPlan {
private Expression condition;
private UnresolvedPlan child;
public Filter(Expression condition) {
this.condition = condition;
}
@Override
public List<UnresolvedPlan> getChild() {
return ImmutableList.of(child);
}
@Override
public <T, C> T accept(AbstractNodeVisitor<T, C> nodeVisitor, C context) {
return nodeVisitor.visitFilter(this, context);
}
private Filter(Builder builder) {
this.child = builder.child;
}
/**
* Filter plan builder
*/
public static class Builder extends UnresolvedPlanBuilder<Filter> {
UnresolvedPlan child;
public Builder(Filter plan) {
super(plan);
}
@Override
public Builder attachPlan(UnresolvedPlan attach) {
this.child = attach;
return this;
}
@Override
public Filter build() {
return new Filter(this);
}
}
}