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
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* init * update * update * update doc
- Loading branch information
Showing
17 changed files
with
476 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
...istroforelasticsearch/sql/elasticsearch/planner/logical/rule/PushProjectAndIndexScan.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* | ||
* 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.rule; | ||
|
||
import static com.amazon.opendistroforelasticsearch.sql.elasticsearch.planner.logical.rule.OptimizationRuleUtils.findReferenceExpressions; | ||
import static com.amazon.opendistroforelasticsearch.sql.planner.optimizer.pattern.Patterns.source; | ||
import static com.facebook.presto.matching.Pattern.typeOf; | ||
|
||
import com.amazon.opendistroforelasticsearch.sql.elasticsearch.planner.logical.ElasticsearchLogicalIndexScan; | ||
import com.amazon.opendistroforelasticsearch.sql.expression.ReferenceExpression; | ||
import com.amazon.opendistroforelasticsearch.sql.planner.logical.LogicalPlan; | ||
import com.amazon.opendistroforelasticsearch.sql.planner.logical.LogicalProject; | ||
import com.amazon.opendistroforelasticsearch.sql.planner.optimizer.Rule; | ||
import com.facebook.presto.matching.Capture; | ||
import com.facebook.presto.matching.Captures; | ||
import com.facebook.presto.matching.Pattern; | ||
import java.util.Set; | ||
|
||
/** | ||
* Push Project list into ElasticsearchLogicalIndexScan. | ||
*/ | ||
public class PushProjectAndIndexScan implements Rule<LogicalProject> { | ||
|
||
private final Capture<ElasticsearchLogicalIndexScan> indexScanCapture; | ||
|
||
private final Pattern<LogicalProject> pattern; | ||
|
||
private Set<ReferenceExpression> pushDownProjects; | ||
|
||
/** | ||
* Constructor of MergeProjectAndIndexScan. | ||
*/ | ||
public PushProjectAndIndexScan() { | ||
this.indexScanCapture = Capture.newCapture(); | ||
this.pattern = typeOf(LogicalProject.class).matching( | ||
project -> { | ||
pushDownProjects = findReferenceExpressions(project.getProjectList()); | ||
return !pushDownProjects.isEmpty(); | ||
}).with(source() | ||
.matching(typeOf(ElasticsearchLogicalIndexScan.class) | ||
.matching(indexScan -> !indexScan.hasProjects()) | ||
.capturedAs(indexScanCapture))); | ||
|
||
} | ||
|
||
@Override | ||
public Pattern<LogicalProject> pattern() { | ||
return pattern; | ||
} | ||
|
||
@Override | ||
public LogicalPlan apply(LogicalProject project, | ||
Captures captures) { | ||
ElasticsearchLogicalIndexScan indexScan = captures.get(indexScanCapture); | ||
indexScan.setProjectList(pushDownProjects); | ||
return new LogicalProject(indexScan, project.getProjectList()); | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
...distroforelasticsearch/sql/elasticsearch/planner/logical/rule/PushProjectAndRelation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* | ||
* 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.rule; | ||
|
||
import static com.amazon.opendistroforelasticsearch.sql.elasticsearch.planner.logical.rule.OptimizationRuleUtils.findReferenceExpressions; | ||
import static com.amazon.opendistroforelasticsearch.sql.planner.optimizer.pattern.Patterns.source; | ||
import static com.facebook.presto.matching.Pattern.typeOf; | ||
|
||
import com.amazon.opendistroforelasticsearch.sql.elasticsearch.planner.logical.ElasticsearchLogicalIndexScan; | ||
import com.amazon.opendistroforelasticsearch.sql.expression.ReferenceExpression; | ||
import com.amazon.opendistroforelasticsearch.sql.planner.logical.LogicalPlan; | ||
import com.amazon.opendistroforelasticsearch.sql.planner.logical.LogicalProject; | ||
import com.amazon.opendistroforelasticsearch.sql.planner.logical.LogicalRelation; | ||
import com.amazon.opendistroforelasticsearch.sql.planner.optimizer.Rule; | ||
import com.facebook.presto.matching.Capture; | ||
import com.facebook.presto.matching.Captures; | ||
import com.facebook.presto.matching.Pattern; | ||
import java.util.Set; | ||
|
||
/** | ||
* Push Project list into Relation. The transformed plan is Project - IndexScan | ||
*/ | ||
public class PushProjectAndRelation implements Rule<LogicalProject> { | ||
|
||
private final Capture<LogicalRelation> relationCapture; | ||
|
||
private final Pattern<LogicalProject> pattern; | ||
|
||
private Set<ReferenceExpression> pushDownProjects; | ||
|
||
/** | ||
* Constructor of MergeProjectAndRelation. | ||
*/ | ||
public PushProjectAndRelation() { | ||
this.relationCapture = Capture.newCapture(); | ||
this.pattern = typeOf(LogicalProject.class) | ||
.matching(project -> { | ||
pushDownProjects = findReferenceExpressions(project.getProjectList()); | ||
return !pushDownProjects.isEmpty(); | ||
}) | ||
.with(source().matching(typeOf(LogicalRelation.class).capturedAs(relationCapture))); | ||
} | ||
|
||
@Override | ||
public Pattern<LogicalProject> pattern() { | ||
return pattern; | ||
} | ||
|
||
@Override | ||
public LogicalPlan apply(LogicalProject project, | ||
Captures captures) { | ||
LogicalRelation relation = captures.get(relationCapture); | ||
return new LogicalProject( | ||
ElasticsearchLogicalIndexScan | ||
.builder() | ||
.relationName(relation.getRelationName()) | ||
.projectList(findReferenceExpressions(project.getProjectList())) | ||
.build(), | ||
project.getProjectList() | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.