Skip to content

Commit

Permalink
reuse cost and enforce
Browse files Browse the repository at this point in the history
  • Loading branch information
keanji-x committed Dec 30, 2022
1 parent 9dc78d2 commit 2b43c5e
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 151 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ public CostAndEnforcerJob(GroupExpression groupExpression, JobContext context) {
this.groupExpression = groupExpression;
}

public void init(double cost, List<GroupExpression> lowestCostChildren) {
this.curTotalCost = cost;
this.lowestCostChildren.addAll(lowestCostChildren);
}

/*-
* Please read the ORCA paper
* - 4.1.4 Optimization.
Expand Down Expand Up @@ -163,6 +158,7 @@ public void execute() {
pushJob(new OptimizeGroupJob(childGroup, jobContext));
return;
}

// when the child group finish the optimizeGroupJob, the code will begin to run.
GroupExpression lowestCostExpr = lowestCostPlanOpt.get().second;
lowestCostChildren.add(lowestCostExpr);
Expand Down Expand Up @@ -201,7 +197,7 @@ public void execute() {
* calculate enforce
* @return false if error occurs, the caller will return.
*/
public boolean calculateEnforce(List<PhysicalProperties> requestChildrenProperties) {
private boolean calculateEnforce(List<PhysicalProperties> requestChildrenProperties) {
// to ensure distributionSpec has been added sufficiently.
// it's certain that lowestCostChildren is equals to arity().
ChildrenPropertiesRegulator regulator = new ChildrenPropertiesRegulator(groupExpression,
Expand Down Expand Up @@ -247,7 +243,7 @@ public boolean calculateEnforce(List<PhysicalProperties> requestChildrenProperti
* @param outputProperty the group expression's out property
* @param requestChildrenProperty the group expression's request to its child.
*/
public void enforce(PhysicalProperties outputProperty, List<PhysicalProperties> requestChildrenProperty) {
private void enforce(PhysicalProperties outputProperty, List<PhysicalProperties> requestChildrenProperty) {
PhysicalProperties requiredProperties = context.getRequiredProperties();
if (outputProperty.satisfy(requiredProperties)) {
if (!outputProperty.equals(requiredProperties)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ private Group optimizeJoin(Group group) {
buildGraph(group, hyperGraph);
// TODO: Right now, we just hardcode the limit with 10000, maybe we need a better way to set it
int limit = 10000;
PlanReceiver planReceiver = new PlanReceiver(this.context, limit);
PlanReceiver planReceiver = new PlanReceiver(this.context, limit, hyperGraph,
group.getLogicalProperties().getOutputSet());
SubgraphEnumerator subgraphEnumerator = new SubgraphEnumerator(planReceiver, hyperGraph);
if (!subgraphEnumerator.enumerate()) {
GraphSimplifier graphSimplifier = new GraphSimplifier(hyperGraph);
Expand Down
Loading

0 comments on commit 2b43c5e

Please sign in to comment.