forked from opendistro-for-elasticsearch/sql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ElasticsearchLogicalIndexScan.java
109 lines (96 loc) · 2.87 KB
/
ElasticsearchLogicalIndexScan.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
*
* Copyright 2020 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.elasticsearch.planner.logical;
import com.amazon.opendistroforelasticsearch.sql.ast.tree.Sort;
import com.amazon.opendistroforelasticsearch.sql.expression.Expression;
import com.amazon.opendistroforelasticsearch.sql.expression.NamedExpression;
import com.amazon.opendistroforelasticsearch.sql.expression.ReferenceExpression;
import com.amazon.opendistroforelasticsearch.sql.planner.logical.LogicalPlan;
import com.amazon.opendistroforelasticsearch.sql.planner.logical.LogicalPlanNodeVisitor;
import com.google.common.collect.ImmutableList;
import java.util.List;
import java.util.Set;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.apache.commons.lang3.tuple.Pair;
/**
* Elasticsearch Logical Index Scan Operation.
*/
@Getter
@ToString
@EqualsAndHashCode(callSuper = false)
public class ElasticsearchLogicalIndexScan extends LogicalPlan {
/**
* Relation Name.
*/
private final String relationName;
/**
* Filter Condition.
*/
@Setter
private Expression filter;
/**
* Projection List.
*/
@Setter
private Set<ReferenceExpression> projectList;
/**
* Sort List.
*/
@Setter
private List<Pair<Sort.SortOption, Expression>> sortList;
@Setter
private Integer offset;
@Setter
private Integer limit;
/**
* ElasticsearchLogicalIndexScan Constructor.
*/
@Builder
public ElasticsearchLogicalIndexScan(
String relationName,
Expression filter,
Set<ReferenceExpression> projectList,
List<Pair<Sort.SortOption, Expression>> sortList,
Integer limit, Integer offset) {
super(ImmutableList.of());
this.relationName = relationName;
this.filter = filter;
this.projectList = projectList;
this.sortList = sortList;
this.limit = limit;
this.offset = offset;
}
@Override
public <R, C> R accept(LogicalPlanNodeVisitor<R, C> visitor, C context) {
return visitor.visitNode(this, context);
}
public boolean hasLimit() {
return limit != null;
}
/**
* Test has projects or not.
*
* @return true for has projects, otherwise false.
*/
public boolean hasProjects() {
return projectList != null && !projectList.isEmpty();
}
}