Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GIE Compiler] Introduce
GraphPlanner
to unify logical and physical…
… plan building (#2838) <!-- Thanks for your contribution! please review https://github.com/alibaba/GraphScope/blob/main/CONTRIBUTING.md before opening an issue. --> ## What do these changes do? 1. re-design `PhysicalBuilder` to build physical plan from logical plan, `FfiPhysicalBuilder` is one of the implementations which will build physical plan in ir core structure 2. introduce `GraphPlanner` to unify logical and physical plan building phases 3. other minor fix: refine the structure of `IrMeta` which contains schema info <!-- Please give a short brief about these changes. --> ## Related issue number <!-- Are there any issues opened that will be resolved by merging this change? --> Fixes --------- Co-authored-by: Longbin Lai <longbin.lailb@alibaba-inc.com>
- Loading branch information
1 parent
a8b9dce
commit 1ba6102
Showing
35 changed files
with
643 additions
and
424 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
26 changes: 26 additions & 0 deletions
26
...tive_engine/compiler/src/main/java/com/alibaba/graphscope/common/antlr4/Antlr4Parser.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,26 @@ | ||
/* | ||
* Copyright 2020 Alibaba Group Holding Limited. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License 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.alibaba.graphscope.common.antlr4; | ||
|
||
import org.antlr.v4.runtime.tree.ParseTree; | ||
|
||
/** | ||
* parse DSL statement to antlr tree | ||
*/ | ||
public interface Antlr4Parser { | ||
ParseTree parse(String statement); | ||
} |
61 changes: 0 additions & 61 deletions
61
...compiler/src/main/java/com/alibaba/graphscope/common/ir/runtime/LogicalPlanConverter.java
This file was deleted.
Oops, something went wrong.
60 changes: 60 additions & 0 deletions
60
...mpiler/src/main/java/com/alibaba/graphscope/common/ir/runtime/RegularPhysicalBuilder.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,60 @@ | ||
/* | ||
* Copyright 2020 Alibaba Group Holding Limited. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License 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.alibaba.graphscope.common.ir.runtime; | ||
|
||
import com.alibaba.graphscope.common.ir.runtime.type.PhysicalNode; | ||
import com.alibaba.graphscope.common.ir.tools.LogicalPlan; | ||
|
||
import org.apache.calcite.rel.RelNode; | ||
import org.apache.calcite.rel.RelShuttle; | ||
import org.apache.calcite.rel.RelVisitor; | ||
import org.checkerframework.checker.nullness.qual.Nullable; | ||
|
||
/** | ||
* build physical plan from logical plan of a regular query | ||
* @param <T> | ||
* @param <R> | ||
*/ | ||
public abstract class RegularPhysicalBuilder<T, R> extends PhysicalBuilder<R> { | ||
protected RelShuttle relShuttle; | ||
|
||
protected RegularPhysicalBuilder(LogicalPlan logicalPlan, RelShuttle relShuttle) { | ||
super(logicalPlan); | ||
this.relShuttle = relShuttle; | ||
} | ||
|
||
protected void initialize() { | ||
if (this.logicalPlan.getRegularQuery() != null && !this.logicalPlan.isReturnEmpty()) { | ||
RelNode regularQuery = this.logicalPlan.getRegularQuery(); | ||
RelVisitor relVisitor = | ||
new RelVisitor() { | ||
@Override | ||
public void visit(RelNode node, int ordinal, @Nullable RelNode parent) { | ||
super.visit(node, ordinal, parent); | ||
appendNode((PhysicalNode) node.accept(relShuttle)); | ||
} | ||
}; | ||
relVisitor.go(regularQuery); | ||
} | ||
} | ||
|
||
/** | ||
* append {@code PhysicalNode} to the physical plan | ||
* @param node | ||
*/ | ||
protected abstract void appendNode(PhysicalNode<T> node); | ||
} |
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.