MCPcopy Create free account
hub / github.com/apache/pig / optimize

Method optimize

src/org/apache/pig/newplan/optimizer/PlanOptimizer.java:95–132  ·  view source on GitHub ↗

Run the optimizer. This method attempts to match each of the Rules against the plan. If a Rule matches, it then calls the check method of the associated Transformer to give the it a chance to check whether it really wants to do the optimization. If that returns true as well, then Transformer.tran

()

Source from the content-addressed store, hash-verified

93 * @throws FrontendException
94 */
95 public void optimize() throws FrontendException {
96
97 for (Set<Rule> rs : ruleSets) {
98 boolean sawMatch = false;
99 int numIterations = 0;
100 do {
101 sawMatch = false;
102 for (Rule rule : rs) {
103 List<OperatorPlan> matches = rule.match(plan);
104 if (matches != null) {
105 Transformer transformer = rule.getNewTransformer();
106 for (OperatorPlan m : matches) {
107 try {
108 if (transformer.check(m)) {
109 sawMatch = true;
110 transformer.transform(m);
111 OperatorPlan change = transformer.reportChanges();
112 if (change == null) {
113 sawMatch = false;
114 } else if (!rule.isSkipListener()) {
115 for(PlanTransformListener l: listeners) {
116 l.transformed(plan, change);
117 }
118 }
119 }
120 } catch (Exception e) {
121 StringBuffer message = new StringBuffer("Error processing rule " + rule.name);
122 if (!rule.isMandatory()) {
123 message.append(". Try -t " + rule.name);
124 }
125 throw new FrontendException(message.toString(), 2000, e);
126 }
127 }
128 }
129 }
130 } while(sawMatch && ++numIterations < maxIter);
131 }
132 }
133}

Callers 15

testFilterPushDownMethod · 0.45
buildPlanMethod · 0.45
checkPhysicalPlanMethod · 0.45
testNoPruneMethod · 0.45
testPruneMethod · 0.45
testPruneWithMapKeyMethod · 0.45
testPruneWithBagMethod · 0.45
testAddForeachMethod · 0.45
testDistinctMethod · 0.45
testNoAddForeachMethod · 0.45

Calls 10

checkMethod · 0.95
transformMethod · 0.95
reportChangesMethod · 0.95
isSkipListenerMethod · 0.80
isMandatoryMethod · 0.80
matchMethod · 0.65
transformedMethod · 0.65
appendMethod · 0.65
getNewTransformerMethod · 0.45
toStringMethod · 0.45

Tested by 15

testFilterPushDownMethod · 0.36
buildPlanMethod · 0.36
checkPhysicalPlanMethod · 0.36
testNoPruneMethod · 0.36
testPruneMethod · 0.36
testPruneWithMapKeyMethod · 0.36
testPruneWithBagMethod · 0.36
testAddForeachMethod · 0.36
testDistinctMethod · 0.36
testNoAddForeachMethod · 0.36