Skip to content

Commit

Permalink
support features for ic benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
shirly121 committed Oct 17, 2024
1 parent ff7693f commit b05b29f
Show file tree
Hide file tree
Showing 10 changed files with 303 additions and 312 deletions.
10 changes: 9 additions & 1 deletion interactive_engine/compiler/src/main/antlr4/CypherGS.g4
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,15 @@ CALL : ( 'C' | 'c' ) ( 'A' | 'a' ) ( 'L' | 'l' ) ( 'L' | 'l' ) ;
YIELD : ( 'Y' | 'y' ) ( 'I' | 'i' ) ( 'E' | 'e' ) ( 'L' | 'l' ) ( 'D' | 'd' ) ;

oC_RegularQuery
: oC_Match ( SP? ( oC_Match | oC_With | oC_Unwind | oC_UnionCallSubQuery ) )* ( SP oC_Return ) ;
: ( oC_ReadingClause SP? )* SP? oC_ReadingClause ( SP oC_Return )
;

oC_ReadingClause
: oC_Match
| oC_Unwind
| oC_With
| oC_UnionCallSubQuery
;

oC_SubQuery
: ( ( oC_Match | oC_With | oC_Unwind ) SP? )* ( SP? oC_Return ) ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import com.alibaba.graphscope.common.ir.meta.IrMeta;
import com.alibaba.graphscope.common.ir.meta.glogue.calcite.GraphRelMetadataQuery;
import com.alibaba.graphscope.common.ir.meta.glogue.calcite.handler.GraphMetadataHandlerProvider;
import com.alibaba.graphscope.common.ir.meta.schema.CommonOptTable;
import com.alibaba.graphscope.common.ir.rel.CommonTableScan;
import com.alibaba.graphscope.common.ir.rel.GraphShuttle;
import com.alibaba.graphscope.common.ir.rel.graph.GraphLogicalSource;
import com.alibaba.graphscope.common.ir.rel.graph.match.AbstractLogicalMatch;
Expand All @@ -32,6 +34,7 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

import org.apache.calcite.plan.GraphOptCluster;
import org.apache.calcite.plan.RelOptPlanner;
Expand All @@ -45,6 +48,7 @@
import org.checkerframework.checker.nullness.qual.Nullable;

import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;

/**
Expand Down Expand Up @@ -100,10 +104,26 @@ public RelNode optimize(RelNode before, GraphIOProcessor ioProcessor) {
public static class MatchOptimizer extends GraphShuttle {
private final GraphIOProcessor ioProcessor;
private final RelOptPlanner matchPlanner;
// record the common rel(s) which has been optimized
private final Map<String, RelNode> commonTableToOpt;

public MatchOptimizer(GraphIOProcessor ioProcessor, RelOptPlanner matchPlanner) {
this.ioProcessor = ioProcessor;
this.matchPlanner = matchPlanner;
this.commonTableToOpt = Maps.newHashMap();
}

@Override
public RelNode visit(CommonTableScan tableScan) {
CommonOptTable optTable = (CommonOptTable) tableScan.getTable();
String tableName = optTable.getQualifiedName().get(0);
RelNode commonOpt = commonTableToOpt.get(tableName);
if (commonOpt == null) {
commonOpt = optTable.getCommon().accept(this);
commonTableToOpt.put(tableName, commonOpt);
}
return new CommonTableScan(
tableScan.getCluster(), tableScan.getTraitSet(), new CommonOptTable(commonOpt));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.alibaba.graphscope.common.ir.rel.type.AliasNameWithId;
import com.alibaba.graphscope.common.ir.rex.RexGraphVariable;
import com.google.common.collect.Lists;

import org.apache.calcite.rel.RelNode;
import org.apache.calcite.rel.core.JoinRelType;
import org.apache.calcite.rel.logical.LogicalFilter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.alibaba.graphscope.common.ir.tools.config.GraphOpt;
import com.alibaba.graphscope.common.ir.type.GraphSchemaType;
import com.google.common.collect.ImmutableList;

import org.apache.calcite.plan.GraphOptCluster;
import org.apache.calcite.plan.RelTraitSet;
import org.apache.calcite.rel.RelNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.alibaba.graphscope.common.ir.rel.type.TableConfig;
import com.alibaba.graphscope.common.ir.tools.config.GraphOpt;
import com.google.common.collect.ImmutableList;

import org.apache.calcite.plan.GraphOptCluster;
import org.apache.calcite.plan.RelTraitSet;
import org.apache.calcite.rel.RelNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.alibaba.graphscope.common.ir.rel.type.TableConfig;
import com.alibaba.graphscope.common.ir.tools.config.GraphOpt;
import com.google.common.collect.ImmutableList;

import org.apache.calcite.plan.GraphOptCluster;
import org.apache.calcite.rel.RelNode;
import org.apache.calcite.rel.RelShuttle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.alibaba.graphscope.common.ir.tools.GraphBuilder;
import com.alibaba.graphscope.grammar.CypherGSBaseVisitor;
import com.alibaba.graphscope.grammar.CypherGSParser;

import org.apache.calcite.plan.GraphOptCluster;
import org.apache.calcite.plan.RelOptTable;
import org.apache.calcite.rel.RelNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ public GraphBuilder visitOC_UnionCallSubQuery(CypherGSParser.OC_UnionCallSubQuer
for (int i = 0; i < ctx.oC_CallSubQuery().size(); ++i) {
CypherGSParser.OC_CallSubQueryContext callSubQuery = ctx.oC_CallSubQuery(i);
if (callSubQuery != null) {
branches.add(
new CallSubQueryVisitor(this.builder).visit(callSubQuery));
branches.add(new CallSubQueryVisitor(this.builder).visit(callSubQuery));
}
}
Preconditions.checkArgument(
Expand Down
Loading

0 comments on commit b05b29f

Please sign in to comment.