Merge lp:~zorba-coders/zorba/gen-flwor-opt into lp:zorba
- gen-flwor-opt
- Merge into trunk
Proposed by
Markos Zaharioudakis
Status: | Merged |
---|---|
Approved by: | Markos Zaharioudakis |
Approved revision: | 10685 |
Merged at revision: | 11455 |
Proposed branch: | lp:~zorba-coders/zorba/gen-flwor-opt |
Merge into: | lp:zorba |
Diff against target: |
4114 lines (+2136/-1186) 44 files modified
ChangeLog (+11/-0) src/compiler/api/compiler_api_impl.cpp (+1/-1) src/compiler/expression/flwor_expr.cpp (+0/-22) src/compiler/expression/flwor_expr.h (+0/-1) src/compiler/rewriter/CMakeLists.txt (+0/-1) src/compiler/rewriter/framework/CMakeLists.txt (+2/-1) src/compiler/rewriter/framework/default_optimizer.cpp (+275/-0) src/compiler/rewriter/framework/default_optimizer.h (+47/-0) src/compiler/rewriter/framework/rule_driver.cpp (+2/-2) src/compiler/rewriter/framework/rule_driver.h (+8/-2) src/compiler/rewriter/framework/sequential_rewriter.cpp (+2/-2) src/compiler/rewriter/framework/sequential_rewriter.h (+14/-1) src/compiler/rewriter/rewriters/CMakeLists.txt (+0/-16) src/compiler/rewriter/rewriters/common_rewriter.h (+0/-33) src/compiler/rewriter/rewriters/default_optimizer.cpp (+0/-275) src/compiler/rewriter/rewriters/default_optimizer.h (+0/-47) src/compiler/rewriter/rewriters/phase1_rewriter.cpp (+0/-33) src/compiler/rewriter/rewriters/phase1_rewriter.h (+0/-42) src/compiler/rewriter/rules/fold_rules.h (+0/-1) src/compiler/rewriter/rules/hoist_rules.cpp (+457/-238) src/compiler/rewriter/rules/hoist_rules.h (+55/-0) src/compiler/rewriter/rules/ruleset.h (+0/-13) src/system/globalenv.cpp (+5/-0) test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/gflwor_02.iter (+76/-41) test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/gflwor_03.iter (+100/-81) test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/gflwor_04.iter (+67/-51) test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/gflwor_05.iter (+28/-14) test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/idx10.iter (+104/-108) test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/idx11.iter (+38/-17) test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/idx9.iter (+13/-9) test/rbkt/ExpCompilerResults/IterPlan/zorba/index/match_veq_04.iter (+12/-5) test/rbkt/ExpCompilerResults/IterPlan/zorba/index/match_veq_05.iter (+12/-5) test/rbkt/ExpCompilerResults/IterPlan/zorba/index/match_veq_06.iter (+0/-7) test/rbkt/ExpCompilerResults/IterPlan/zorba/index/match_veq_10.iter (+39/-31) test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/q4.iter (+10/-3) test/rbkt/ExpCompilerResults/IterPlan/zorba/optim/hoist_trycatch_01.iter (+211/-0) test/rbkt/ExpCompilerResults/IterPlan/zorba/optim/hoist_window_01.iter (+295/-0) test/rbkt/ExpCompilerResults/IterPlan/zorba/optim/var_inline_05.iter (+31/-23) test/rbkt/ExpCompilerResults/IterPlan/zorba/xmark/q4.iter (+10/-3) test/rbkt/ExpQueryResults/zorba/optim/hoist_trycatch_01.xml.res (+1/-0) test/rbkt/ExpQueryResults/zorba/optim/hoist_window_01.xml.res (+1/-0) test/rbkt/Queries/zorba/hashjoins/gflwor_04.xq (+66/-57) test/rbkt/Queries/zorba/optim/hoist_trycatch_01.xq (+115/-0) test/rbkt/Queries/zorba/optim/hoist_window_01.xq (+28/-0) |
To merge this branch: | bzr merge lp:~zorba-coders/zorba/gen-flwor-opt |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Markos Zaharioudakis | Approve | ||
Review via email: mp+163850@code.launchpad.net |
Commit message
1. Implemented hoisting optimization for general FLWOR.
2. Fixed bug in hoisting through try-catch expr
Description of the change
1. Implemented hoisting optimization for general FLWOR.
2. Fixed bug in hoisting through try-catch expr
To post a comment you must log in.
- 10681. By Markos Zaharioudakis
-
hoisting applied to general flwor
- 10682. By Markos Zaharioudakis
-
fixed bug in hoisting through try-catch expr
- 10683. By Markos Zaharioudakis
-
merge from trunk
- 10684. By Markos Zaharioudakis
-
updated ChangeLog
- 10685. By Markos Zaharioudakis
-
fixed iter plan
Revision history for this message
Markos Zaharioudakis (markos-za) : | # |
review:
Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : | # |
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job gen-flwor-
All tests succeeded!
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'ChangeLog' |
2 | --- ChangeLog 2013-05-15 14:53:48 +0000 |
3 | +++ ChangeLog 2013-05-16 10:15:45 +0000 |
4 | @@ -1,6 +1,17 @@ |
5 | Zorba - The XQuery Processor |
6 | |
7 | |
8 | +version 3.0 |
9 | + |
10 | +New Features: |
11 | + |
12 | +Optimizations: |
13 | + * Implemented hoisting optimization for general FLWOR. |
14 | + |
15 | +Bug Fixes/Other Changes: |
16 | + * Fixed bug in hoisting through try-catch expr |
17 | + |
18 | + |
19 | version 2.9 |
20 | |
21 | New Features: |
22 | |
23 | === modified file 'src/compiler/api/compiler_api_impl.cpp' |
24 | --- src/compiler/api/compiler_api_impl.cpp 2013-02-07 17:24:36 +0000 |
25 | +++ src/compiler/api/compiler_api_impl.cpp 2013-05-16 10:15:45 +0000 |
26 | @@ -17,7 +17,7 @@ |
27 | |
28 | #include "compiler/api/compiler_api_impl.h" |
29 | #include "compiler/api/compilercb.h" |
30 | -#include "compiler/rewriter/rewriters/default_optimizer.h" |
31 | +#include "compiler/rewriter/framework/default_optimizer.h" |
32 | |
33 | |
34 | namespace zorba { |
35 | |
36 | === modified file 'src/compiler/expression/flwor_expr.cpp' |
37 | --- src/compiler/expression/flwor_expr.cpp 2013-05-04 20:20:05 +0000 |
38 | +++ src/compiler/expression/flwor_expr.cpp 2013-05-16 10:15:45 +0000 |
39 | @@ -944,28 +944,6 @@ |
40 | |
41 | |
42 | /******************************************************************************* |
43 | - For simple flwor only. |
44 | -********************************************************************************/ |
45 | -csize flwor_expr::num_forlet_clauses() |
46 | -{ |
47 | - csize num = 0; |
48 | - csize numClauses = num_clauses(); |
49 | - for (csize i = 0; i < numClauses; ++i) |
50 | - { |
51 | - const flwor_clause* c = theClauses[i]; |
52 | - |
53 | - if (c->get_kind() == flwor_clause::for_clause || |
54 | - c->get_kind() == flwor_clause::let_clause) |
55 | - { |
56 | - ++num; |
57 | - } |
58 | - } |
59 | - |
60 | - return num; |
61 | -} |
62 | - |
63 | - |
64 | -/******************************************************************************* |
65 | |
66 | ********************************************************************************/ |
67 | bool flwor_expr::defines_var(const var_expr* v) const |
68 | |
69 | === modified file 'src/compiler/expression/flwor_expr.h' |
70 | --- src/compiler/expression/flwor_expr.h 2013-05-09 18:50:15 +0000 |
71 | +++ src/compiler/expression/flwor_expr.h 2013-05-16 10:15:45 +0000 |
72 | @@ -726,7 +726,6 @@ |
73 | void set_where(expr* e); |
74 | groupby_clause* get_group_clause() const; |
75 | orderby_clause* get_order_clause() const; |
76 | - csize num_forlet_clauses(); |
77 | |
78 | void accept(expr_visitor&); |
79 | |
80 | |
81 | === modified file 'src/compiler/rewriter/CMakeLists.txt' |
82 | --- src/compiler/rewriter/CMakeLists.txt 2013-02-07 17:24:36 +0000 |
83 | +++ src/compiler/rewriter/CMakeLists.txt 2013-05-16 10:15:45 +0000 |
84 | @@ -14,6 +14,5 @@ |
85 | SET(REWRITER_SRCS) |
86 | |
87 | ADD_SRC_SUBFOLDER(REWRITER_SRCS framework REWRITER_FRAMEWORK_SRCS) |
88 | -ADD_SRC_SUBFOLDER(REWRITER_SRCS rewriters REWRITER_REWRITERS_SRCS) |
89 | ADD_SRC_SUBFOLDER(REWRITER_SRCS rules REWRITER_RULES_SRCS) |
90 | ADD_SRC_SUBFOLDER(REWRITER_SRCS tools REWRITER_TOOLS_SRCS) |
91 | |
92 | === modified file 'src/compiler/rewriter/framework/CMakeLists.txt' |
93 | --- src/compiler/rewriter/framework/CMakeLists.txt 2013-02-07 17:24:36 +0000 |
94 | +++ src/compiler/rewriter/framework/CMakeLists.txt 2013-05-16 10:15:45 +0000 |
95 | @@ -14,4 +14,5 @@ |
96 | SET(REWRITER_FRAMEWORK_SRCS |
97 | rule_driver.cpp |
98 | rewriter_context.cpp |
99 | - sequential_rewriter.cpp) |
100 | + sequential_rewriter.cpp |
101 | + default_optimizer.cpp) |
102 | |
103 | === added file 'src/compiler/rewriter/framework/default_optimizer.cpp' |
104 | --- src/compiler/rewriter/framework/default_optimizer.cpp 1970-01-01 00:00:00 +0000 |
105 | +++ src/compiler/rewriter/framework/default_optimizer.cpp 2013-05-16 10:15:45 +0000 |
106 | @@ -0,0 +1,275 @@ |
107 | +/* |
108 | + * Copyright 2006-2008 The FLWOR Foundation. |
109 | + * |
110 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
111 | + * you may not use this file except in compliance with the License. |
112 | + * You may obtain a copy of the License at |
113 | + * |
114 | + * http://www.apache.org/licenses/LICENSE-2.0 |
115 | + * |
116 | + * Unless required by applicable law or agreed to in writing, software |
117 | + * distributed under the License is distributed on an "AS IS" BASIS, |
118 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
119 | + * See the License for the specific language governing permissions and |
120 | + * limitations under the License. |
121 | + */ |
122 | +#include "stdafx.h" |
123 | + |
124 | +#include "compiler/rewriter/framework/rule_driver.h" |
125 | +#include "compiler/rewriter/framework/default_optimizer.h" |
126 | +#include "compiler/rewriter/rules/ruleset.h" |
127 | +#include "compiler/rewriter/rules/fold_rules.h" |
128 | +#include "compiler/rewriter/rules/index_matching_rule.h" |
129 | +#include "compiler/rewriter/rules/index_join_rule.h" |
130 | +#include "compiler/rewriter/rules/hoist_rules.h" |
131 | +#include "compiler/rewriter/tools/expr_tools.h" |
132 | + |
133 | +#include "compiler/xqddf/value_index.h" |
134 | + |
135 | +#include "compiler/api/compilercb.h" |
136 | + |
137 | +#include "functions/udf.h" |
138 | + |
139 | +#include "system/properties.h" |
140 | + |
141 | +#include "context/static_context.h" |
142 | + |
143 | + |
144 | + |
145 | +namespace zorba |
146 | +{ |
147 | + |
148 | + |
149 | +DefaultOptimizer::DefaultOptimizer() |
150 | +{ |
151 | +} |
152 | + |
153 | + |
154 | +DefaultOptimizer::~DefaultOptimizer() |
155 | +{ |
156 | +} |
157 | + |
158 | + |
159 | +bool DefaultOptimizer::rewrite(RewriterContext& rCtx) |
160 | +{ |
161 | + bool modified = false; |
162 | + |
163 | + SingletonRuleMajorDriver<EliminateTypeEnforcingOperations> driverTypeRules; |
164 | + SingletonRuleMajorDriver<EliminateExtraneousPathSteps> driverPathSimplify; |
165 | + RuleOnceDriver<EliminateUnusedLetVars> driverEliminateVars; |
166 | + RuleOnceDriver<MarkProducerNodeProps> driverMarkProducerNodeProps; |
167 | + RuleOnceDriver<MarkConsumerNodeProps> driverMarkConsumerNodeProps; |
168 | + RuleOnceDriver<EliminateNodeOps> driverEliminateNodeOps; |
169 | + SingletonRuleMajorDriver<SpecializeOperations> driverSpecializeOperations; |
170 | + |
171 | + SingletonRuleMajorDriver<MarkFreeVars> driverMarkFreeVars; |
172 | + FoldRules driverFoldRules; |
173 | + |
174 | + // InlineFunctions |
175 | + |
176 | + if (Properties::instance()->inlineUdf()) |
177 | + { |
178 | + SingletonRuleMajorDriver<InlineFunctions> driverInlineFunctions; |
179 | + if (driverInlineFunctions.rewrite(rCtx)) |
180 | + modified = true; |
181 | + } |
182 | + |
183 | + // PathSimplification |
184 | + if (driverPathSimplify.rewrite(rCtx)) |
185 | + modified = true; |
186 | + |
187 | + if (rCtx.theUDF != NULL) |
188 | + { |
189 | + RuleOnceDriver<MarkExprs> driverMarkLocalExprs; |
190 | + driverMarkLocalExprs.getRule()->setLocal(true); |
191 | + driverMarkLocalExprs.rewrite(rCtx); |
192 | + } |
193 | + |
194 | + repeat1: |
195 | + |
196 | + // TypeRules |
197 | + if (driverTypeRules.rewrite(rCtx)) |
198 | + modified = true; |
199 | + |
200 | + // FoldRules |
201 | + driverFoldRules.rewrite(rCtx); |
202 | + |
203 | + // |
204 | + bool local_modified = false; |
205 | + rCtx.theRoot->compute_return_type(true, &local_modified); |
206 | + if (local_modified) |
207 | + { |
208 | + //std::cout << "TYPES MODIFIED 1 !!!" << std::endl << std::endl; |
209 | + goto repeat1; |
210 | + } |
211 | + |
212 | + /* |
213 | + repeat2: |
214 | + |
215 | + // |
216 | + driverMarkFreeVars.rewrite(rCtx); |
217 | + // |
218 | + driverEliminateVars.rewrite(rCtx); |
219 | + |
220 | + // Recompute static types |
221 | + local_modified = false; |
222 | + rCtx.theRoot->compute_return_type(true, &local_modified); |
223 | + if (local_modified) |
224 | + { |
225 | + //std::cout << "TYPES MODIFIED 2 !!!" << std::endl << std::endl; |
226 | + goto repeat2; |
227 | + } |
228 | + */ |
229 | + |
230 | + // |
231 | + driverMarkProducerNodeProps.rewrite(rCtx); |
232 | + driverEliminateNodeOps.rewrite(rCtx); |
233 | + |
234 | + // |
235 | + driverMarkConsumerNodeProps.rewrite(rCtx); |
236 | + driverEliminateNodeOps.rewrite(rCtx); |
237 | + |
238 | + repeat4: |
239 | + |
240 | + // SpecializeOps |
241 | + driverSpecializeOperations.rewrite(rCtx); |
242 | + |
243 | + // FoldRules |
244 | + driverFoldRules.rewrite(rCtx); |
245 | + |
246 | + // TypeRules |
247 | + driverTypeRules.rewrite(rCtx); |
248 | + |
249 | + // Recompute static types |
250 | + local_modified = false; |
251 | + rCtx.theRoot->compute_return_type(true, &local_modified); |
252 | + if (local_modified) |
253 | + { |
254 | + //std::cout << "TYPES MODIFIED 4 !!!" << std::endl << std::endl; |
255 | + goto repeat4; |
256 | + } |
257 | + |
258 | + // Loop Hoisting |
259 | + if (Properties::instance()->loopHoisting()) |
260 | + { |
261 | + HoistRule rule; |
262 | + bool local_modified = false; |
263 | + |
264 | + expr* e = rule.apply(rCtx, rCtx.getRoot(), local_modified); |
265 | + |
266 | + if (e != rCtx.getRoot()) |
267 | + rCtx.setRoot(e); |
268 | + |
269 | + // Mark exprs again time because hoisting may have created new exprs. |
270 | + if (local_modified) |
271 | + { |
272 | + modified = true; |
273 | + |
274 | + if (Properties::instance()->printIntermediateOpt()) |
275 | + { |
276 | + std::cout << "After hoisting : " << std::endl; |
277 | + rCtx.getRoot()->put(std::cout) << std::endl; |
278 | + } |
279 | + |
280 | + RuleOnceDriver<MarkExprs> driverMarkExpr; |
281 | + driverMarkExpr.rewrite(rCtx); |
282 | + } |
283 | + } |
284 | + |
285 | + // index matching |
286 | + if (Properties::instance()->useIndexes()) |
287 | + { |
288 | + static_context* sctx = rCtx.theRoot->get_sctx(); |
289 | + |
290 | + std::vector<IndexDecl*> indexDecls; |
291 | + sctx->get_index_decls(indexDecls); |
292 | + |
293 | + if (!indexDecls.empty()) |
294 | + { |
295 | + MarkFreeVars freeVarsRule; |
296 | + bool modified; |
297 | + freeVarsRule.apply(rCtx, rCtx.theRoot, modified); |
298 | + } |
299 | + |
300 | + std::vector<IndexDecl*>::const_iterator ite = indexDecls.begin(); |
301 | + std::vector<IndexDecl*>::const_iterator end = indexDecls.end(); |
302 | + for (; ite != end; ++ite) |
303 | + { |
304 | + bool local_modified = false; |
305 | + |
306 | + //store::Index* idx = GENV_STORE.getIndex((*ite)->getName()); |
307 | + |
308 | + //if (idx != NULL) |
309 | + if (!(*ite)->isTemp()) |
310 | + { |
311 | + IndexMatchingRule rule(*ite); |
312 | + |
313 | + expr* e = rule.apply(rCtx, rCtx.getRoot(), local_modified); |
314 | + |
315 | + if (e != rCtx.getRoot()) |
316 | + rCtx.setRoot(e); |
317 | + } |
318 | + |
319 | + if (local_modified) |
320 | + { |
321 | + if (Properties::instance()->printIntermediateOpt()) |
322 | + { |
323 | + std::cout << "After index matching : " << std::endl; |
324 | + rCtx.getRoot()->put(std::cout) << std::endl; |
325 | + } |
326 | + |
327 | + modified = true; |
328 | + } |
329 | + } |
330 | + } |
331 | + |
332 | + // Index Joins |
333 | + if (Properties::instance()->inferJoins()) |
334 | + { |
335 | + bool local_modified = false; |
336 | + |
337 | + IndexJoinRule rule(&rCtx); |
338 | + |
339 | + do |
340 | + { |
341 | + local_modified = false; |
342 | + |
343 | + expr* e = rule.apply(rCtx, rCtx.getRoot(), local_modified); |
344 | + |
345 | + if (e != rCtx.getRoot()) |
346 | + rCtx.setRoot(e); |
347 | + |
348 | + if (local_modified) |
349 | + { |
350 | + modified = true; |
351 | + |
352 | + if (Properties::instance()->printIntermediateOpt()) |
353 | + { |
354 | + std::cout << "After index join : " << std::endl; |
355 | + rCtx.getRoot()->put(std::cout) << std::endl; |
356 | + } |
357 | + |
358 | + // Mark exprs again because index joins may have created new exprs. |
359 | + RuleOnceDriver<MarkExprs> driverMarkExpr; |
360 | + driverMarkExpr.rewrite(rCtx); |
361 | + } |
362 | + } |
363 | + while (local_modified); |
364 | + } |
365 | + |
366 | + // Mark node copy property |
367 | + if (Properties::instance()->noCopyOptim()) |
368 | + { |
369 | + if (rCtx.theUDF == NULL) |
370 | + { |
371 | + RuleOnceDriver<MarkNodeCopyProps> driverMarkNodeCopyProps; |
372 | + driverMarkNodeCopyProps.rewrite(rCtx); |
373 | + } |
374 | + } |
375 | + |
376 | + return modified; |
377 | +} |
378 | + |
379 | + |
380 | +} |
381 | +/* vim:set et sw=2 ts=2: */ |
382 | |
383 | === added file 'src/compiler/rewriter/framework/default_optimizer.h' |
384 | --- src/compiler/rewriter/framework/default_optimizer.h 1970-01-01 00:00:00 +0000 |
385 | +++ src/compiler/rewriter/framework/default_optimizer.h 2013-05-16 10:15:45 +0000 |
386 | @@ -0,0 +1,47 @@ |
387 | +/* |
388 | + * Copyright 2006-2008 The FLWOR Foundation. |
389 | + * |
390 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
391 | + * you may not use this file except in compliance with the License. |
392 | + * You may obtain a copy of the License at |
393 | + * |
394 | + * http://www.apache.org/licenses/LICENSE-2.0 |
395 | + * |
396 | + * Unless required by applicable law or agreed to in writing, software |
397 | + * distributed under the License is distributed on an "AS IS" BASIS, |
398 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
399 | + * See the License for the specific language governing permissions and |
400 | + * limitations under the License. |
401 | + */ |
402 | +#pragma once |
403 | +#ifndef ZORBA_DEFAULT_OPTIMIZER_H |
404 | +#define ZORBA_DEFAULT_OPTIMIZER_H |
405 | + |
406 | +#include "common/shared_types.h" |
407 | +#include "compiler/rewriter/framework/sequential_rewriter.h" |
408 | +#include "compiler/api/compilercb.h" |
409 | + |
410 | +namespace zorba |
411 | +{ |
412 | + |
413 | +class DefaultOptimizer : public SequentialRewriter |
414 | +{ |
415 | +public: |
416 | + DefaultOptimizer(); |
417 | + |
418 | + ~DefaultOptimizer(); |
419 | + |
420 | + bool rewrite(RewriterContext& rCtx); |
421 | +}; |
422 | + |
423 | + |
424 | +} |
425 | + |
426 | +#endif /* ZORBA_DEFAULT_OPTIMIZER_H */ |
427 | + |
428 | +/* |
429 | + * Local variables: |
430 | + * mode: c++ |
431 | + * End: |
432 | + */ |
433 | +/* vim:set et sw=2 ts=2: */ |
434 | |
435 | === modified file 'src/compiler/rewriter/framework/rule_driver.cpp' |
436 | --- src/compiler/rewriter/framework/rule_driver.cpp 2013-02-07 17:24:36 +0000 |
437 | +++ src/compiler/rewriter/framework/rule_driver.cpp 2013-05-16 10:15:45 +0000 |
438 | @@ -52,12 +52,12 @@ |
439 | { |
440 | bool totalModified = false; |
441 | bool modified = false; |
442 | - rules_t::const_iterator end = m_rules.end(); |
443 | + rules_t::const_iterator end = theRules.end(); |
444 | do |
445 | { |
446 | modified = false; |
447 | |
448 | - for (rules_t::iterator i = m_rules.begin(); i != end; ++i) |
449 | + for (rules_t::iterator i = theRules.begin(); i != end; ++i) |
450 | { |
451 | bool rule_modified = false; |
452 | expr* newRoot = (*i)->apply(rCtx, &*rCtx.getRoot(), rule_modified); |
453 | |
454 | === modified file 'src/compiler/rewriter/framework/rule_driver.h' |
455 | --- src/compiler/rewriter/framework/rule_driver.h 2013-02-07 17:24:36 +0000 |
456 | +++ src/compiler/rewriter/framework/rule_driver.h 2013-05-16 10:15:45 +0000 |
457 | @@ -31,6 +31,12 @@ |
458 | typedef rchandle<RewriteRule> rule_ptr_t; |
459 | |
460 | |
461 | +/******************************************************************************* |
462 | + A RuleMajorDriver whose rule set contains a single rule. |
463 | +********************************************************************************/ |
464 | +#define ADD_RULE( rule ) theRules.push_back(rule_ptr_t(new rule)) |
465 | + |
466 | + |
467 | /***************************************************************************//** |
468 | Represents a class of rules that are applied "together". This means that the |
469 | rules that are registered with a RuleMajorDriver R are applied one after the |
470 | @@ -46,7 +52,7 @@ |
471 | typedef std::vector<rule_ptr_t> rules_t; |
472 | |
473 | protected: |
474 | - rules_t m_rules; |
475 | + rules_t theRules; |
476 | |
477 | public: |
478 | RuleMajorDriver(); |
479 | @@ -65,7 +71,7 @@ |
480 | public: |
481 | SingletonRuleMajorDriverBase(rule_ptr_t rule) |
482 | { |
483 | - m_rules.push_back(rule); |
484 | + theRules.push_back(rule); |
485 | } |
486 | }; |
487 | |
488 | |
489 | === modified file 'src/compiler/rewriter/framework/sequential_rewriter.cpp' |
490 | --- src/compiler/rewriter/framework/sequential_rewriter.cpp 2013-02-07 17:24:36 +0000 |
491 | +++ src/compiler/rewriter/framework/sequential_rewriter.cpp 2013-05-16 10:15:45 +0000 |
492 | @@ -35,9 +35,9 @@ |
493 | { |
494 | bool modified = false; |
495 | |
496 | - rewriters_t::const_iterator end = m_childRewriters.end(); |
497 | + rewriters_t::const_iterator end = theChildRewriters.end(); |
498 | |
499 | - for(rewriters_t::const_iterator i = m_childRewriters.begin(); i != end; ++i) |
500 | + for (rewriters_t::const_iterator i = theChildRewriters.begin(); i != end; ++i) |
501 | { |
502 | bool mod = (*i)->rewrite(rCtx); |
503 | |
504 | |
505 | === modified file 'src/compiler/rewriter/framework/sequential_rewriter.h' |
506 | --- src/compiler/rewriter/framework/sequential_rewriter.h 2013-02-07 17:24:36 +0000 |
507 | +++ src/compiler/rewriter/framework/sequential_rewriter.h 2013-05-16 10:15:45 +0000 |
508 | @@ -33,10 +33,11 @@ |
509 | { |
510 | protected: |
511 | typedef rchandle<Rewriter> rewriter_ptr_t; |
512 | + |
513 | typedef std::vector<rewriter_ptr_t> rewriters_t; |
514 | |
515 | protected: |
516 | - rewriters_t m_childRewriters; |
517 | + rewriters_t theChildRewriters; |
518 | |
519 | public: |
520 | virtual bool rewrite(RewriterContext& rCtx); |
521 | @@ -47,6 +48,18 @@ |
522 | ~SequentialRewriter(); |
523 | }; |
524 | |
525 | + |
526 | + |
527 | +#define ADD_DRIVER(d) \ |
528 | +theChildRewriters.push_back(new d) |
529 | + |
530 | +#define ADD_SINGLETON_DRIVER(rule) \ |
531 | +theChildRewriters.push_back(new SingletonRuleMajorDriver<rule>) |
532 | + |
533 | +#define ADD_ONCE_DRIVER(rule) \ |
534 | +theChildRewriters.push_back(new RuleOnceDriver<rule>) |
535 | + |
536 | + |
537 | } |
538 | |
539 | #endif /* ZORBA_SEQUENTIAL_REWRITER_H */ |
540 | |
541 | === removed directory 'src/compiler/rewriter/rewriters' |
542 | === removed file 'src/compiler/rewriter/rewriters/CMakeLists.txt' |
543 | --- src/compiler/rewriter/rewriters/CMakeLists.txt 2013-02-07 17:24:36 +0000 |
544 | +++ src/compiler/rewriter/rewriters/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
545 | @@ -1,16 +0,0 @@ |
546 | -# Copyright 2006-2008 The FLWOR Foundation. |
547 | -# |
548 | -# Licensed under the Apache License, Version 2.0 (the "License"); |
549 | -# you may not use this file except in compliance with the License. |
550 | -# You may obtain a copy of the License at |
551 | -# |
552 | -# http://www.apache.org/licenses/LICENSE-2.0 |
553 | -# |
554 | -# Unless required by applicable law or agreed to in writing, software |
555 | -# distributed under the License is distributed on an "AS IS" BASIS, |
556 | -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
557 | -# See the License for the specific language governing permissions and |
558 | -# limitations under the License. |
559 | -SET(REWRITER_REWRITERS_SRCS |
560 | - default_optimizer.cpp) |
561 | - |
562 | |
563 | === removed file 'src/compiler/rewriter/rewriters/common_rewriter.h' |
564 | --- src/compiler/rewriter/rewriters/common_rewriter.h 2013-02-07 17:24:36 +0000 |
565 | +++ src/compiler/rewriter/rewriters/common_rewriter.h 1970-01-01 00:00:00 +0000 |
566 | @@ -1,33 +0,0 @@ |
567 | -/* |
568 | - * Copyright 2006-2008 The FLWOR Foundation. |
569 | - * |
570 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
571 | - * you may not use this file except in compliance with the License. |
572 | - * You may obtain a copy of the License at |
573 | - * |
574 | - * http://www.apache.org/licenses/LICENSE-2.0 |
575 | - * |
576 | - * Unless required by applicable law or agreed to in writing, software |
577 | - * distributed under the License is distributed on an "AS IS" BASIS, |
578 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
579 | - * See the License for the specific language governing permissions and |
580 | - * limitations under the License. |
581 | - */ |
582 | -#pragma once |
583 | -#ifndef ZORBA_COMMON_REWRITER |
584 | -#define ZORBA_COMMON_REWRITER |
585 | - |
586 | -#define ADD_DRIVER( d ) \ |
587 | -m_childRewriters.push_back(rewriter_ptr_t (new d)) |
588 | - |
589 | -#define ADD_SINGLETON_DRIVER(rule) \ |
590 | -m_childRewriters.push_back(rewriter_ptr_t(new SingletonRuleMajorDriver<rule>)) |
591 | - |
592 | -#define ADD_ONCE_DRIVER(rule) \ |
593 | -m_childRewriters.push_back(rewriter_ptr_t(new RuleOnceDriver<rule>)) |
594 | - |
595 | -#define ADD_RULE( rule ) \ |
596 | -m_rules.push_back (rule_ptr_t (new rule)) |
597 | - |
598 | -#endif /* ZORBA_COMMON_REWRITER */ |
599 | -/* vim:set et sw=2 ts=2: */ |
600 | |
601 | === removed file 'src/compiler/rewriter/rewriters/default_optimizer.cpp' |
602 | --- src/compiler/rewriter/rewriters/default_optimizer.cpp 2013-02-26 03:15:17 +0000 |
603 | +++ src/compiler/rewriter/rewriters/default_optimizer.cpp 1970-01-01 00:00:00 +0000 |
604 | @@ -1,275 +0,0 @@ |
605 | -/* |
606 | - * Copyright 2006-2008 The FLWOR Foundation. |
607 | - * |
608 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
609 | - * you may not use this file except in compliance with the License. |
610 | - * You may obtain a copy of the License at |
611 | - * |
612 | - * http://www.apache.org/licenses/LICENSE-2.0 |
613 | - * |
614 | - * Unless required by applicable law or agreed to in writing, software |
615 | - * distributed under the License is distributed on an "AS IS" BASIS, |
616 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
617 | - * See the License for the specific language governing permissions and |
618 | - * limitations under the License. |
619 | - */ |
620 | -#include "stdafx.h" |
621 | - |
622 | -#include "compiler/rewriter/framework/rule_driver.h" |
623 | -#include "compiler/rewriter/rules/ruleset.h" |
624 | -#include "compiler/rewriter/rules/fold_rules.h" |
625 | -#include "compiler/rewriter/rules/index_matching_rule.h" |
626 | -#include "compiler/rewriter/rules/index_join_rule.h" |
627 | -#include "compiler/rewriter/rewriters/common_rewriter.h" |
628 | -#include "compiler/rewriter/rewriters/default_optimizer.h" |
629 | -#include "compiler/rewriter/tools/expr_tools.h" |
630 | - |
631 | -#include "compiler/xqddf/value_index.h" |
632 | - |
633 | -#include "compiler/api/compilercb.h" |
634 | - |
635 | -#include "functions/udf.h" |
636 | - |
637 | -#include "system/properties.h" |
638 | - |
639 | -#include "context/static_context.h" |
640 | - |
641 | - |
642 | - |
643 | -namespace zorba |
644 | -{ |
645 | - |
646 | - |
647 | -DefaultOptimizer::DefaultOptimizer() |
648 | -{ |
649 | -} |
650 | - |
651 | - |
652 | -DefaultOptimizer::~DefaultOptimizer() |
653 | -{ |
654 | -} |
655 | - |
656 | - |
657 | -bool DefaultOptimizer::rewrite(RewriterContext& rCtx) |
658 | -{ |
659 | - bool modified = false; |
660 | - |
661 | - SingletonRuleMajorDriver<EliminateTypeEnforcingOperations> driverTypeRules; |
662 | - SingletonRuleMajorDriver<EliminateExtraneousPathSteps> driverPathSimplify; |
663 | - RuleOnceDriver<EliminateUnusedLetVars> driverEliminateVars; |
664 | - RuleOnceDriver<MarkProducerNodeProps> driverMarkProducerNodeProps; |
665 | - RuleOnceDriver<MarkConsumerNodeProps> driverMarkConsumerNodeProps; |
666 | - RuleOnceDriver<EliminateNodeOps> driverEliminateNodeOps; |
667 | - SingletonRuleMajorDriver<SpecializeOperations> driverSpecializeOperations; |
668 | - |
669 | - SingletonRuleMajorDriver<MarkFreeVars> driverMarkFreeVars; |
670 | - FoldRules driverFoldRules; |
671 | - |
672 | - // InlineFunctions |
673 | - |
674 | - if (Properties::instance()->inlineUdf()) |
675 | - { |
676 | - SingletonRuleMajorDriver<InlineFunctions> driverInlineFunctions; |
677 | - if (driverInlineFunctions.rewrite(rCtx)) |
678 | - modified = true; |
679 | - } |
680 | - |
681 | - // PathSimplification |
682 | - if (driverPathSimplify.rewrite(rCtx)) |
683 | - modified = true; |
684 | - |
685 | - if (rCtx.theUDF != NULL) |
686 | - { |
687 | - RuleOnceDriver<MarkExprs> driverMarkLocalExprs; |
688 | - driverMarkLocalExprs.getRule()->setLocal(true); |
689 | - driverMarkLocalExprs.rewrite(rCtx); |
690 | - } |
691 | - |
692 | - repeat1: |
693 | - |
694 | - // TypeRules |
695 | - if (driverTypeRules.rewrite(rCtx)) |
696 | - modified = true; |
697 | - |
698 | - // FoldRules |
699 | - driverFoldRules.rewrite(rCtx); |
700 | - |
701 | - // |
702 | - bool local_modified = false; |
703 | - rCtx.theRoot->compute_return_type(true, &local_modified); |
704 | - if (local_modified) |
705 | - { |
706 | - //std::cout << "TYPES MODIFIED 1 !!!" << std::endl << std::endl; |
707 | - goto repeat1; |
708 | - } |
709 | - |
710 | - /* |
711 | - repeat2: |
712 | - |
713 | - // |
714 | - driverMarkFreeVars.rewrite(rCtx); |
715 | - // |
716 | - driverEliminateVars.rewrite(rCtx); |
717 | - |
718 | - // Recompute static types |
719 | - local_modified = false; |
720 | - rCtx.theRoot->compute_return_type(true, &local_modified); |
721 | - if (local_modified) |
722 | - { |
723 | - //std::cout << "TYPES MODIFIED 2 !!!" << std::endl << std::endl; |
724 | - goto repeat2; |
725 | - } |
726 | - */ |
727 | - |
728 | - // |
729 | - driverMarkProducerNodeProps.rewrite(rCtx); |
730 | - driverEliminateNodeOps.rewrite(rCtx); |
731 | - |
732 | - // |
733 | - driverMarkConsumerNodeProps.rewrite(rCtx); |
734 | - driverEliminateNodeOps.rewrite(rCtx); |
735 | - |
736 | - repeat4: |
737 | - |
738 | - // SpecializeOps |
739 | - driverSpecializeOperations.rewrite(rCtx); |
740 | - |
741 | - // FoldRules |
742 | - driverFoldRules.rewrite(rCtx); |
743 | - |
744 | - // TypeRules |
745 | - driverTypeRules.rewrite(rCtx); |
746 | - |
747 | - // Recompute static types |
748 | - local_modified = false; |
749 | - rCtx.theRoot->compute_return_type(true, &local_modified); |
750 | - if (local_modified) |
751 | - { |
752 | - //std::cout << "TYPES MODIFIED 4 !!!" << std::endl << std::endl; |
753 | - goto repeat4; |
754 | - } |
755 | - |
756 | - // Loop Hoisting |
757 | - if (Properties::instance()->loopHoisting()) |
758 | - { |
759 | - HoistRule rule; |
760 | - bool local_modified = false; |
761 | - |
762 | - expr* e = rule.apply(rCtx, rCtx.getRoot(), local_modified); |
763 | - |
764 | - if (e != rCtx.getRoot()) |
765 | - rCtx.setRoot(e); |
766 | - |
767 | - // Mark exprs again time because hoisting may have created new exprs. |
768 | - if (local_modified) |
769 | - { |
770 | - modified = true; |
771 | - |
772 | - if (Properties::instance()->printIntermediateOpt()) |
773 | - { |
774 | - std::cout << "After hoisting : " << std::endl; |
775 | - rCtx.getRoot()->put(std::cout) << std::endl; |
776 | - } |
777 | - |
778 | - RuleOnceDriver<MarkExprs> driverMarkExpr; |
779 | - driverMarkExpr.rewrite(rCtx); |
780 | - } |
781 | - } |
782 | - |
783 | - // index matching |
784 | - if (Properties::instance()->useIndexes()) |
785 | - { |
786 | - static_context* sctx = rCtx.theRoot->get_sctx(); |
787 | - |
788 | - std::vector<IndexDecl*> indexDecls; |
789 | - sctx->get_index_decls(indexDecls); |
790 | - |
791 | - if (!indexDecls.empty()) |
792 | - { |
793 | - MarkFreeVars freeVarsRule; |
794 | - bool modified; |
795 | - freeVarsRule.apply(rCtx, rCtx.theRoot, modified); |
796 | - } |
797 | - |
798 | - std::vector<IndexDecl*>::const_iterator ite = indexDecls.begin(); |
799 | - std::vector<IndexDecl*>::const_iterator end = indexDecls.end(); |
800 | - for (; ite != end; ++ite) |
801 | - { |
802 | - bool local_modified = false; |
803 | - |
804 | - //store::Index* idx = GENV_STORE.getIndex((*ite)->getName()); |
805 | - |
806 | - //if (idx != NULL) |
807 | - if (!(*ite)->isTemp()) |
808 | - { |
809 | - IndexMatchingRule rule(*ite); |
810 | - |
811 | - expr* e = rule.apply(rCtx, rCtx.getRoot(), local_modified); |
812 | - |
813 | - if (e != rCtx.getRoot()) |
814 | - rCtx.setRoot(e); |
815 | - } |
816 | - |
817 | - if (local_modified) |
818 | - { |
819 | - if (Properties::instance()->printIntermediateOpt()) |
820 | - { |
821 | - std::cout << "After index matching : " << std::endl; |
822 | - rCtx.getRoot()->put(std::cout) << std::endl; |
823 | - } |
824 | - |
825 | - modified = true; |
826 | - } |
827 | - } |
828 | - } |
829 | - |
830 | - // Index Joins |
831 | - if (Properties::instance()->inferJoins()) |
832 | - { |
833 | - bool local_modified = false; |
834 | - |
835 | - IndexJoinRule rule(&rCtx); |
836 | - |
837 | - do |
838 | - { |
839 | - local_modified = false; |
840 | - |
841 | - expr* e = rule.apply(rCtx, rCtx.getRoot(), local_modified); |
842 | - |
843 | - if (e != rCtx.getRoot()) |
844 | - rCtx.setRoot(e); |
845 | - |
846 | - if (local_modified) |
847 | - { |
848 | - modified = true; |
849 | - |
850 | - if (Properties::instance()->printIntermediateOpt()) |
851 | - { |
852 | - std::cout << "After index join : " << std::endl; |
853 | - rCtx.getRoot()->put(std::cout) << std::endl; |
854 | - } |
855 | - |
856 | - // Mark exprs again because index joins may have created new exprs. |
857 | - RuleOnceDriver<MarkExprs> driverMarkExpr; |
858 | - driverMarkExpr.rewrite(rCtx); |
859 | - } |
860 | - } |
861 | - while (local_modified); |
862 | - } |
863 | - |
864 | - // Mark node copy property |
865 | - if (Properties::instance()->noCopyOptim()) |
866 | - { |
867 | - if (rCtx.theUDF == NULL) |
868 | - { |
869 | - RuleOnceDriver<MarkNodeCopyProps> driverMarkNodeCopyProps; |
870 | - driverMarkNodeCopyProps.rewrite(rCtx); |
871 | - } |
872 | - } |
873 | - |
874 | - return modified; |
875 | -} |
876 | - |
877 | - |
878 | -} |
879 | -/* vim:set et sw=2 ts=2: */ |
880 | |
881 | === removed file 'src/compiler/rewriter/rewriters/default_optimizer.h' |
882 | --- src/compiler/rewriter/rewriters/default_optimizer.h 2013-02-07 17:24:36 +0000 |
883 | +++ src/compiler/rewriter/rewriters/default_optimizer.h 1970-01-01 00:00:00 +0000 |
884 | @@ -1,47 +0,0 @@ |
885 | -/* |
886 | - * Copyright 2006-2008 The FLWOR Foundation. |
887 | - * |
888 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
889 | - * you may not use this file except in compliance with the License. |
890 | - * You may obtain a copy of the License at |
891 | - * |
892 | - * http://www.apache.org/licenses/LICENSE-2.0 |
893 | - * |
894 | - * Unless required by applicable law or agreed to in writing, software |
895 | - * distributed under the License is distributed on an "AS IS" BASIS, |
896 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
897 | - * See the License for the specific language governing permissions and |
898 | - * limitations under the License. |
899 | - */ |
900 | -#pragma once |
901 | -#ifndef ZORBA_DEFAULT_OPTIMIZER_H |
902 | -#define ZORBA_DEFAULT_OPTIMIZER_H |
903 | - |
904 | -#include "common/shared_types.h" |
905 | -#include "compiler/rewriter/framework/sequential_rewriter.h" |
906 | -#include "compiler/api/compilercb.h" |
907 | - |
908 | -namespace zorba |
909 | -{ |
910 | - |
911 | -class DefaultOptimizer : public SequentialRewriter |
912 | -{ |
913 | -public: |
914 | - DefaultOptimizer(); |
915 | - |
916 | - ~DefaultOptimizer(); |
917 | - |
918 | - bool rewrite(RewriterContext& rCtx); |
919 | -}; |
920 | - |
921 | - |
922 | -} |
923 | - |
924 | -#endif /* ZORBA_DEFAULT_OPTIMIZER_H */ |
925 | - |
926 | -/* |
927 | - * Local variables: |
928 | - * mode: c++ |
929 | - * End: |
930 | - */ |
931 | -/* vim:set et sw=2 ts=2: */ |
932 | |
933 | === removed file 'src/compiler/rewriter/rewriters/phase1_rewriter.cpp' |
934 | --- src/compiler/rewriter/rewriters/phase1_rewriter.cpp 2013-02-07 17:24:36 +0000 |
935 | +++ src/compiler/rewriter/rewriters/phase1_rewriter.cpp 1970-01-01 00:00:00 +0000 |
936 | @@ -1,33 +0,0 @@ |
937 | -/* |
938 | - * Copyright 2006-2008 The FLWOR Foundation. |
939 | - * |
940 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
941 | - * you may not use this file except in compliance with the License. |
942 | - * You may obtain a copy of the License at |
943 | - * |
944 | - * http://www.apache.org/licenses/LICENSE-2.0 |
945 | - * |
946 | - * Unless required by applicable law or agreed to in writing, software |
947 | - * distributed under the License is distributed on an "AS IS" BASIS, |
948 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
949 | - * See the License for the specific language governing permissions and |
950 | - * limitations under the License. |
951 | - */ |
952 | -#include "compiler/rewriter/framework/rule_driver.h" |
953 | -#include "compiler/rewriter/rules/ruleset.h" |
954 | -#include "compiler/rewriter/rewriters/common_rewriter.h" |
955 | -#include "compiler/rewriter/rewriters/phase1_rewriter.h" |
956 | - |
957 | -namespace zorba { |
958 | - |
959 | -Phase1Rewriter::Phase1Rewriter() |
960 | -{ |
961 | - ADD_SINGLETON_DRIVER(ExpandBuildIndex); |
962 | -} |
963 | - |
964 | -Phase1Rewriter::~Phase1Rewriter() |
965 | -{ |
966 | -} |
967 | - |
968 | -} |
969 | -/* vim:set et sw=2 ts=2: */ |
970 | |
971 | === removed file 'src/compiler/rewriter/rewriters/phase1_rewriter.h' |
972 | --- src/compiler/rewriter/rewriters/phase1_rewriter.h 2013-02-07 17:24:36 +0000 |
973 | +++ src/compiler/rewriter/rewriters/phase1_rewriter.h 1970-01-01 00:00:00 +0000 |
974 | @@ -1,42 +0,0 @@ |
975 | -/* |
976 | - * Copyright 2006-2008 The FLWOR Foundation. |
977 | - * |
978 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
979 | - * you may not use this file except in compliance with the License. |
980 | - * You may obtain a copy of the License at |
981 | - * |
982 | - * http://www.apache.org/licenses/LICENSE-2.0 |
983 | - * |
984 | - * Unless required by applicable law or agreed to in writing, software |
985 | - * distributed under the License is distributed on an "AS IS" BASIS, |
986 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
987 | - * See the License for the specific language governing permissions and |
988 | - * limitations under the License. |
989 | - */ |
990 | -#pragma once |
991 | -#ifndef ZORBA_PHASE1_REWRITER_H |
992 | -#define ZORBA_PHASE1_REWRITER_H |
993 | - |
994 | -#include "common/shared_types.h" |
995 | -#include "compiler/rewriter/framework/sequential_rewriter.h" |
996 | - |
997 | -namespace zorba { |
998 | - |
999 | -class Phase1Rewriter : public SequentialRewriter |
1000 | -{ |
1001 | -public: |
1002 | - Phase1Rewriter(); |
1003 | - ~Phase1Rewriter(); |
1004 | -}; |
1005 | - |
1006 | -} |
1007 | - |
1008 | -#endif /* ZORBA_PHASE1_REWRITER_H */ |
1009 | - |
1010 | - |
1011 | -/* |
1012 | - * Local variables: |
1013 | - * mode: c++ |
1014 | - * End: |
1015 | - */ |
1016 | -/* vim:set et sw=2 ts=2: */ |
1017 | |
1018 | === modified file 'src/compiler/rewriter/rules/fold_rules.h' |
1019 | --- src/compiler/rewriter/rules/fold_rules.h 2012-12-14 18:01:41 +0000 |
1020 | +++ src/compiler/rewriter/rules/fold_rules.h 2013-05-16 10:15:45 +0000 |
1021 | @@ -20,7 +20,6 @@ |
1022 | #include "stdafx.h" |
1023 | |
1024 | #include "compiler/rewriter/framework/rule_driver.h" |
1025 | -#include "compiler/rewriter/rewriters/common_rewriter.h" |
1026 | #include "compiler/rewriter/rules/ruleset.h" |
1027 | |
1028 | |
1029 | |
1030 | === modified file 'src/compiler/rewriter/rules/hoist_rules.cpp' |
1031 | --- src/compiler/rewriter/rules/hoist_rules.cpp 2013-03-04 21:00:58 +0000 |
1032 | +++ src/compiler/rewriter/rules/hoist_rules.cpp 2013-05-16 10:15:45 +0000 |
1033 | @@ -22,8 +22,7 @@ |
1034 | #include "functions/library.h" |
1035 | #include "functions/udf.h" |
1036 | |
1037 | -#include "compiler/rewriter/rules/ruleset.h" |
1038 | -#include "compiler/rewriter/tools/expr_tools.h" |
1039 | +#include "compiler/rewriter/rules/hoist_rules.h" |
1040 | #include "compiler/expression/flwor_expr.h" |
1041 | #include "compiler/expression/expr.h" |
1042 | #include "compiler/expression/expr_iter.h" |
1043 | @@ -38,29 +37,11 @@ |
1044 | namespace zorba |
1045 | { |
1046 | |
1047 | -static bool hoist_expressions( |
1048 | - RewriterContext&, |
1049 | - expr*, |
1050 | - const expr_tools::VarIdMap&, |
1051 | - const expr_tools::ExprVarsMap&, |
1052 | - struct PathHolder*); |
1053 | - |
1054 | -static expr* try_hoisting( |
1055 | - RewriterContext&, |
1056 | - expr*, |
1057 | - const expr_tools::VarIdMap&, |
1058 | - const expr_tools::ExprVarsMap&, |
1059 | - struct PathHolder*); |
1060 | - |
1061 | -static bool non_hoistable (const expr*); |
1062 | + |
1063 | +static bool non_hoistable(const expr*); |
1064 | |
1065 | static bool is_already_hoisted(const expr*); |
1066 | |
1067 | -static bool contains_var( |
1068 | - var_expr*, |
1069 | - const expr_tools::VarIdMap&, |
1070 | - const DynamicBitset&); |
1071 | - |
1072 | static bool is_enclosed_expr(const expr*); |
1073 | |
1074 | static bool containsUpdates(const expr*); |
1075 | @@ -77,11 +58,7 @@ |
1076 | expr * theExpr; |
1077 | long clauseCount; |
1078 | |
1079 | - PathHolder() |
1080 | - : |
1081 | - prev(NULL), |
1082 | - theExpr(NULL), |
1083 | - clauseCount(0) |
1084 | + PathHolder() : prev(NULL), theExpr(NULL), clauseCount(0) |
1085 | { |
1086 | } |
1087 | }; |
1088 | @@ -99,9 +76,10 @@ |
1089 | assert(node == rCtx.getRoot()); |
1090 | |
1091 | csize numVars = 0; |
1092 | - expr_tools::VarIdMap varmap; |
1093 | + theVarIdMap.clear(); |
1094 | + theExprVarsMap.clear(); |
1095 | |
1096 | - expr_tools::index_flwor_vars(node, numVars, varmap, NULL); |
1097 | + expr_tools::index_flwor_vars(node, numVars, theVarIdMap, NULL); |
1098 | |
1099 | /* |
1100 | expr_tools::VarIdMap::const_iterator ite = varmap.begin(); |
1101 | @@ -112,12 +90,11 @@ |
1102 | } |
1103 | */ |
1104 | |
1105 | - expr_tools::ExprVarsMap freevarMap; |
1106 | DynamicBitset freeset(numVars+1); |
1107 | - expr_tools::build_expr_to_vars_map(node, varmap, freeset, freevarMap); |
1108 | + expr_tools::build_expr_to_vars_map(node, theVarIdMap, freeset, theExprVarsMap); |
1109 | |
1110 | PathHolder root; |
1111 | - modified = hoist_expressions(rCtx, node, varmap, freevarMap, &root); |
1112 | + modified = hoistChildren(rCtx, node, &root); |
1113 | |
1114 | if (modified && root.theExpr != NULL) |
1115 | { |
1116 | @@ -134,16 +111,12 @@ |
1117 | /******************************************************************************* |
1118 | Try to hoist the children of the given expr "e". |
1119 | ********************************************************************************/ |
1120 | -static bool hoist_expressions( |
1121 | - RewriterContext& rCtx, |
1122 | - expr* e, |
1123 | - const expr_tools::VarIdMap& varmap, |
1124 | - const expr_tools::ExprVarsMap& freevarMap, |
1125 | - struct PathHolder* path) |
1126 | +bool HoistRule::hoistChildren(RewriterContext& rCtx, expr* e, PathHolder* path) |
1127 | { |
1128 | bool status = false; |
1129 | |
1130 | - if (e->get_expr_kind() == flwor_expr_kind) |
1131 | + if (e->get_expr_kind() == flwor_expr_kind || |
1132 | + e->get_expr_kind() == gflwor_expr_kind) |
1133 | { |
1134 | flwor_expr* flwor = static_cast<flwor_expr *>(e); |
1135 | |
1136 | @@ -151,85 +124,240 @@ |
1137 | step.prev = path; |
1138 | step.theExpr = e; |
1139 | |
1140 | - csize numForLetClauses = flwor->num_forlet_clauses(); |
1141 | + csize numClauses = flwor->num_clauses(); |
1142 | csize i = 0; |
1143 | |
1144 | - while (i < numForLetClauses) |
1145 | + while (i < numClauses) |
1146 | { |
1147 | - forletwin_clause* flc = static_cast<forletwin_clause*>(flwor->get_clause(i)); |
1148 | - expr* domainExpr = flc->get_expr(); |
1149 | - |
1150 | - expr* unhoistExpr = |
1151 | - try_hoisting(rCtx, domainExpr, varmap, freevarMap, &step); |
1152 | - |
1153 | - if (unhoistExpr != NULL) |
1154 | - { |
1155 | - flc->set_expr(unhoistExpr); |
1156 | - status = true; |
1157 | - numForLetClauses = flwor->num_forlet_clauses(); |
1158 | - // TODO: the expr that was just hoisted here, may contain sub-exprs that |
1159 | - // can be hoisted even earlier. |
1160 | - } |
1161 | - else if (domainExpr->is_sequential()) |
1162 | - { |
1163 | - PathHolder root; |
1164 | - |
1165 | - bool hoisted = |
1166 | - hoist_expressions(rCtx, domainExpr, varmap, freevarMap, &root); |
1167 | - |
1168 | - if (hoisted) |
1169 | - { |
1170 | - if (root.theExpr != NULL) |
1171 | - { |
1172 | - assert(root.theExpr->get_expr_kind() == flwor_expr_kind); |
1173 | - |
1174 | - static_cast<flwor_expr*>(root.theExpr)->set_return_expr(domainExpr); |
1175 | - flc->set_expr(root.theExpr); |
1176 | - } |
1177 | - |
1178 | - status = true; |
1179 | - assert(numForLetClauses == flwor->num_forlet_clauses()); |
1180 | - } |
1181 | - } |
1182 | - else |
1183 | - { |
1184 | - bool hoisted = |
1185 | - hoist_expressions(rCtx, domainExpr, varmap, freevarMap, &step); |
1186 | - |
1187 | - if (hoisted) |
1188 | - { |
1189 | - status = true; |
1190 | - numForLetClauses = flwor->num_forlet_clauses(); |
1191 | - } |
1192 | + flwor_clause* c = flwor->get_clause(i); |
1193 | + |
1194 | + switch (c->get_kind()) |
1195 | + { |
1196 | + case flwor_clause::for_clause: |
1197 | + case flwor_clause::let_clause: |
1198 | + case flwor_clause::window_clause: |
1199 | + { |
1200 | + forletwin_clause* flwc = static_cast<forletwin_clause*>(c); |
1201 | + expr* domainExpr = flwc->get_expr(); |
1202 | + |
1203 | + expr* unhoistExpr = hoistExpr(rCtx, domainExpr, &step); |
1204 | + |
1205 | + if (unhoistExpr != NULL) |
1206 | + { |
1207 | + flwc->set_expr(unhoistExpr); |
1208 | + status = true; |
1209 | + numClauses = flwor->num_clauses(); |
1210 | + // TODO: the expr that was just hoisted here, may contain sub-exprs that |
1211 | + // can be hoisted even earlier. |
1212 | + } |
1213 | + else if (domainExpr->is_sequential()) |
1214 | + { |
1215 | + PathHolder root; |
1216 | + |
1217 | + bool hoisted = hoistChildren(rCtx, domainExpr, &root); |
1218 | + |
1219 | + if (hoisted) |
1220 | + { |
1221 | + if (root.theExpr != NULL) |
1222 | + { |
1223 | + assert(root.theExpr->get_expr_kind() == flwor_expr_kind); |
1224 | + |
1225 | + static_cast<flwor_expr*>(root.theExpr)->set_return_expr(domainExpr); |
1226 | + flwc->set_expr(root.theExpr); |
1227 | + } |
1228 | + |
1229 | + status = true; |
1230 | + assert(numClauses == flwor->num_clauses()); |
1231 | + } |
1232 | + } |
1233 | + else if (hoistChildren(rCtx, domainExpr, &step)) |
1234 | + { |
1235 | + status = true; |
1236 | + numClauses = flwor->num_clauses(); |
1237 | + } |
1238 | + |
1239 | + if (c->get_kind() == flwor_clause::window_clause) |
1240 | + { |
1241 | + window_clause* wc = static_cast<window_clause*>(c); |
1242 | + flwor_wincond* startCond = wc->get_win_start(); |
1243 | + flwor_wincond* stopCond = wc->get_win_stop(); |
1244 | + |
1245 | + if (startCond) |
1246 | + { |
1247 | + expr* condExpr = startCond->get_expr(); |
1248 | + |
1249 | + ZORBA_ASSERT(!condExpr->is_sequential()); |
1250 | + |
1251 | + ++step.clauseCount; |
1252 | + |
1253 | + expr* unhoistExpr = hoistExpr(rCtx, condExpr, &step); |
1254 | + |
1255 | + if (unhoistExpr != NULL) |
1256 | + { |
1257 | + startCond->set_expr(unhoistExpr); |
1258 | + status = true; |
1259 | + numClauses = flwor->num_clauses(); |
1260 | + } |
1261 | + else if (hoistChildren(rCtx, condExpr, &step)) |
1262 | + { |
1263 | + status = true; |
1264 | + numClauses = flwor->num_clauses(); |
1265 | + } |
1266 | + |
1267 | + --step.clauseCount; |
1268 | + } |
1269 | + |
1270 | + if (stopCond) |
1271 | + { |
1272 | + expr* condExpr = stopCond->get_expr(); |
1273 | + |
1274 | + ZORBA_ASSERT(!condExpr->is_sequential()); |
1275 | + |
1276 | + ++step.clauseCount; |
1277 | + |
1278 | + expr* unhoistExpr = hoistExpr(rCtx, condExpr, &step); |
1279 | + |
1280 | + if (unhoistExpr != NULL) |
1281 | + { |
1282 | + stopCond->set_expr(unhoistExpr); |
1283 | + status = true; |
1284 | + numClauses = flwor->num_clauses(); |
1285 | + } |
1286 | + else if (hoistChildren(rCtx, condExpr, &step)) |
1287 | + { |
1288 | + status = true; |
1289 | + numClauses = flwor->num_clauses(); |
1290 | + } |
1291 | + |
1292 | + --step.clauseCount; |
1293 | + } |
1294 | + } |
1295 | + |
1296 | + break; |
1297 | + } |
1298 | + case flwor_clause::where_clause: |
1299 | + { |
1300 | + where_clause* wc = static_cast<where_clause*>(c); |
1301 | + expr* we = wc->get_expr(); |
1302 | + |
1303 | + ZORBA_ASSERT(!we->is_sequential()); |
1304 | + |
1305 | + expr* unhoistExpr = hoistExpr(rCtx, we, &step); |
1306 | + |
1307 | + if (unhoistExpr != NULL) |
1308 | + { |
1309 | + wc->set_expr(unhoistExpr); |
1310 | + status = true; |
1311 | + numClauses = flwor->num_clauses(); |
1312 | + } |
1313 | + else if (hoistChildren(rCtx, we, &step)) |
1314 | + { |
1315 | + status = true; |
1316 | + numClauses = flwor->num_clauses(); |
1317 | + } |
1318 | + |
1319 | + break; |
1320 | + } |
1321 | + case flwor_clause::orderby_clause: |
1322 | + { |
1323 | + orderby_clause* oc = static_cast<orderby_clause*>(c); |
1324 | + |
1325 | + std::vector<expr*>::const_iterator ite = oc->begin(); |
1326 | + std::vector<expr*>::const_iterator end = oc->end(); |
1327 | + for (; ite != end; ++ite) |
1328 | + { |
1329 | + expr* oe = *ite; |
1330 | + |
1331 | + ZORBA_ASSERT(!oe->is_sequential()); |
1332 | + |
1333 | + expr* unhoistExpr = hoistExpr(rCtx, oe, &step); |
1334 | + |
1335 | + if (unhoistExpr != NULL) |
1336 | + { |
1337 | + oc->set_column_expr(ite - oc->begin(), unhoistExpr); |
1338 | + status = true; |
1339 | + numClauses = flwor->num_clauses(); |
1340 | + } |
1341 | + else if (hoistChildren(rCtx, oe, &step)) |
1342 | + { |
1343 | + status = true; |
1344 | + numClauses = flwor->num_clauses(); |
1345 | + } |
1346 | + } |
1347 | + |
1348 | + break; |
1349 | + } |
1350 | + case flwor_clause::groupby_clause: |
1351 | + { |
1352 | + groupby_clause* gc = static_cast<groupby_clause*>(c); |
1353 | + |
1354 | + var_rebind_list_t::iterator ite = gc->beginGroupVars(); |
1355 | + var_rebind_list_t::iterator end = gc->endGroupVars(); |
1356 | + for (; ite != end; ++ite) |
1357 | + { |
1358 | + expr* ge = (*ite).first; |
1359 | + |
1360 | + ZORBA_ASSERT(!ge->is_sequential()); |
1361 | + |
1362 | + expr* unhoistExpr = hoistExpr(rCtx, ge, &step); |
1363 | + |
1364 | + if (unhoistExpr != NULL) |
1365 | + { |
1366 | + (*ite).first = unhoistExpr; |
1367 | + status = true; |
1368 | + numClauses = flwor->num_clauses(); |
1369 | + } |
1370 | + else if (hoistChildren(rCtx, ge, &step)) |
1371 | + { |
1372 | + status = true; |
1373 | + numClauses = flwor->num_clauses(); |
1374 | + } |
1375 | + } |
1376 | + |
1377 | + ite = gc->beginNonGroupVars(); |
1378 | + end = gc->endNonGroupVars(); |
1379 | + for (; ite != end; ++ite) |
1380 | + { |
1381 | + expr* ge = (*ite).first; |
1382 | + |
1383 | + ZORBA_ASSERT(!ge->is_sequential()); |
1384 | + |
1385 | + expr* unhoistExpr = hoistExpr(rCtx, ge, &step); |
1386 | + |
1387 | + if (unhoistExpr != NULL) |
1388 | + { |
1389 | + (*ite).first = unhoistExpr; |
1390 | + status = true; |
1391 | + numClauses = flwor->num_clauses(); |
1392 | + } |
1393 | + else if (hoistChildren(rCtx, ge, &step)) |
1394 | + { |
1395 | + status = true; |
1396 | + numClauses = flwor->num_clauses(); |
1397 | + } |
1398 | + } |
1399 | + |
1400 | + break; |
1401 | + } |
1402 | + case flwor_clause::count_clause: |
1403 | + { |
1404 | + break; |
1405 | + } |
1406 | + case flwor_clause::materialize_clause: |
1407 | + { |
1408 | + break; |
1409 | + } |
1410 | + default: |
1411 | + ZORBA_ASSERT(false); |
1412 | } |
1413 | |
1414 | i = ++(step.clauseCount); |
1415 | |
1416 | - assert(numForLetClauses == flwor->num_forlet_clauses()); |
1417 | - } |
1418 | - |
1419 | - expr* we = flwor->get_where(); |
1420 | - if (we != NULL) |
1421 | - { |
1422 | - ZORBA_ASSERT(!we->is_sequential()); |
1423 | - |
1424 | - expr* unhoistExpr = try_hoisting(rCtx, we, varmap, freevarMap, &step); |
1425 | - |
1426 | - if (unhoistExpr != NULL) |
1427 | - { |
1428 | - flwor->set_where(unhoistExpr); |
1429 | - status = true; |
1430 | - } |
1431 | - else |
1432 | - { |
1433 | - status = hoist_expressions(rCtx, we, varmap, freevarMap, &step) || status; |
1434 | - } |
1435 | - } |
1436 | - |
1437 | - // TODO: hoist orderby exprs |
1438 | + assert(numClauses == flwor->num_clauses()); |
1439 | + } |
1440 | |
1441 | expr* re = flwor->get_return_expr(); |
1442 | - expr* unhoistExpr = try_hoisting(rCtx, re, varmap, freevarMap, &step); |
1443 | + expr* unhoistExpr = hoistExpr(rCtx, re, &step); |
1444 | |
1445 | if (unhoistExpr != NULL) |
1446 | { |
1447 | @@ -239,7 +367,7 @@ |
1448 | else if (re->is_sequential()) |
1449 | { |
1450 | PathHolder root; |
1451 | - bool nestedModified = hoist_expressions(rCtx, re, varmap, freevarMap, &root); |
1452 | + bool nestedModified = hoistChildren(rCtx, re, &root); |
1453 | |
1454 | if (nestedModified && root.theExpr != NULL) |
1455 | { |
1456 | @@ -253,36 +381,7 @@ |
1457 | } |
1458 | else |
1459 | { |
1460 | - status = hoist_expressions(rCtx, re, varmap, freevarMap, &step) || status; |
1461 | - } |
1462 | - } |
1463 | - |
1464 | - else if (e->get_expr_kind() == trycatch_expr_kind) |
1465 | - { |
1466 | - PathHolder step; |
1467 | - step.prev = path; |
1468 | - step.theExpr = e; |
1469 | - |
1470 | - ExprIterator iter(e); |
1471 | - |
1472 | - while(!iter.done()) |
1473 | - { |
1474 | - expr* ce = **iter; |
1475 | - if (ce) |
1476 | - { |
1477 | - expr* unhoistExpr = try_hoisting(rCtx, ce, varmap, freevarMap, &step); |
1478 | - if (unhoistExpr != NULL) |
1479 | - { |
1480 | - **iter = unhoistExpr; |
1481 | - status = true; |
1482 | - } |
1483 | - else |
1484 | - { |
1485 | - status = hoist_expressions(rCtx, ce, varmap, freevarMap, &step) || status; |
1486 | - } |
1487 | - } |
1488 | - |
1489 | - iter.next(); |
1490 | + status = hoistChildren(rCtx, re, &step) || status; |
1491 | } |
1492 | } |
1493 | |
1494 | @@ -298,7 +397,7 @@ |
1495 | expr* ce = **iter; |
1496 | |
1497 | PathHolder root; |
1498 | - bool nestedModified = hoist_expressions(rCtx, ce, varmap, freevarMap, &root); |
1499 | + bool nestedModified = hoistChildren(rCtx, ce, &root); |
1500 | |
1501 | if (nestedModified && root.theExpr != NULL) |
1502 | { |
1503 | @@ -314,23 +413,29 @@ |
1504 | } |
1505 | } |
1506 | |
1507 | - else if (e->is_updating() || |
1508 | - e->get_expr_kind() == gflwor_expr_kind || |
1509 | - e->get_expr_kind() == transform_expr_kind) |
1510 | + else if (e->is_updating() || e->get_expr_kind() == transform_expr_kind) |
1511 | { |
1512 | // do nothing |
1513 | } |
1514 | |
1515 | else |
1516 | { |
1517 | + if (e->get_expr_kind() == trycatch_expr_kind) |
1518 | + { |
1519 | + PathHolder step; |
1520 | + step.prev = path; |
1521 | + step.theExpr = e; |
1522 | + path = &step; |
1523 | + } |
1524 | + |
1525 | ExprIterator iter(e); |
1526 | |
1527 | - while(!iter.done()) |
1528 | + while (!iter.done()) |
1529 | { |
1530 | expr* ce = **iter; |
1531 | if (ce) |
1532 | { |
1533 | - expr* unhoistExpr = try_hoisting(rCtx, ce, varmap, freevarMap, path); |
1534 | + expr* unhoistExpr = hoistExpr(rCtx, ce, path); |
1535 | if (unhoistExpr != NULL) |
1536 | { |
1537 | **iter = unhoistExpr; |
1538 | @@ -338,7 +443,7 @@ |
1539 | } |
1540 | else |
1541 | { |
1542 | - status = hoist_expressions(rCtx, ce, varmap, freevarMap, path) || status; |
1543 | + status = hoistChildren(rCtx, ce, path) || status; |
1544 | } |
1545 | } |
1546 | |
1547 | @@ -355,11 +460,9 @@ |
1548 | flwor expr inside the stack of flwor exprs that is accessible via the "holder" |
1549 | param. |
1550 | ********************************************************************************/ |
1551 | -static expr* try_hoisting( |
1552 | +expr* HoistRule::hoistExpr( |
1553 | RewriterContext& rCtx, |
1554 | expr* e, |
1555 | - const expr_tools::VarIdMap& varmap, |
1556 | - const expr_tools::ExprVarsMap& freevarMap, |
1557 | struct PathHolder* path) |
1558 | { |
1559 | if (non_hoistable(e) || e->constructsNodes()) |
1560 | @@ -373,11 +476,12 @@ |
1561 | |
1562 | assert(udf == rCtx.theUDF); |
1563 | |
1564 | - expr_tools::ExprVarsMap::const_iterator fvme = freevarMap.find(e); |
1565 | - ZORBA_ASSERT(fvme != freevarMap.end()); |
1566 | + expr_tools::ExprVarsMap::const_iterator fvme = theExprVarsMap.find(e); |
1567 | + ZORBA_ASSERT(fvme != theExprVarsMap.end()); |
1568 | const DynamicBitset& varset = fvme->second; |
1569 | |
1570 | PathHolder* step = path; |
1571 | + PathHolder* nextstep = NULL; |
1572 | |
1573 | bool inloop = false; |
1574 | bool foundReferencedFLWORVar = false; |
1575 | @@ -407,39 +511,17 @@ |
1576 | { |
1577 | var_expr* trycatchVar = (*ite).second; |
1578 | |
1579 | - if (contains_var(trycatchVar, varmap, varset)) |
1580 | + if (contains_var(trycatchVar, varset)) |
1581 | return NULL; |
1582 | } |
1583 | } |
1584 | } |
1585 | else |
1586 | { |
1587 | - assert(step->theExpr->get_expr_kind() == flwor_expr_kind); |
1588 | + assert(step->theExpr->get_expr_kind() == flwor_expr_kind || |
1589 | + step->theExpr->get_expr_kind() == gflwor_expr_kind); |
1590 | |
1591 | flwor_expr* flwor = static_cast<flwor_expr*>(step->theExpr); |
1592 | - groupby_clause* gc = flwor->get_group_clause(); |
1593 | - |
1594 | - // If any free variable is a group-by variable, give up. |
1595 | - if (gc != NULL) |
1596 | - { |
1597 | - const flwor_clause::rebind_list_t& gvars = gc->get_grouping_vars(); |
1598 | - csize numGroupVars = gvars.size(); |
1599 | - |
1600 | - for (csize i = 0; i < numGroupVars; ++i) |
1601 | - { |
1602 | - if (contains_var(gvars[i].second, varmap, varset)) |
1603 | - return NULL; |
1604 | - } |
1605 | - |
1606 | - const flwor_clause::rebind_list_t& ngvars = gc->get_nongrouping_vars(); |
1607 | - csize numNonGroupVars = ngvars.size(); |
1608 | - |
1609 | - for (csize i = 0; i < numNonGroupVars; ++i) |
1610 | - { |
1611 | - if (contains_var(ngvars[i].second, varmap, varset)) |
1612 | - return NULL; |
1613 | - } |
1614 | - } |
1615 | |
1616 | // Check whether expr e references any variables from the current flwor. If |
1617 | // not, then e can be hoisted out of the current flwor and we repeat the |
1618 | @@ -449,35 +531,177 @@ |
1619 | // cannot be hoisted. |
1620 | for (i = step->clauseCount - 1; i >= 0; --i) |
1621 | { |
1622 | - const forlet_clause* flc = |
1623 | - static_cast<const forlet_clause*>(flwor->get_clause(i)); |
1624 | - |
1625 | - if (flc->get_expr()->is_sequential()) |
1626 | - { |
1627 | - foundSequentialClause = true; |
1628 | - break; |
1629 | - } |
1630 | - |
1631 | - if (contains_var(flc->get_var(), varmap, varset) || |
1632 | - contains_var(flc->get_pos_var(), varmap, varset) || |
1633 | - contains_var(flc->get_score_var(), varmap, varset)) |
1634 | - { |
1635 | - foundReferencedFLWORVar = true; |
1636 | - break; |
1637 | - } |
1638 | - |
1639 | - inloop = (inloop || |
1640 | - (flc->get_kind() == flwor_clause::for_clause && |
1641 | - flc->get_expr()->get_return_type()->max_card() >= 2)); |
1642 | - } |
1643 | + flwor_clause* c = flwor->get_clause(i); |
1644 | + |
1645 | + switch (c->get_kind()) |
1646 | + { |
1647 | + case flwor_clause::for_clause: |
1648 | + case flwor_clause::let_clause: |
1649 | + case flwor_clause::window_clause: |
1650 | + { |
1651 | + forletwin_clause* flwc = static_cast<forletwin_clause*>(c); |
1652 | + |
1653 | + if (flwc->get_expr()->is_sequential()) |
1654 | + { |
1655 | + foundSequentialClause = true; |
1656 | + break; |
1657 | + } |
1658 | + |
1659 | + if (contains_var(flwc->get_var(), varset) || |
1660 | + contains_var(flwc->get_pos_var(), varset)) |
1661 | + // contains_var(flc->get_score_var(), varset) |
1662 | + { |
1663 | + foundReferencedFLWORVar = true; |
1664 | + break; |
1665 | + } |
1666 | + |
1667 | + if (c->get_kind() == flwor_clause::window_clause) |
1668 | + { |
1669 | + window_clause* wc = static_cast<window_clause*>(c); |
1670 | + flwor_wincond* startCond = wc->get_win_start(); |
1671 | + flwor_wincond* stopCond = wc->get_win_stop(); |
1672 | + |
1673 | + if (startCond) |
1674 | + { |
1675 | + const flwor_wincond_vars& vars = startCond->get_out_vars(); |
1676 | + |
1677 | + if (contains_var(vars.posvar, varset) || |
1678 | + contains_var(vars.curr, varset) || |
1679 | + contains_var(vars.prev, varset) || |
1680 | + contains_var(vars.next, varset)) |
1681 | + { |
1682 | + foundReferencedFLWORVar = true; |
1683 | + break; |
1684 | + } |
1685 | + |
1686 | + const flwor_wincond_vars& invars = startCond->get_in_vars(); |
1687 | + |
1688 | + if (contains_var(invars.posvar, varset) || |
1689 | + contains_var(invars.curr, varset) || |
1690 | + contains_var(invars.prev, varset) || |
1691 | + contains_var(invars.next, varset)) |
1692 | + { |
1693 | + foundReferencedFLWORVar = true; |
1694 | + |
1695 | + if (inloop) |
1696 | + { |
1697 | + ZORBA_ASSERT(nextstep); |
1698 | + step = nextstep; |
1699 | + i = -1; |
1700 | + } |
1701 | + |
1702 | + break; |
1703 | + } |
1704 | + } |
1705 | + |
1706 | + if (stopCond) |
1707 | + { |
1708 | + const flwor_wincond_vars& vars = stopCond->get_out_vars(); |
1709 | + |
1710 | + if (contains_var(vars.posvar, varset) || |
1711 | + contains_var(vars.curr, varset) || |
1712 | + contains_var(vars.prev, varset) || |
1713 | + contains_var(vars.next, varset)) |
1714 | + { |
1715 | + foundReferencedFLWORVar = true; |
1716 | + break; |
1717 | + } |
1718 | + |
1719 | + const flwor_wincond_vars& invars = stopCond->get_in_vars(); |
1720 | + |
1721 | + if (contains_var(invars.posvar, varset) || |
1722 | + contains_var(invars.curr, varset) || |
1723 | + contains_var(invars.prev, varset) || |
1724 | + contains_var(invars.next, varset)) |
1725 | + { |
1726 | + foundReferencedFLWORVar = true; |
1727 | + |
1728 | + if (inloop) |
1729 | + { |
1730 | + ZORBA_ASSERT(nextstep); |
1731 | + step = nextstep; |
1732 | + i = -1; |
1733 | + } |
1734 | + |
1735 | + break; |
1736 | + } |
1737 | + } |
1738 | + } |
1739 | + |
1740 | + if (!inloop) |
1741 | + inloop = ((c->get_kind() == flwor_clause::for_clause || |
1742 | + c->get_kind() == flwor_clause::window_clause) && |
1743 | + flwc->get_expr()->get_return_type()->max_card() >= 2); |
1744 | + |
1745 | + break; |
1746 | + } |
1747 | + case flwor_clause::groupby_clause: |
1748 | + { |
1749 | + groupby_clause* gc = static_cast<groupby_clause*>(c); |
1750 | + |
1751 | + var_rebind_list_t::iterator ite = gc->beginGroupVars(); |
1752 | + var_rebind_list_t::iterator end = gc->endGroupVars(); |
1753 | + for (; ite != end; ++ite) |
1754 | + { |
1755 | + if (contains_var((*ite).second, varset)) |
1756 | + { |
1757 | + foundReferencedFLWORVar = true; |
1758 | + break; |
1759 | + } |
1760 | + } |
1761 | + |
1762 | + if (foundReferencedFLWORVar) |
1763 | + break; |
1764 | + |
1765 | + ite = gc->beginNonGroupVars(); |
1766 | + end = gc->endNonGroupVars(); |
1767 | + for (; ite != end; ++ite) |
1768 | + { |
1769 | + if (contains_var((*ite).second, varset)) |
1770 | + { |
1771 | + foundReferencedFLWORVar = true; |
1772 | + break; |
1773 | + } |
1774 | + } |
1775 | + |
1776 | + break; |
1777 | + } |
1778 | + case flwor_clause::count_clause: |
1779 | + { |
1780 | + count_clause* cc = static_cast<count_clause*>(c); |
1781 | + |
1782 | + if (contains_var(cc->get_var(), varset)) |
1783 | + { |
1784 | + foundReferencedFLWORVar = true; |
1785 | + } |
1786 | + |
1787 | + break; |
1788 | + } |
1789 | + case flwor_clause::orderby_clause: |
1790 | + case flwor_clause::where_clause: |
1791 | + { |
1792 | + break; |
1793 | + } |
1794 | + case flwor_clause::materialize_clause: |
1795 | + { |
1796 | + return NULL; |
1797 | + } |
1798 | + default: |
1799 | + ZORBA_ASSERT(false); |
1800 | + } |
1801 | + |
1802 | + if (foundSequentialClause || foundReferencedFLWORVar) |
1803 | + break; |
1804 | + } // for each flwor clause |
1805 | |
1806 | if (foundSequentialClause || foundReferencedFLWORVar) |
1807 | break; |
1808 | - } |
1809 | - |
1810 | - if (step->prev->prev == NULL) |
1811 | - break; |
1812 | - |
1813 | + |
1814 | + if (step->prev->prev == NULL) |
1815 | + break; |
1816 | + } // flwor expr |
1817 | + |
1818 | + nextstep = step; |
1819 | step = step->prev; |
1820 | } |
1821 | |
1822 | @@ -496,42 +720,34 @@ |
1823 | hoisted->setAnnotationFlags(e->getAnnotationFlags()); |
1824 | //letvar->setFlags(e->getFlags()); |
1825 | |
1826 | - let_clause* flref(rCtx.theEM->create_let_clause(sctx, loc, letvar, hoisted)); |
1827 | + let_clause* flref = rCtx.theEM->create_let_clause(sctx, loc, letvar, hoisted); |
1828 | |
1829 | letvar->set_flwor_clause(flref); |
1830 | |
1831 | + ZORBA_ASSERT(step->theExpr == NULL || |
1832 | + step->theExpr->get_expr_kind() == flwor_expr_kind || |
1833 | + step->theExpr->get_expr_kind() == gflwor_expr_kind); |
1834 | + |
1835 | if (step->prev == NULL) |
1836 | { |
1837 | if (step->theExpr == NULL) |
1838 | { |
1839 | - step->theExpr= rCtx.theEM->create_flwor_expr(sctx, udf, loc, false); |
1840 | + step->theExpr = rCtx.theEM->create_flwor_expr(sctx, udf, loc, false); |
1841 | } |
1842 | + |
1843 | static_cast<flwor_expr*>(step->theExpr)->add_clause(flref); |
1844 | } |
1845 | - else if (step->theExpr->get_expr_kind() == flwor_expr_kind) |
1846 | + else |
1847 | { |
1848 | static_cast<flwor_expr*>(step->theExpr)->add_clause(i + 1, flref); |
1849 | ++step->clauseCount; |
1850 | } |
1851 | - else |
1852 | - { |
1853 | - assert(step->theExpr->get_expr_kind() == trycatch_expr_kind); |
1854 | - |
1855 | - trycatch_expr* trycatchExpr = static_cast<trycatch_expr*>(step->theExpr); |
1856 | - |
1857 | - flwor_expr* flwor = rCtx.theEM->create_flwor_expr(sctx, udf, loc, false); |
1858 | - flwor->add_clause(flref); |
1859 | - flwor->set_return_expr(trycatchExpr->get_try_expr()); |
1860 | - |
1861 | - trycatchExpr->set_try_expr(flwor); |
1862 | - } |
1863 | |
1864 | expr* unhoisted = rCtx.theEM-> |
1865 | - create_fo_expr(sctx, |
1866 | - udf, |
1867 | - loc, |
1868 | + create_fo_expr(sctx, udf, loc, |
1869 | BUILTIN_FUNC(OP_UNHOIST_1), |
1870 | rCtx.theEM->create_wrapper_expr(sctx, udf, loc, letvar)); |
1871 | + |
1872 | unhoisted->setAnnotationFlags(e->getAnnotationFlags()); |
1873 | |
1874 | return unhoisted; |
1875 | @@ -541,23 +757,17 @@ |
1876 | /******************************************************************************* |
1877 | Check if the given var is contained in the given varset. |
1878 | ********************************************************************************/ |
1879 | -static bool contains_var( |
1880 | - var_expr* v, |
1881 | - const expr_tools::VarIdMap& varmap, |
1882 | - const DynamicBitset& varset) |
1883 | +bool HoistRule::contains_var(var_expr* v, const DynamicBitset& varset) |
1884 | { |
1885 | if (v == NULL) |
1886 | - { |
1887 | - return false; |
1888 | - } |
1889 | - |
1890 | - expr_tools::VarIdMap::const_iterator i = varmap.find(v); |
1891 | - if (i == varmap.end()) |
1892 | - { |
1893 | - return false; |
1894 | - } |
1895 | - int bit = i->second; |
1896 | - return varset.get(bit); |
1897 | + return false; |
1898 | + |
1899 | + expr_tools::VarIdMap::const_iterator i = theVarIdMap.find(v); |
1900 | + |
1901 | + if (i == theVarIdMap.end()) |
1902 | + return false; |
1903 | + |
1904 | + return varset.get(i->second); |
1905 | } |
1906 | |
1907 | |
1908 | @@ -589,8 +799,17 @@ |
1909 | { |
1910 | const fo_expr* fo = static_cast<const fo_expr*>(e); |
1911 | const function* f = fo->get_func(); |
1912 | - |
1913 | - if (f->getKind() == FunctionConsts::OP_CONCATENATE_N && fo->num_args() == 0) |
1914 | + FunctionConsts::FunctionKind fkind = f->getKind(); |
1915 | + |
1916 | + if (fkind == FunctionConsts::OP_CONCATENATE_N && fo->num_args() == 0) |
1917 | + return true; |
1918 | + |
1919 | + if (fkind == FunctionConsts::STATIC_COLLECTIONS_DML_COLLECTION_1 || |
1920 | + fkind == FunctionConsts::STATIC_COLLECTIONS_DML_COLLECTION_2 || |
1921 | + fkind == FunctionConsts::STATIC_COLLECTIONS_DML_COLLECTION_3 || |
1922 | + fkind == FunctionConsts::DYNAMIC_COLLECTIONS_DML_COLLECTION_1 || |
1923 | + fkind == FunctionConsts::DYNAMIC_COLLECTIONS_DML_COLLECTION_2 || |
1924 | + fkind == FunctionConsts::DYNAMIC_COLLECTIONS_DML_COLLECTION_3) |
1925 | return true; |
1926 | } |
1927 | |
1928 | |
1929 | === added file 'src/compiler/rewriter/rules/hoist_rules.h' |
1930 | --- src/compiler/rewriter/rules/hoist_rules.h 1970-01-01 00:00:00 +0000 |
1931 | +++ src/compiler/rewriter/rules/hoist_rules.h 2013-05-16 10:15:45 +0000 |
1932 | @@ -0,0 +1,55 @@ |
1933 | +/* |
1934 | + * Copyright 2006-2008 The FLWOR Foundation. |
1935 | + * |
1936 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
1937 | + * you may not use this file except in compliance with the License. |
1938 | + * You may obtain a copy of the License at |
1939 | + * |
1940 | + * http://www.apache.org/licenses/LICENSE-2.0 |
1941 | + * |
1942 | + * Unless required by applicable law or agreed to in writing, software |
1943 | + * distributed under the License is distributed on an "AS IS" BASIS, |
1944 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
1945 | + * See the License for the specific language governing permissions and |
1946 | + * limitations under the License. |
1947 | + */ |
1948 | +#pragma once |
1949 | +#ifndef ZORBA_COMPILER_REWRITER_HOIST_RULES |
1950 | +#define ZORBA_COMPILER_REWRITER_HOIST_RULES |
1951 | + |
1952 | +#include "compiler/rewriter/rules/rule_base.h" |
1953 | +#include "compiler/rewriter/tools/expr_tools.h" |
1954 | + |
1955 | + |
1956 | +namespace zorba |
1957 | +{ |
1958 | + |
1959 | +class RewriterContext; |
1960 | + |
1961 | + |
1962 | +/******************************************************************************* |
1963 | + |
1964 | +********************************************************************************/ |
1965 | +class HoistRule : public RewriteRule |
1966 | +{ |
1967 | +protected: |
1968 | + expr_tools::VarIdMap theVarIdMap; |
1969 | + |
1970 | + expr_tools::ExprVarsMap theExprVarsMap; |
1971 | + |
1972 | +public: |
1973 | + HoistRule() : RewriteRule(RewriteRule::HoistExprsOutOfLoops, "Hoist") {} |
1974 | + |
1975 | + expr* apply(RewriterContext& rCtx, expr* node, bool& modified); |
1976 | + |
1977 | +protected: |
1978 | + bool hoistChildren(RewriterContext&, expr*, struct PathHolder*); |
1979 | + |
1980 | + expr* hoistExpr(RewriterContext&, expr*, struct PathHolder*); |
1981 | + |
1982 | + bool contains_var(var_expr* v, const DynamicBitset& varset); |
1983 | +}; |
1984 | + |
1985 | + |
1986 | +} |
1987 | +#endif |
1988 | |
1989 | === modified file 'src/compiler/rewriter/rules/ruleset.h' |
1990 | --- src/compiler/rewriter/rules/ruleset.h 2013-02-08 08:23:51 +0000 |
1991 | +++ src/compiler/rewriter/rules/ruleset.h 2013-05-16 10:15:45 +0000 |
1992 | @@ -223,19 +223,6 @@ |
1993 | }; |
1994 | |
1995 | |
1996 | -/******************************************************************************* |
1997 | - |
1998 | -********************************************************************************/ |
1999 | -class HoistRule : public RewriteRule |
2000 | -{ |
2001 | -public: |
2002 | - HoistRule() : RewriteRule(RewriteRule::IndexJoin, "Hoist") {} |
2003 | - |
2004 | - expr* apply(RewriterContext& rCtx, expr* node, bool& modified); |
2005 | -}; |
2006 | - |
2007 | - |
2008 | - |
2009 | } |
2010 | |
2011 | #endif /* ZORBA_REWRITE_RULE_H */ |
2012 | |
2013 | === modified file 'src/system/globalenv.cpp' |
2014 | --- src/system/globalenv.cpp 2013-05-08 20:14:47 +0000 |
2015 | +++ src/system/globalenv.cpp 2013-05-16 10:15:45 +0000 |
2016 | @@ -30,13 +30,18 @@ |
2017 | #include "zorbautils/fatal.h" |
2018 | |
2019 | #include "globalenv.h" |
2020 | + |
2021 | #include "types/root_typemanager.h" |
2022 | #include "types/schema/schema.h" |
2023 | + |
2024 | #include "context/root_static_context.h" |
2025 | #include "context/default_url_resolvers.h" |
2026 | #include "context/dynamic_loader.h" |
2027 | + |
2028 | #include "functions/library.h" |
2029 | + |
2030 | #include "annotations/annotations.h" |
2031 | + |
2032 | #include "compiler/api/compiler_api.h" |
2033 | #include "compiler/xqueryx/xqueryx_to_xquery.h" |
2034 | |
2035 | |
2036 | === modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/gflwor_02.iter' |
2037 | --- test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/gflwor_02.iter 2013-02-21 16:34:45 +0000 |
2038 | +++ test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/gflwor_02.iter 2013-05-16 10:15:45 +0000 |
2039 | @@ -98,35 +98,78 @@ |
2040 | </FnConcatIterator> |
2041 | </ElementIterator> |
2042 | </CtxVarDeclareIterator> |
2043 | - <CreateInternalIndexIterator name="xs:QName(,,tempIndex0)"> |
2044 | - <flwor::FLWORIterator> |
2045 | - <ForVariable name="$$opt_temp_0"> |
2046 | - <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,sale)" typename="*" nill allowed="0"> |
2047 | - <CtxVarIterator varid="5" varname="sales" varkind="global"/> |
2048 | - </ChildAxisIterator> |
2049 | - </ForVariable> |
2050 | - <ReturnClause> |
2051 | - <ValueIndexEntryBuilderIterator> |
2052 | - <ForVarIterator varname="$$opt_temp_0"/> |
2053 | - <FnStringIterator> |
2054 | - <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,pid)" typename="*" nill allowed="0"> |
2055 | - <ForVarIterator varname="$$opt_temp_0"/> |
2056 | - </AttributeAxisIterator> |
2057 | - </FnStringIterator> |
2058 | - </ValueIndexEntryBuilderIterator> |
2059 | - </ReturnClause> |
2060 | - </flwor::FLWORIterator> |
2061 | - </CreateInternalIndexIterator> |
2062 | <flwor::TupleStreamIterator> |
2063 | <flwor::ForIterator> |
2064 | <ForVariable name="s"/> |
2065 | <flwor::WhereIterator> |
2066 | <flwor::ForIterator> |
2067 | - <ForVariable name="p"/> |
2068 | - <flwor::TupleSourceIterator/> |
2069 | - <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,prod)" typename="*" nill allowed="0"> |
2070 | - <CtxVarIterator varid="4" varname="products" varkind="global"/> |
2071 | - </ChildAxisIterator> |
2072 | + <ForVariable name="$$opt_temp_1"/> |
2073 | + <flwor::LetIterator> |
2074 | + <LetVariable name="$$opt_temp_2" materialize="true"/> |
2075 | + <flwor::LetIterator> |
2076 | + <LetVariable name="$$opt_temp_3" materialize="true"/> |
2077 | + <flwor::ForIterator> |
2078 | + <ForVariable name="p"/> |
2079 | + <flwor::LetIterator> |
2080 | + <LetVariable name="$$opt_temp_6" materialize="true"/> |
2081 | + <flwor::LetIterator> |
2082 | + <LetVariable name="$$opt_temp_0" materialize="true"/> |
2083 | + <flwor::TupleSourceIterator/> |
2084 | + <HoistIterator> |
2085 | + <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,sale)" typename="*" nill allowed="0"> |
2086 | + <CtxVarIterator varid="5" varname="sales" varkind="global"/> |
2087 | + </ChildAxisIterator> |
2088 | + </HoistIterator> |
2089 | + </flwor::LetIterator> |
2090 | + <CreateInternalIndexIterator name="xs:QName(,,tempIndex0)"> |
2091 | + <flwor::FLWORIterator> |
2092 | + <ForVariable name="$$opt_temp_4"> |
2093 | + <UnhoistIterator> |
2094 | + <LetVarIterator varname="$$opt_temp_0"/> |
2095 | + </UnhoistIterator> |
2096 | + </ForVariable> |
2097 | + <ReturnClause> |
2098 | + <ValueIndexEntryBuilderIterator> |
2099 | + <ForVarIterator varname="$$opt_temp_4"/> |
2100 | + <FnStringIterator> |
2101 | + <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,pid)" typename="*" nill allowed="0"> |
2102 | + <ForVarIterator varname="$$opt_temp_4"/> |
2103 | + </AttributeAxisIterator> |
2104 | + </FnStringIterator> |
2105 | + </ValueIndexEntryBuilderIterator> |
2106 | + </ReturnClause> |
2107 | + </flwor::FLWORIterator> |
2108 | + </CreateInternalIndexIterator> |
2109 | + </flwor::LetIterator> |
2110 | + <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,prod)" typename="*" nill allowed="0"> |
2111 | + <CtxVarIterator varid="4" varname="products" varkind="global"/> |
2112 | + </ChildAxisIterator> |
2113 | + </flwor::ForIterator> |
2114 | + <HoistIterator> |
2115 | + <PromoteIterator type="xs:anyAtomicType"> |
2116 | + <FnDataIterator> |
2117 | + <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,price)" typename="*" nill allowed="0"> |
2118 | + <ForVarIterator varname="p"/> |
2119 | + </AttributeAxisIterator> |
2120 | + </FnDataIterator> |
2121 | + </PromoteIterator> |
2122 | + </HoistIterator> |
2123 | + </flwor::LetIterator> |
2124 | + <HoistIterator> |
2125 | + <FnDataIterator> |
2126 | + <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,name)" typename="*" nill allowed="0"> |
2127 | + <ForVarIterator varname="p"/> |
2128 | + </AttributeAxisIterator> |
2129 | + </FnDataIterator> |
2130 | + </HoistIterator> |
2131 | + </flwor::LetIterator> |
2132 | + <HoistIterator> |
2133 | + <FnStringIterator> |
2134 | + <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,id)" typename="*" nill allowed="0"> |
2135 | + <ForVarIterator varname="p"/> |
2136 | + </AttributeAxisIterator> |
2137 | + </FnStringIterator> |
2138 | + </HoistIterator> |
2139 | </flwor::ForIterator> |
2140 | <CompareIterator> |
2141 | <CastIterator type="xs:integer"> |
2142 | @@ -141,11 +184,9 @@ |
2143 | </flwor::WhereIterator> |
2144 | <ProbeIndexPointValueIterator> |
2145 | <SingletonIterator value="xs:QName(,,tempIndex0)"/> |
2146 | - <FnStringIterator> |
2147 | - <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,id)" typename="*" nill allowed="0"> |
2148 | - <ForVarIterator varname="p"/> |
2149 | - </AttributeAxisIterator> |
2150 | - </FnStringIterator> |
2151 | + <UnhoistIterator> |
2152 | + <ForVarIterator varname="$$opt_temp_1"/> |
2153 | + </UnhoistIterator> |
2154 | </ProbeIndexPointValueIterator> |
2155 | </flwor::ForIterator> |
2156 | <ElementIterator> |
2157 | @@ -153,23 +194,17 @@ |
2158 | <FnConcatIterator> |
2159 | <AttributeIterator qname="xs:QName(,,prod)"> |
2160 | <EnclosedIterator attr_cont="true"> |
2161 | - <FnDataIterator> |
2162 | - <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,name)" typename="*" nill allowed="0"> |
2163 | - <ForVarIterator varname="p"/> |
2164 | - </AttributeAxisIterator> |
2165 | - </FnDataIterator> |
2166 | + <UnhoistIterator> |
2167 | + <LetVarIterator varname="$$opt_temp_2"/> |
2168 | + </UnhoistIterator> |
2169 | </EnclosedIterator> |
2170 | </AttributeIterator> |
2171 | <AttributeIterator qname="xs:QName(,,amount)"> |
2172 | <EnclosedIterator attr_cont="true"> |
2173 | <GenericArithIterator_MultiplyOperation> |
2174 | - <PromoteIterator type="xs:anyAtomicType"> |
2175 | - <FnDataIterator> |
2176 | - <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,price)" typename="*" nill allowed="0"> |
2177 | - <ForVarIterator varname="p"/> |
2178 | - </AttributeAxisIterator> |
2179 | - </FnDataIterator> |
2180 | - </PromoteIterator> |
2181 | + <UnhoistIterator> |
2182 | + <LetVarIterator varname="$$opt_temp_3"/> |
2183 | + </UnhoistIterator> |
2184 | <PromoteIterator type="xs:anyAtomicType"> |
2185 | <FnDataIterator> |
2186 | <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,qty)" typename="*" nill allowed="0"> |
2187 | |
2188 | === modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/gflwor_03.iter' |
2189 | --- test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/gflwor_03.iter 2013-02-28 10:59:07 +0000 |
2190 | +++ test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/gflwor_03.iter 2013-05-16 10:15:45 +0000 |
2191 | @@ -94,88 +94,107 @@ |
2192 | </FnConcatIterator> |
2193 | </ElementIterator> |
2194 | </CtxVarDeclareIterator> |
2195 | - <CreateInternalIndexIterator name="xs:QName(,,tempIndex0)"> |
2196 | - <flwor::FLWORIterator> |
2197 | - <ForVariable name="$$opt_temp_0"> |
2198 | - <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,loc)" typename="*" nill allowed="0"> |
2199 | - <CtxVarIterator varid="5" varname="locations" varkind="global"/> |
2200 | - </ChildAxisIterator> |
2201 | - </ForVariable> |
2202 | - <ReturnClause> |
2203 | - <ValueIndexEntryBuilderIterator> |
2204 | - <ForVarIterator varname="$$opt_temp_0"/> |
2205 | - <FnStringIterator> |
2206 | - <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,id)" typename="*" nill allowed="0"> |
2207 | - <ForVarIterator varname="$$opt_temp_0"/> |
2208 | - </AttributeAxisIterator> |
2209 | - </FnStringIterator> |
2210 | - </ValueIndexEntryBuilderIterator> |
2211 | - </ReturnClause> |
2212 | - </flwor::FLWORIterator> |
2213 | - </CreateInternalIndexIterator> |
2214 | - <flwor::FLWORIterator> |
2215 | - <ForVariable name="s"> |
2216 | - <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,sale)" typename="*" nill allowed="0"> |
2217 | - <CtxVarIterator varid="4" varname="sales" varkind="global"/> |
2218 | - </ChildAxisIterator> |
2219 | - </ForVariable> |
2220 | - <GroupByClause> |
2221 | - <Spec> |
2222 | - <TreatIterator quant="?"> |
2223 | - <FnDataIterator> |
2224 | - <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,locid)" typename="*" nill allowed="0"> |
2225 | - <ForVarIterator varname="s"/> |
2226 | - </AttributeAxisIterator> |
2227 | - </FnDataIterator> |
2228 | - </TreatIterator> |
2229 | - <GroupVariable/> |
2230 | - </Spec> |
2231 | - <Spec> |
2232 | - <ForVarIterator varname="s"/> |
2233 | - <NonGroupVariable/> |
2234 | - </Spec> |
2235 | - </GroupByClause> |
2236 | - <ReturnClause> |
2237 | - <ElementIterator> |
2238 | - <SingletonIterator value="xs:QName(,,sale)"/> |
2239 | - <FnConcatIterator> |
2240 | - <AttributeIterator qname="xs:QName(,,city)"> |
2241 | - <EnclosedIterator attr_cont="true"> |
2242 | + <flwor::TupleStreamIterator> |
2243 | + <flwor::ForIterator> |
2244 | + <ForVariable name="$$opt_temp_1"/> |
2245 | + <flwor::GroupByIterator> |
2246 | + <flwor::ForIterator> |
2247 | + <ForVariable name="s"/> |
2248 | + <flwor::LetIterator> |
2249 | + <LetVariable name="$$opt_temp_4" materialize="true"/> |
2250 | + <flwor::LetIterator> |
2251 | + <LetVariable name="$$opt_temp_0" materialize="true"/> |
2252 | + <flwor::TupleSourceIterator/> |
2253 | + <HoistIterator> |
2254 | + <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,loc)" typename="*" nill allowed="0"> |
2255 | + <CtxVarIterator varid="5" varname="locations" varkind="global"/> |
2256 | + </ChildAxisIterator> |
2257 | + </HoistIterator> |
2258 | + </flwor::LetIterator> |
2259 | + <CreateInternalIndexIterator name="xs:QName(,,tempIndex0)"> |
2260 | + <flwor::FLWORIterator> |
2261 | + <ForVariable name="$$opt_temp_2"> |
2262 | + <UnhoistIterator> |
2263 | + <LetVarIterator varname="$$opt_temp_0"/> |
2264 | + </UnhoistIterator> |
2265 | + </ForVariable> |
2266 | + <ReturnClause> |
2267 | + <ValueIndexEntryBuilderIterator> |
2268 | + <ForVarIterator varname="$$opt_temp_2"/> |
2269 | + <FnStringIterator> |
2270 | + <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,id)" typename="*" nill allowed="0"> |
2271 | + <ForVarIterator varname="$$opt_temp_2"/> |
2272 | + </AttributeAxisIterator> |
2273 | + </FnStringIterator> |
2274 | + </ValueIndexEntryBuilderIterator> |
2275 | + </ReturnClause> |
2276 | + </flwor::FLWORIterator> |
2277 | + </CreateInternalIndexIterator> |
2278 | + </flwor::LetIterator> |
2279 | + <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,sale)" typename="*" nill allowed="0"> |
2280 | + <CtxVarIterator varid="4" varname="sales" varkind="global"/> |
2281 | + </ChildAxisIterator> |
2282 | + </flwor::ForIterator> |
2283 | + <Spec> |
2284 | + <TreatIterator quant="?"> |
2285 | + <FnDataIterator> |
2286 | + <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,locid)" typename="*" nill allowed="0"> |
2287 | + <ForVarIterator varname="s"/> |
2288 | + </AttributeAxisIterator> |
2289 | + </FnDataIterator> |
2290 | + </TreatIterator> |
2291 | + <GroupVariable/> |
2292 | + </Spec> |
2293 | + <Spec> |
2294 | + <ForVarIterator varname="s"/> |
2295 | + <NonGroupVariable/> |
2296 | + </Spec> |
2297 | + </flwor::GroupByIterator> |
2298 | + <HoistIterator> |
2299 | + <FnStringIterator> |
2300 | + <ForVarIterator varname="loc"/> |
2301 | + </FnStringIterator> |
2302 | + </HoistIterator> |
2303 | + </flwor::ForIterator> |
2304 | + <ElementIterator> |
2305 | + <SingletonIterator value="xs:QName(,,sale)"/> |
2306 | + <FnConcatIterator> |
2307 | + <AttributeIterator qname="xs:QName(,,city)"> |
2308 | + <EnclosedIterator attr_cont="true"> |
2309 | + <FnDataIterator> |
2310 | + <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,city)" typename="*" nill allowed="0"> |
2311 | + <flwor::FLWORIterator> |
2312 | + <ForVariable name="$$context-item"> |
2313 | + <ProbeIndexPointValueIterator> |
2314 | + <SingletonIterator value="xs:QName(,,tempIndex0)"/> |
2315 | + <UnhoistIterator> |
2316 | + <ForVarIterator varname="$$opt_temp_1"/> |
2317 | + </UnhoistIterator> |
2318 | + </ProbeIndexPointValueIterator> |
2319 | + </ForVariable> |
2320 | + <ReturnClause> |
2321 | + <ForVarIterator varname="$$context-item"/> |
2322 | + </ReturnClause> |
2323 | + </flwor::FLWORIterator> |
2324 | + </AttributeAxisIterator> |
2325 | + </FnDataIterator> |
2326 | + </EnclosedIterator> |
2327 | + </AttributeIterator> |
2328 | + <AttributeIterator qname="xs:QName(,,qty)"> |
2329 | + <EnclosedIterator attr_cont="true"> |
2330 | + <FnSumIterator> |
2331 | <FnDataIterator> |
2332 | - <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,city)" typename="*" nill allowed="0"> |
2333 | - <flwor::FLWORIterator> |
2334 | - <ForVariable name="$$context-item"> |
2335 | - <ProbeIndexPointValueIterator> |
2336 | - <SingletonIterator value="xs:QName(,,tempIndex0)"/> |
2337 | - <FnStringIterator> |
2338 | - <ForVarIterator varname="loc"/> |
2339 | - </FnStringIterator> |
2340 | - </ProbeIndexPointValueIterator> |
2341 | - </ForVariable> |
2342 | - <ReturnClause> |
2343 | - <ForVarIterator varname="$$context-item"/> |
2344 | - </ReturnClause> |
2345 | - </flwor::FLWORIterator> |
2346 | - </AttributeAxisIterator> |
2347 | + <NodeDistinctIterator allow-atomics="false" check-only="false"> |
2348 | + <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,qty)" typename="*" nill allowed="0"> |
2349 | + <LetVarIterator varname="s"/> |
2350 | + </AttributeAxisIterator> |
2351 | + </NodeDistinctIterator> |
2352 | </FnDataIterator> |
2353 | - </EnclosedIterator> |
2354 | - </AttributeIterator> |
2355 | - <AttributeIterator qname="xs:QName(,,qty)"> |
2356 | - <EnclosedIterator attr_cont="true"> |
2357 | - <FnSumIterator> |
2358 | - <FnDataIterator> |
2359 | - <NodeDistinctIterator allow-atomics="false" check-only="false"> |
2360 | - <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,qty)" typename="*" nill allowed="0"> |
2361 | - <LetVarIterator varname="s"/> |
2362 | - </AttributeAxisIterator> |
2363 | - </NodeDistinctIterator> |
2364 | - </FnDataIterator> |
2365 | - </FnSumIterator> |
2366 | - </EnclosedIterator> |
2367 | - </AttributeIterator> |
2368 | - </FnConcatIterator> |
2369 | - </ElementIterator> |
2370 | - </ReturnClause> |
2371 | - </flwor::FLWORIterator> |
2372 | + </FnSumIterator> |
2373 | + </EnclosedIterator> |
2374 | + </AttributeIterator> |
2375 | + </FnConcatIterator> |
2376 | + </ElementIterator> |
2377 | + </flwor::TupleStreamIterator> |
2378 | </SequentialIterator> |
2379 | |
2380 | |
2381 | === modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/gflwor_04.iter' |
2382 | --- test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/gflwor_04.iter 2013-03-04 23:38:24 +0000 |
2383 | +++ test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/gflwor_04.iter 2013-05-16 10:15:45 +0000 |
2384 | @@ -3,65 +3,81 @@ |
2385 | <flwor::LetIterator> |
2386 | <LetVariable name="y" materialize="true"/> |
2387 | <flwor::CountIterator> |
2388 | - <flwor::ForIterator> |
2389 | - <ForVariable name="x"/> |
2390 | - <flwor::LetIterator> |
2391 | - <LetVariable name="$$opt_temp_2" materialize="true"/> |
2392 | - <flwor::ForIterator> |
2393 | - <ForVariable name="a"/> |
2394 | - <flwor::TupleSourceIterator/> |
2395 | - <FnConcatIterator> |
2396 | - <SingletonIterator value="xs:integer(1)"/> |
2397 | - <SingletonIterator value="xs:integer(2)"/> |
2398 | - </FnConcatIterator> |
2399 | - </flwor::ForIterator> |
2400 | - <CreateInternalIndexIterator name="xs:QName(,,tempIndex0)"> |
2401 | - <flwor::FLWORIterator> |
2402 | - <ForVariable name="$$opt_temp_0"> |
2403 | + <flwor::LetIterator> |
2404 | + <LetVariable name="$$opt_temp_1" materialize="true"/> |
2405 | + <flwor::ForIterator> |
2406 | + <ForVariable name="x"/> |
2407 | + <flwor::LetIterator> |
2408 | + <LetVariable name="$$opt_temp_4" materialize="true"/> |
2409 | + <flwor::LetIterator> |
2410 | + <LetVariable name="$$opt_temp_0" materialize="true"/> |
2411 | + <flwor::ForIterator> |
2412 | + <ForVariable name="a"/> |
2413 | + <flwor::TupleSourceIterator/> |
2414 | + <FnConcatIterator> |
2415 | + <SingletonIterator value="xs:integer(1)"/> |
2416 | + <SingletonIterator value="xs:integer(2)"/> |
2417 | + </FnConcatIterator> |
2418 | + </flwor::ForIterator> |
2419 | + <HoistIterator> |
2420 | <UDFunctionCallIterator function="local:foo"> |
2421 | <ForVarIterator varname="a"/> |
2422 | </UDFunctionCallIterator> |
2423 | - </ForVariable> |
2424 | - <ReturnClause> |
2425 | - <ValueIndexEntryBuilderIterator> |
2426 | - <ForVarIterator varname="$$opt_temp_0"/> |
2427 | - <ForVarIterator varname="$$opt_temp_0"/> |
2428 | - </ValueIndexEntryBuilderIterator> |
2429 | - </ReturnClause> |
2430 | - </flwor::FLWORIterator> |
2431 | - </CreateInternalIndexIterator> |
2432 | - </flwor::LetIterator> |
2433 | - <FnConcatIterator> |
2434 | - <ElementIterator> |
2435 | - <SingletonIterator value="xs:QName(,,a)"/> |
2436 | - <TextIterator> |
2437 | - <SingletonIterator value="xs:string(1)"/> |
2438 | - </TextIterator> |
2439 | - </ElementIterator> |
2440 | - <ElementIterator> |
2441 | - <SingletonIterator value="xs:QName(,,a)"/> |
2442 | - <TextIterator> |
2443 | - <SingletonIterator value="xs:string(2)"/> |
2444 | - </TextIterator> |
2445 | - </ElementIterator> |
2446 | - <ElementIterator> |
2447 | - <SingletonIterator value="xs:QName(,,a)"/> |
2448 | - <TextIterator> |
2449 | - <SingletonIterator value="xs:string(3)"/> |
2450 | - </TextIterator> |
2451 | - </ElementIterator> |
2452 | - </FnConcatIterator> |
2453 | - </flwor::ForIterator> |
2454 | + </HoistIterator> |
2455 | + </flwor::LetIterator> |
2456 | + <CreateInternalIndexIterator name="xs:QName(,,tempIndex0)"> |
2457 | + <flwor::FLWORIterator> |
2458 | + <ForVariable name="$$opt_temp_2"> |
2459 | + <UnhoistIterator> |
2460 | + <LetVarIterator varname="$$opt_temp_0"/> |
2461 | + </UnhoistIterator> |
2462 | + </ForVariable> |
2463 | + <ReturnClause> |
2464 | + <ValueIndexEntryBuilderIterator> |
2465 | + <ForVarIterator varname="$$opt_temp_2"/> |
2466 | + <ForVarIterator varname="$$opt_temp_2"/> |
2467 | + </ValueIndexEntryBuilderIterator> |
2468 | + </ReturnClause> |
2469 | + </flwor::FLWORIterator> |
2470 | + </CreateInternalIndexIterator> |
2471 | + </flwor::LetIterator> |
2472 | + <FnConcatIterator> |
2473 | + <ElementIterator> |
2474 | + <SingletonIterator value="xs:QName(,,a)"/> |
2475 | + <TextIterator> |
2476 | + <SingletonIterator value="xs:string(1)"/> |
2477 | + </TextIterator> |
2478 | + </ElementIterator> |
2479 | + <ElementIterator> |
2480 | + <SingletonIterator value="xs:QName(,,a)"/> |
2481 | + <TextIterator> |
2482 | + <SingletonIterator value="xs:string(2)"/> |
2483 | + </TextIterator> |
2484 | + </ElementIterator> |
2485 | + <ElementIterator> |
2486 | + <SingletonIterator value="xs:QName(,,a)"/> |
2487 | + <TextIterator> |
2488 | + <SingletonIterator value="xs:string(3)"/> |
2489 | + </TextIterator> |
2490 | + </ElementIterator> |
2491 | + </FnConcatIterator> |
2492 | + </flwor::ForIterator> |
2493 | + <HoistIterator> |
2494 | + <CastIterator type="xs:integer"> |
2495 | + <FnDataIterator> |
2496 | + <ForVarIterator varname="x"/> |
2497 | + </FnDataIterator> |
2498 | + </CastIterator> |
2499 | + </HoistIterator> |
2500 | + </flwor::LetIterator> |
2501 | </flwor::CountIterator> |
2502 | <flwor::FLWORIterator> |
2503 | <ForVariable name="z"> |
2504 | <ProbeIndexPointValueIterator> |
2505 | <SingletonIterator value="xs:QName(,,tempIndex0)"/> |
2506 | - <CastIterator type="xs:integer"> |
2507 | - <FnDataIterator> |
2508 | - <ForVarIterator varname="x"/> |
2509 | - </FnDataIterator> |
2510 | - </CastIterator> |
2511 | + <UnhoistIterator> |
2512 | + <LetVarIterator varname="$$opt_temp_1"/> |
2513 | + </UnhoistIterator> |
2514 | </ProbeIndexPointValueIterator> |
2515 | </ForVariable> |
2516 | <ReturnClause> |
2517 | |
2518 | === modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/gflwor_05.iter' |
2519 | --- test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/gflwor_05.iter 2013-02-28 10:59:07 +0000 |
2520 | +++ test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/gflwor_05.iter 2013-05-16 10:15:45 +0000 |
2521 | @@ -1,19 +1,26 @@ |
2522 | Iterator tree for main query: |
2523 | <flwor::FLWORIterator> |
2524 | - <LetVariable name="$$opt_temp_2" materialize="true"> |
2525 | + <LetVariable name="$$opt_temp_0" materialize="true"> |
2526 | + <HoistIterator> |
2527 | + <FnConcatIterator> |
2528 | + <SingletonIterator value="xs:integer(1)"/> |
2529 | + <SingletonIterator value="xs:integer(2)"/> |
2530 | + <SingletonIterator value="xs:integer(3)"/> |
2531 | + </FnConcatIterator> |
2532 | + </HoistIterator> |
2533 | + </LetVariable> |
2534 | + <LetVariable name="$$opt_temp_4" materialize="true"> |
2535 | <CreateInternalIndexIterator name="xs:QName(,,tempIndex0)"> |
2536 | <flwor::FLWORIterator> |
2537 | - <ForVariable name="$$opt_temp_0"> |
2538 | - <FnConcatIterator> |
2539 | - <SingletonIterator value="xs:integer(1)"/> |
2540 | - <SingletonIterator value="xs:integer(2)"/> |
2541 | - <SingletonIterator value="xs:integer(3)"/> |
2542 | - </FnConcatIterator> |
2543 | + <ForVariable name="$$opt_temp_2"> |
2544 | + <UnhoistIterator> |
2545 | + <LetVarIterator varname="$$opt_temp_0"/> |
2546 | + </UnhoistIterator> |
2547 | </ForVariable> |
2548 | <ReturnClause> |
2549 | <ValueIndexEntryBuilderIterator> |
2550 | - <ForVarIterator varname="$$opt_temp_0"/> |
2551 | - <ForVarIterator varname="$$opt_temp_0"/> |
2552 | + <ForVarIterator varname="$$opt_temp_2"/> |
2553 | + <ForVarIterator varname="$$opt_temp_2"/> |
2554 | </ValueIndexEntryBuilderIterator> |
2555 | </ReturnClause> |
2556 | </flwor::FLWORIterator> |
2557 | @@ -41,6 +48,15 @@ |
2558 | </ElementIterator> |
2559 | </FnConcatIterator> |
2560 | </ForVariable> |
2561 | + <LetVariable name="$$opt_temp_1" materialize="true"> |
2562 | + <HoistIterator> |
2563 | + <CastIterator type="xs:integer"> |
2564 | + <FnDataIterator> |
2565 | + <ForVarIterator varname="x"/> |
2566 | + </FnDataIterator> |
2567 | + </CastIterator> |
2568 | + </HoistIterator> |
2569 | + </LetVariable> |
2570 | <LetVariable name="y" materialize="true"> |
2571 | <flwor::TupleStreamIterator> |
2572 | <flwor::ForIterator> |
2573 | @@ -81,11 +97,9 @@ |
2574 | </flwor::GroupByIterator> |
2575 | <ProbeIndexPointValueIterator> |
2576 | <SingletonIterator value="xs:QName(,,tempIndex0)"/> |
2577 | - <CastIterator type="xs:integer"> |
2578 | - <FnDataIterator> |
2579 | - <ForVarIterator varname="x"/> |
2580 | - </FnDataIterator> |
2581 | - </CastIterator> |
2582 | + <UnhoistIterator> |
2583 | + <LetVarIterator varname="$$opt_temp_1"/> |
2584 | + </UnhoistIterator> |
2585 | </ProbeIndexPointValueIterator> |
2586 | </flwor::ForIterator> |
2587 | <ForVarIterator varname="w"/> |
2588 | |
2589 | === modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/idx10.iter' |
2590 | --- test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/idx10.iter 2013-02-26 03:15:17 +0000 |
2591 | +++ test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/idx10.iter 2013-05-16 10:15:45 +0000 |
2592 | @@ -1,134 +1,130 @@ |
2593 | Iterator tree for main query: |
2594 | -<TryCatchIterator> |
2595 | - <flwor::FLWORIterator> |
2596 | - <LetVariable name="$$opt_temp_1" materialize="true"> |
2597 | - <HoistIterator> |
2598 | - <OpToIterator> |
2599 | - <SingletonIterator value="xs:integer(1)"/> |
2600 | - <SingletonIterator value="xs:integer(10)"/> |
2601 | - </OpToIterator> |
2602 | - </HoistIterator> |
2603 | - </LetVariable> |
2604 | - <ReturnClause> |
2605 | +<flwor::FLWORIterator> |
2606 | + <ForVariable name="$$opt_temp_0"> |
2607 | + <HoistIterator> |
2608 | + <ErrorIterator/> |
2609 | + </HoistIterator> |
2610 | + </ForVariable> |
2611 | + <LetVariable name="$$opt_temp_1" materialize="true"> |
2612 | + <HoistIterator> |
2613 | + <OpToIterator> |
2614 | + <SingletonIterator value="xs:integer(1)"/> |
2615 | + <SingletonIterator value="xs:integer(10)"/> |
2616 | + </OpToIterator> |
2617 | + </HoistIterator> |
2618 | + </LetVariable> |
2619 | + <ReturnClause> |
2620 | + <TryCatchIterator> |
2621 | <flwor::FLWORIterator> |
2622 | - <ForVariable name="$$opt_temp_0"> |
2623 | - <HoistIterator> |
2624 | - <ErrorIterator/> |
2625 | - </HoistIterator> |
2626 | - </ForVariable> |
2627 | - <ReturnClause> |
2628 | - <SequentialIterator> |
2629 | - <CreateInternalIndexIterator name="xs:QName(,,tempIndex0)"> |
2630 | - <flwor::FLWORIterator> |
2631 | - <ForVariable name="$$opt_temp_3"> |
2632 | - <NodeSortIterator distinct="true" ascending="true"> |
2633 | - <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,id)" typename="*" nill allowed="0"> |
2634 | - <FunctionTraceIterator> |
2635 | - <flwor::FLWORIterator> |
2636 | - <ForVariable name="$$opt_temp_0"> |
2637 | - <HoistIterator> |
2638 | - <UnhoistIterator> |
2639 | - <ForVarIterator varname="$$opt_temp_0"/> |
2640 | - </UnhoistIterator> |
2641 | - </HoistIterator> |
2642 | - </ForVariable> |
2643 | - <ForVariable name="i"> |
2644 | - <UnhoistIterator> |
2645 | - <LetVarIterator varname="$$opt_temp_1"/> |
2646 | - </UnhoistIterator> |
2647 | - </ForVariable> |
2648 | - <ReturnClause> |
2649 | - <IfThenElseIterator> |
2650 | - <TypedValueCompareIterator_INTEGER> |
2651 | - <NumArithIterator_ModOperation> |
2652 | - <ForVarIterator varname="i"/> |
2653 | - <SingletonIterator value="xs:integer(2)"/> |
2654 | - </NumArithIterator_ModOperation> |
2655 | - <SingletonIterator value="xs:integer(0)"/> |
2656 | - </TypedValueCompareIterator_INTEGER> |
2657 | - <ElementIterator> |
2658 | - <SingletonIterator value="xs:QName(,,a)"/> |
2659 | - <AttributeIterator qname="xs:QName(,,id)"> |
2660 | - <EnclosedIterator attr_cont="true"> |
2661 | - <ForVarIterator varname="i"/> |
2662 | - </EnclosedIterator> |
2663 | - </AttributeIterator> |
2664 | - </ElementIterator> |
2665 | - <UnhoistIterator> |
2666 | - <ForVarIterator varname="$$opt_temp_0"/> |
2667 | - </UnhoistIterator> |
2668 | - </IfThenElseIterator> |
2669 | - </ReturnClause> |
2670 | - </flwor::FLWORIterator> |
2671 | - </FunctionTraceIterator> |
2672 | - </AttributeAxisIterator> |
2673 | - </NodeSortIterator> |
2674 | - </ForVariable> |
2675 | - <ReturnClause> |
2676 | - <ValueIndexEntryBuilderIterator> |
2677 | - <ForVarIterator varname="$$opt_temp_3"/> |
2678 | - <CastIterator type="xs:string"> |
2679 | - <FnDataIterator> |
2680 | - <ForVarIterator varname="$$opt_temp_3"/> |
2681 | - </FnDataIterator> |
2682 | - </CastIterator> |
2683 | - </ValueIndexEntryBuilderIterator> |
2684 | - </ReturnClause> |
2685 | - </flwor::FLWORIterator> |
2686 | - </CreateInternalIndexIterator> |
2687 | + <LetVariable name="$$opt_temp_5" materialize="true"> |
2688 | + <CreateInternalIndexIterator name="xs:QName(,,tempIndex0)"> |
2689 | <flwor::FLWORIterator> |
2690 | - <ForVariable name="i"> |
2691 | + <ForVariable name="$$opt_temp_3"> |
2692 | <NodeSortIterator distinct="true" ascending="true"> |
2693 | <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,id)" typename="*" nill allowed="0"> |
2694 | <FunctionTraceIterator> |
2695 | <flwor::FLWORIterator> |
2696 | + <ForVariable name="$$opt_temp_0"> |
2697 | + <HoistIterator> |
2698 | + <UnhoistIterator> |
2699 | + <ForVarIterator varname="$$opt_temp_0"/> |
2700 | + </UnhoistIterator> |
2701 | + </HoistIterator> |
2702 | + </ForVariable> |
2703 | <ForVariable name="i"> |
2704 | - <OpToIterator> |
2705 | - <SingletonIterator value="xs:integer(1)"/> |
2706 | - <SingletonIterator value="xs:integer(10)"/> |
2707 | - </OpToIterator> |
2708 | + <UnhoistIterator> |
2709 | + <LetVarIterator varname="$$opt_temp_1"/> |
2710 | + </UnhoistIterator> |
2711 | </ForVariable> |
2712 | <ReturnClause> |
2713 | - <ElementIterator> |
2714 | - <SingletonIterator value="xs:QName(,,b)"/> |
2715 | - <AttributeIterator qname="xs:QName(,,id)"> |
2716 | - <EnclosedIterator attr_cont="true"> |
2717 | + <IfThenElseIterator> |
2718 | + <TypedValueCompareIterator_INTEGER> |
2719 | + <NumArithIterator_ModOperation> |
2720 | <ForVarIterator varname="i"/> |
2721 | - </EnclosedIterator> |
2722 | - </AttributeIterator> |
2723 | - </ElementIterator> |
2724 | + <SingletonIterator value="xs:integer(2)"/> |
2725 | + </NumArithIterator_ModOperation> |
2726 | + <SingletonIterator value="xs:integer(0)"/> |
2727 | + </TypedValueCompareIterator_INTEGER> |
2728 | + <ElementIterator> |
2729 | + <SingletonIterator value="xs:QName(,,a)"/> |
2730 | + <AttributeIterator qname="xs:QName(,,id)"> |
2731 | + <EnclosedIterator attr_cont="true"> |
2732 | + <ForVarIterator varname="i"/> |
2733 | + </EnclosedIterator> |
2734 | + </AttributeIterator> |
2735 | + </ElementIterator> |
2736 | + <UnhoistIterator> |
2737 | + <ForVarIterator varname="$$opt_temp_0"/> |
2738 | + </UnhoistIterator> |
2739 | + </IfThenElseIterator> |
2740 | </ReturnClause> |
2741 | </flwor::FLWORIterator> |
2742 | </FunctionTraceIterator> |
2743 | </AttributeAxisIterator> |
2744 | </NodeSortIterator> |
2745 | </ForVariable> |
2746 | - <LetVariable name="$$opt_temp_2" materialize="true"> |
2747 | - <HoistIterator> |
2748 | + <ReturnClause> |
2749 | + <ValueIndexEntryBuilderIterator> |
2750 | + <ForVarIterator varname="$$opt_temp_3"/> |
2751 | <CastIterator type="xs:string"> |
2752 | <FnDataIterator> |
2753 | - <ForVarIterator varname="i"/> |
2754 | + <ForVarIterator varname="$$opt_temp_3"/> |
2755 | </FnDataIterator> |
2756 | </CastIterator> |
2757 | - </HoistIterator> |
2758 | - </LetVariable> |
2759 | - <ForVariable name="j"> |
2760 | - <ProbeIndexPointValueIterator> |
2761 | - <SingletonIterator value="xs:QName(,,tempIndex0)"/> |
2762 | - <UnhoistIterator> |
2763 | - <LetVarIterator varname="$$opt_temp_2"/> |
2764 | - </UnhoistIterator> |
2765 | - </ProbeIndexPointValueIterator> |
2766 | - </ForVariable> |
2767 | - <ReturnClause> |
2768 | - <ForVarIterator varname="i"/> |
2769 | + </ValueIndexEntryBuilderIterator> |
2770 | </ReturnClause> |
2771 | </flwor::FLWORIterator> |
2772 | - </SequentialIterator> |
2773 | + </CreateInternalIndexIterator> |
2774 | + </LetVariable> |
2775 | + <ForVariable name="i"> |
2776 | + <NodeSortIterator distinct="true" ascending="true"> |
2777 | + <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,id)" typename="*" nill allowed="0"> |
2778 | + <FunctionTraceIterator> |
2779 | + <flwor::FLWORIterator> |
2780 | + <ForVariable name="i"> |
2781 | + <OpToIterator> |
2782 | + <SingletonIterator value="xs:integer(1)"/> |
2783 | + <SingletonIterator value="xs:integer(10)"/> |
2784 | + </OpToIterator> |
2785 | + </ForVariable> |
2786 | + <ReturnClause> |
2787 | + <ElementIterator> |
2788 | + <SingletonIterator value="xs:QName(,,b)"/> |
2789 | + <AttributeIterator qname="xs:QName(,,id)"> |
2790 | + <EnclosedIterator attr_cont="true"> |
2791 | + <ForVarIterator varname="i"/> |
2792 | + </EnclosedIterator> |
2793 | + </AttributeIterator> |
2794 | + </ElementIterator> |
2795 | + </ReturnClause> |
2796 | + </flwor::FLWORIterator> |
2797 | + </FunctionTraceIterator> |
2798 | + </AttributeAxisIterator> |
2799 | + </NodeSortIterator> |
2800 | + </ForVariable> |
2801 | + <LetVariable name="$$opt_temp_2" materialize="true"> |
2802 | + <HoistIterator> |
2803 | + <CastIterator type="xs:string"> |
2804 | + <FnDataIterator> |
2805 | + <ForVarIterator varname="i"/> |
2806 | + </FnDataIterator> |
2807 | + </CastIterator> |
2808 | + </HoistIterator> |
2809 | + </LetVariable> |
2810 | + <ForVariable name="j"> |
2811 | + <ProbeIndexPointValueIterator> |
2812 | + <SingletonIterator value="xs:QName(,,tempIndex0)"/> |
2813 | + <UnhoistIterator> |
2814 | + <LetVarIterator varname="$$opt_temp_2"/> |
2815 | + </UnhoistIterator> |
2816 | + </ProbeIndexPointValueIterator> |
2817 | + </ForVariable> |
2818 | + <ReturnClause> |
2819 | + <ForVarIterator varname="i"/> |
2820 | </ReturnClause> |
2821 | </flwor::FLWORIterator> |
2822 | - </ReturnClause> |
2823 | - </flwor::FLWORIterator> |
2824 | - <SingletonIterator value="xs:string(caught)"/> |
2825 | -</TryCatchIterator> |
2826 | + <SingletonIterator value="xs:string(caught)"/> |
2827 | + </TryCatchIterator> |
2828 | + </ReturnClause> |
2829 | +</flwor::FLWORIterator> |
2830 | |
2831 | |
2832 | === modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/idx11.iter' |
2833 | --- test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/idx11.iter 2013-02-21 16:34:45 +0000 |
2834 | +++ test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/idx11.iter 2013-05-16 10:15:45 +0000 |
2835 | @@ -7,26 +7,41 @@ |
2836 | |
2837 | Iterator tree for main query: |
2838 | <flwor::FLWORIterator> |
2839 | - <LetVariable name="$$opt_temp_2" materialize="true"> |
2840 | + <LetVariable name="$$opt_temp_1" materialize="true"> |
2841 | + <HoistIterator> |
2842 | + <FnConcatIterator> |
2843 | + <SingletonIterator value="xs:integer(1)"/> |
2844 | + <SingletonIterator value="xs:integer(2)"/> |
2845 | + <SingletonIterator value="xs:integer(2)"/> |
2846 | + <SingletonIterator value="xs:integer(3)"/> |
2847 | + </FnConcatIterator> |
2848 | + </HoistIterator> |
2849 | + </LetVariable> |
2850 | + <LetVariable name="$$opt_temp_5" materialize="true"> |
2851 | <CreateInternalIndexIterator name="xs:QName(,,tempIndex0)"> |
2852 | <flwor::FLWORIterator> |
2853 | - <ForVariable name="$$opt_temp_0"> |
2854 | - <FnConcatIterator> |
2855 | - <SingletonIterator value="xs:integer(1)"/> |
2856 | - <SingletonIterator value="xs:integer(2)"/> |
2857 | - <SingletonIterator value="xs:integer(2)"/> |
2858 | - <SingletonIterator value="xs:integer(3)"/> |
2859 | - </FnConcatIterator> |
2860 | + <ForVariable name="$$opt_temp_3"> |
2861 | + <UnhoistIterator> |
2862 | + <LetVarIterator varname="$$opt_temp_1"/> |
2863 | + </UnhoistIterator> |
2864 | </ForVariable> |
2865 | <ReturnClause> |
2866 | <ValueIndexEntryBuilderIterator> |
2867 | - <ForVarIterator varname="$$opt_temp_0"/> |
2868 | - <ForVarIterator varname="$$opt_temp_0"/> |
2869 | + <ForVarIterator varname="$$opt_temp_3"/> |
2870 | + <ForVarIterator varname="$$opt_temp_3"/> |
2871 | </ValueIndexEntryBuilderIterator> |
2872 | </ReturnClause> |
2873 | </flwor::FLWORIterator> |
2874 | </CreateInternalIndexIterator> |
2875 | </LetVariable> |
2876 | + <LetVariable name="$$opt_temp_0" materialize="true"> |
2877 | + <HoistIterator> |
2878 | + <FnConcatIterator> |
2879 | + <SingletonIterator value="xs:integer(1)"/> |
2880 | + <SingletonIterator value="xs:integer(2)"/> |
2881 | + </FnConcatIterator> |
2882 | + </HoistIterator> |
2883 | + </LetVariable> |
2884 | <ForVariable name="x"> |
2885 | <FnConcatIterator> |
2886 | <SingletonIterator value="xs:integer(1)"/> |
2887 | @@ -35,11 +50,17 @@ |
2888 | </FnConcatIterator> |
2889 | </ForVariable> |
2890 | <LetVariable name="y" materialize="true"> |
2891 | - <FnConcatIterator> |
2892 | - <SingletonIterator value="xs:integer(1)"/> |
2893 | - <SingletonIterator value="xs:integer(2)"/> |
2894 | - </FnConcatIterator> |
2895 | + <UnhoistIterator> |
2896 | + <LetVarIterator varname="$$opt_temp_0"/> |
2897 | + </UnhoistIterator> |
2898 | </LetVariable> |
2899 | + <ForVariable name="$$opt_temp_2"> |
2900 | + <HoistIterator> |
2901 | + <FnCountIterator> |
2902 | + <LetVarIterator varname="y"/> |
2903 | + </FnCountIterator> |
2904 | + </HoistIterator> |
2905 | + </ForVariable> |
2906 | <ForVariable name="$$context-item"> |
2907 | <ProbeIndexPointValueIterator> |
2908 | <SingletonIterator value="xs:QName(,,tempIndex0)"/> |
2909 | @@ -49,9 +70,9 @@ |
2910 | <WhereClause> |
2911 | <TypedValueCompareIterator_INTEGER> |
2912 | <ForVarIterator varname="$$context-item"/> |
2913 | - <FnCountIterator> |
2914 | - <LetVarIterator varname="y"/> |
2915 | - </FnCountIterator> |
2916 | + <UnhoistIterator> |
2917 | + <ForVarIterator varname="$$opt_temp_2"/> |
2918 | + </UnhoistIterator> |
2919 | </TypedValueCompareIterator_INTEGER> |
2920 | </WhereClause> |
2921 | <ReturnClause> |
2922 | |
2923 | === modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/idx9.iter' |
2924 | --- test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/idx9.iter 2013-02-21 16:34:45 +0000 |
2925 | +++ test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/idx9.iter 2013-05-16 10:15:45 +0000 |
2926 | @@ -31,21 +31,21 @@ |
2927 | <flwor::ForIterator> |
2928 | <ForVariable name="$$context-item"/> |
2929 | <flwor::LetIterator> |
2930 | - <LetVariable name="$$opt_temp_2" materialize="true"/> |
2931 | + <LetVariable name="$$opt_temp_3" materialize="true"/> |
2932 | <flwor::TupleSourceIterator/> |
2933 | <CreateInternalIndexIterator name="xs:QName(,,tempIndex0)"> |
2934 | <flwor::FLWORIterator> |
2935 | - <ForVariable name="$$opt_temp_0"> |
2936 | + <ForVariable name="$$opt_temp_1"> |
2937 | <ZorbaCollectionIterator> |
2938 | <SingletonIterator value="xs:QName(http://foo.com,foo,game)"/> |
2939 | </ZorbaCollectionIterator> |
2940 | </ForVariable> |
2941 | <ReturnClause> |
2942 | <GeneralIndexEntryBuilderIterator> |
2943 | - <ForVarIterator varname="$$opt_temp_0"/> |
2944 | + <ForVarIterator varname="$$opt_temp_1"/> |
2945 | <FnDataIterator> |
2946 | <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,gid)" typename="*" nill allowed="0"> |
2947 | - <ForVarIterator varname="$$opt_temp_0"/> |
2948 | + <ForVarIterator varname="$$opt_temp_1"/> |
2949 | </AttributeAxisIterator> |
2950 | </FnDataIterator> |
2951 | </GeneralIndexEntryBuilderIterator> |
2952 | @@ -70,11 +70,15 @@ |
2953 | <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,result)" typename="*" nill allowed="0"> |
2954 | <ProbeIndexPointGeneralIterator> |
2955 | <SingletonIterator value="xs:QName(,,tempIndex0)"/> |
2956 | - <FnDataIterator> |
2957 | - <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,gid)" typename="*" nill allowed="0"> |
2958 | - <ForVarIterator varname="$$context-item"/> |
2959 | - </AttributeAxisIterator> |
2960 | - </FnDataIterator> |
2961 | + <UnhoistIterator> |
2962 | + <HoistIterator> |
2963 | + <FnDataIterator> |
2964 | + <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,gid)" typename="*" nill allowed="0"> |
2965 | + <ForVarIterator varname="$$context-item"/> |
2966 | + </AttributeAxisIterator> |
2967 | + </FnDataIterator> |
2968 | + </HoistIterator> |
2969 | + </UnhoistIterator> |
2970 | </ProbeIndexPointGeneralIterator> |
2971 | </ChildAxisIterator> |
2972 | </FnBooleanIterator> |
2973 | |
2974 | === modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/index/match_veq_04.iter' |
2975 | --- test/rbkt/ExpCompilerResults/IterPlan/zorba/index/match_veq_04.iter 2013-02-18 01:12:45 +0000 |
2976 | +++ test/rbkt/ExpCompilerResults/IterPlan/zorba/index/match_veq_04.iter 2013-05-16 10:15:45 +0000 |
2977 | @@ -186,16 +186,23 @@ |
2978 | <LetVariable name="id" materialize="true"> |
2979 | <CtxVarIterator varid="5" varname="external_id" varkind="global"/> |
2980 | </LetVariable> |
2981 | + <LetVariable name="$$opt_temp_0" materialize="true"> |
2982 | + <HoistIterator> |
2983 | + <PromoteIterator type="xs:anyAtomicType"> |
2984 | + <FnDataIterator> |
2985 | + <LetVarIterator varname="id"/> |
2986 | + </FnDataIterator> |
2987 | + </PromoteIterator> |
2988 | + </HoistIterator> |
2989 | + </LetVariable> |
2990 | <LetVariable name="session" materialize="true"> |
2991 | <flwor::FLWORIterator> |
2992 | <ForVariable name="$$context-item"> |
2993 | <ProbeIndexPointValueIterator> |
2994 | <SingletonIterator value="xs:QName(www.sessions.com,sessions,session-index)"/> |
2995 | - <PromoteIterator type="xs:anyAtomicType"> |
2996 | - <FnDataIterator> |
2997 | - <LetVarIterator varname="id"/> |
2998 | - </FnDataIterator> |
2999 | - </PromoteIterator> |
3000 | + <UnhoistIterator> |
3001 | + <LetVarIterator varname="$$opt_temp_0"/> |
3002 | + </UnhoistIterator> |
3003 | </ProbeIndexPointValueIterator> |
3004 | </ForVariable> |
3005 | <ReturnClause> |
3006 | |
3007 | === modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/index/match_veq_05.iter' |
3008 | --- test/rbkt/ExpCompilerResults/IterPlan/zorba/index/match_veq_05.iter 2013-02-18 01:12:45 +0000 |
3009 | +++ test/rbkt/ExpCompilerResults/IterPlan/zorba/index/match_veq_05.iter 2013-05-16 10:15:45 +0000 |
3010 | @@ -263,16 +263,23 @@ |
3011 | <LetVariable name="id" materialize="true"> |
3012 | <CtxVarIterator varid="5" varname="external_id" varkind="global"/> |
3013 | </LetVariable> |
3014 | + <LetVariable name="$$opt_temp_0" materialize="true"> |
3015 | + <HoistIterator> |
3016 | + <PromoteIterator type="xs:anyAtomicType"> |
3017 | + <FnDataIterator> |
3018 | + <LetVarIterator varname="id"/> |
3019 | + </FnDataIterator> |
3020 | + </PromoteIterator> |
3021 | + </HoistIterator> |
3022 | + </LetVariable> |
3023 | <LetVariable name="session" materialize="true"> |
3024 | <flwor::FLWORIterator> |
3025 | <ForVariable name="$$context-item"> |
3026 | <ProbeIndexPointValueIterator> |
3027 | <SingletonIterator value="xs:QName(www.sessions.com,sessions,session-index)"/> |
3028 | - <PromoteIterator type="xs:anyAtomicType"> |
3029 | - <FnDataIterator> |
3030 | - <LetVarIterator varname="id"/> |
3031 | - </FnDataIterator> |
3032 | - </PromoteIterator> |
3033 | + <UnhoistIterator> |
3034 | + <LetVarIterator varname="$$opt_temp_0"/> |
3035 | + </UnhoistIterator> |
3036 | </ProbeIndexPointValueIterator> |
3037 | </ForVariable> |
3038 | <WhereClause> |
3039 | |
3040 | === modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/index/match_veq_06.iter' |
3041 | --- test/rbkt/ExpCompilerResults/IterPlan/zorba/index/match_veq_06.iter 2013-05-04 20:20:05 +0000 |
3042 | +++ test/rbkt/ExpCompilerResults/IterPlan/zorba/index/match_veq_06.iter 2013-05-16 10:15:45 +0000 |
3043 | @@ -134,13 +134,6 @@ |
3044 | </FnTokenizeIterator> |
3045 | </CtxVarDeclareIterator> |
3046 | <flwor::FLWORIterator> |
3047 | - <LetVariable name="$$opt_temp_0" materialize="true"> |
3048 | - <HoistIterator> |
3049 | - <ZorbaCollectionIterator> |
3050 | - <CtxVarIterator varid="4" varname="data:parents" varkind="global"/> |
3051 | - </ZorbaCollectionIterator> |
3052 | - </HoistIterator> |
3053 | - </LetVariable> |
3054 | <ForVariable name="segment"> |
3055 | <CtxVarIterator varid="2" varname="segments" varkind="local"/> |
3056 | </ForVariable> |
3057 | |
3058 | === modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/index/match_veq_10.iter' |
3059 | --- test/rbkt/ExpCompilerResults/IterPlan/zorba/index/match_veq_10.iter 2013-02-21 22:41:14 +0000 |
3060 | +++ test/rbkt/ExpCompilerResults/IterPlan/zorba/index/match_veq_10.iter 2013-05-16 10:15:45 +0000 |
3061 | @@ -48,37 +48,45 @@ |
3062 | </ApplyIterator> |
3063 | <flwor::TupleStreamIterator> |
3064 | <flwor::OrderByIterator> |
3065 | - <OrderByForVariable inputVar="id : "/> |
3066 | <OrderByForVariable inputVar="count : "/> |
3067 | + <OrderByLetVariable inputVar="$$opt_temp_0 : "/> |
3068 | <OrderBySpec> |
3069 | <ForVarIterator varname="count"/> |
3070 | </OrderBySpec> |
3071 | <flwor::ForIterator> |
3072 | <ForVariable name="count"/> |
3073 | - <flwor::GroupByIterator> |
3074 | - <flwor::ForIterator> |
3075 | - <ForVariable name="answers"/> |
3076 | - <flwor::TupleSourceIterator/> |
3077 | - <ZorbaCollectionIterator> |
3078 | - <SingletonIterator value="xs:QName(http://28.io/collections,db28,answers)"/> |
3079 | - </ZorbaCollectionIterator> |
3080 | - </flwor::ForIterator> |
3081 | - <Spec> |
3082 | - <TreatIterator quant="?"> |
3083 | - <FnDataIterator> |
3084 | - <JSONObjectValueIterator> |
3085 | - <ForVarIterator varname="answers"/> |
3086 | - <SingletonIterator value="xs:string(question_id)"/> |
3087 | - </JSONObjectValueIterator> |
3088 | - </FnDataIterator> |
3089 | - </TreatIterator> |
3090 | - <GroupVariable/> |
3091 | - </Spec> |
3092 | - <Spec> |
3093 | - <ForVarIterator varname="answers"/> |
3094 | - <NonGroupVariable/> |
3095 | - </Spec> |
3096 | - </flwor::GroupByIterator> |
3097 | + <flwor::LetIterator> |
3098 | + <LetVariable name="$$opt_temp_0" materialize="true"/> |
3099 | + <flwor::GroupByIterator> |
3100 | + <flwor::ForIterator> |
3101 | + <ForVariable name="answers"/> |
3102 | + <flwor::TupleSourceIterator/> |
3103 | + <ZorbaCollectionIterator> |
3104 | + <SingletonIterator value="xs:QName(http://28.io/collections,db28,answers)"/> |
3105 | + </ZorbaCollectionIterator> |
3106 | + </flwor::ForIterator> |
3107 | + <Spec> |
3108 | + <TreatIterator quant="?"> |
3109 | + <FnDataIterator> |
3110 | + <JSONObjectValueIterator> |
3111 | + <ForVarIterator varname="answers"/> |
3112 | + <SingletonIterator value="xs:string(question_id)"/> |
3113 | + </JSONObjectValueIterator> |
3114 | + </FnDataIterator> |
3115 | + </TreatIterator> |
3116 | + <GroupVariable/> |
3117 | + </Spec> |
3118 | + <Spec> |
3119 | + <ForVarIterator varname="answers"/> |
3120 | + <NonGroupVariable/> |
3121 | + </Spec> |
3122 | + </flwor::GroupByIterator> |
3123 | + <HoistIterator> |
3124 | + <CastIterator type="xs:string"> |
3125 | + <ForVarIterator varname="id"/> |
3126 | + </CastIterator> |
3127 | + </HoistIterator> |
3128 | + </flwor::LetIterator> |
3129 | <FnCountIterator> |
3130 | <LetVarIterator varname="answers"/> |
3131 | </FnCountIterator> |
3132 | @@ -92,12 +100,12 @@ |
3133 | <ForVariable name="$$context-item"> |
3134 | <ProbeIndexRangeValueIterator> |
3135 | <SingletonIterator value="xs:QName(http://28.io/collections,db28,question-id-idx)"/> |
3136 | - <CastIterator type="xs:string"> |
3137 | - <ForVarIterator varname="id"/> |
3138 | - </CastIterator> |
3139 | - <CastIterator type="xs:string"> |
3140 | - <ForVarIterator varname="id"/> |
3141 | - </CastIterator> |
3142 | + <UnhoistIterator> |
3143 | + <LetVarIterator varname="$$opt_temp_0"/> |
3144 | + </UnhoistIterator> |
3145 | + <UnhoistIterator> |
3146 | + <LetVarIterator varname="$$opt_temp_0"/> |
3147 | + </UnhoistIterator> |
3148 | <SingletonIterator value="xs:boolean(true)"/> |
3149 | <SingletonIterator value="xs:boolean(true)"/> |
3150 | <SingletonIterator value="xs:boolean(true)"/> |
3151 | |
3152 | === modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/q4.iter' |
3153 | --- test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/q4.iter 2013-02-07 17:24:36 +0000 |
3154 | +++ test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/q4.iter 2013-05-16 10:15:45 +0000 |
3155 | @@ -31,6 +31,13 @@ |
3156 | </ChildAxisIterator> |
3157 | </ChildAxisIterator> |
3158 | </ForVariable> |
3159 | + <LetVariable name="$$opt_temp_0" materialize="true"> |
3160 | + <HoistIterator> |
3161 | + <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,bidder)" typename="*" nill allowed="0"> |
3162 | + <ForVarIterator varname="b"/> |
3163 | + </ChildAxisIterator> |
3164 | + </HoistIterator> |
3165 | + </LetVariable> |
3166 | <WhereClause> |
3167 | <FnExistsIterator> |
3168 | <flwor::TupleStreamIterator> |
3169 | @@ -63,9 +70,9 @@ |
3170 | <SingletonIterator value="xs:string(person20)"/> |
3171 | </CompareIterator> |
3172 | </flwor::WhereIterator> |
3173 | - <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,bidder)" typename="*" nill allowed="0"> |
3174 | - <ForVarIterator varname="b"/> |
3175 | - </ChildAxisIterator> |
3176 | + <UnhoistIterator> |
3177 | + <LetVarIterator varname="$$opt_temp_0"/> |
3178 | + </UnhoistIterator> |
3179 | </flwor::ForIterator> |
3180 | <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,personref)" typename="*" nill allowed="0"> |
3181 | <ForVarIterator varname="$$context-item"/> |
3182 | |
3183 | === added file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/optim/hoist_trycatch_01.iter' |
3184 | --- test/rbkt/ExpCompilerResults/IterPlan/zorba/optim/hoist_trycatch_01.iter 1970-01-01 00:00:00 +0000 |
3185 | +++ test/rbkt/ExpCompilerResults/IterPlan/zorba/optim/hoist_trycatch_01.iter 2013-05-16 10:15:45 +0000 |
3186 | @@ -0,0 +1,211 @@ |
3187 | +Iterator tree for main query: |
3188 | +<SequentialIterator> |
3189 | + <CtxVarDeclareIterator varid="4" varname="x"/> |
3190 | + <CtxVarDeclareIterator varid="5" varname="sales"> |
3191 | + <ElementIterator copyInputNodes="false"> |
3192 | + <SingletonIterator value="xs:QName(,,sales)"/> |
3193 | + <FnConcatIterator> |
3194 | + <ElementIterator copyInputNodes="false"> |
3195 | + <SingletonIterator value="xs:QName(,,sale)"/> |
3196 | + <FnConcatIterator> |
3197 | + <AttributeIterator qname="xs:QName(,,pid)"> |
3198 | + <SingletonIterator value="xs:string(3)"/> |
3199 | + </AttributeIterator> |
3200 | + <AttributeIterator qname="xs:QName(,,locid)"> |
3201 | + <SingletonIterator value="xs:string(5)"/> |
3202 | + </AttributeIterator> |
3203 | + <AttributeIterator qname="xs:QName(,,qty)"> |
3204 | + <SingletonIterator value="xs:string(3)"/> |
3205 | + </AttributeIterator> |
3206 | + <AttributeIterator qname="xs:QName(,,date)"> |
3207 | + <SingletonIterator value="xs:string(2013-01-01)"/> |
3208 | + </AttributeIterator> |
3209 | + </FnConcatIterator> |
3210 | + </ElementIterator> |
3211 | + <ElementIterator copyInputNodes="false"> |
3212 | + <SingletonIterator value="xs:QName(,,sale)"/> |
3213 | + <FnConcatIterator> |
3214 | + <AttributeIterator qname="xs:QName(,,pid)"> |
3215 | + <SingletonIterator value="xs:string(3)"/> |
3216 | + </AttributeIterator> |
3217 | + <AttributeIterator qname="xs:QName(,,locid)"> |
3218 | + <SingletonIterator value="xs:string(5)"/> |
3219 | + </AttributeIterator> |
3220 | + <AttributeIterator qname="xs:QName(,,qty)"> |
3221 | + <SingletonIterator value="xs:string(5)"/> |
3222 | + </AttributeIterator> |
3223 | + <AttributeIterator qname="xs:QName(,,date)"> |
3224 | + <SingletonIterator value="xs:string(2013-01-02)"/> |
3225 | + </AttributeIterator> |
3226 | + </FnConcatIterator> |
3227 | + </ElementIterator> |
3228 | + <ElementIterator copyInputNodes="false"> |
3229 | + <SingletonIterator value="xs:QName(,,sale)"/> |
3230 | + <FnConcatIterator> |
3231 | + <AttributeIterator qname="xs:QName(,,pid)"> |
3232 | + <SingletonIterator value="xs:string(2)"/> |
3233 | + </AttributeIterator> |
3234 | + <AttributeIterator qname="xs:QName(,,locid)"> |
3235 | + <SingletonIterator value="xs:string(4)"/> |
3236 | + </AttributeIterator> |
3237 | + <AttributeIterator qname="xs:QName(,,qty)"> |
3238 | + <SingletonIterator value="xs:string(1)"/> |
3239 | + </AttributeIterator> |
3240 | + <AttributeIterator qname="xs:QName(,,date)"> |
3241 | + <SingletonIterator value="xs:string(2013-01-01)"/> |
3242 | + </AttributeIterator> |
3243 | + </FnConcatIterator> |
3244 | + </ElementIterator> |
3245 | + <ElementIterator copyInputNodes="false"> |
3246 | + <SingletonIterator value="xs:QName(,,sale)"/> |
3247 | + <FnConcatIterator> |
3248 | + <AttributeIterator qname="xs:QName(,,pid)"> |
3249 | + <SingletonIterator value="xs:string(2)"/> |
3250 | + </AttributeIterator> |
3251 | + <AttributeIterator qname="xs:QName(,,locid)"> |
3252 | + <SingletonIterator value="xs:string(4)"/> |
3253 | + </AttributeIterator> |
3254 | + <AttributeIterator qname="xs:QName(,,qty)"> |
3255 | + <SingletonIterator value="xs:string(1)"/> |
3256 | + </AttributeIterator> |
3257 | + <AttributeIterator qname="xs:QName(,,date)"> |
3258 | + <SingletonIterator value="xs:string(2014-01-01)"/> |
3259 | + </AttributeIterator> |
3260 | + </FnConcatIterator> |
3261 | + </ElementIterator> |
3262 | + <ElementIterator copyInputNodes="false"> |
3263 | + <SingletonIterator value="xs:QName(,,sale)"/> |
3264 | + <FnConcatIterator> |
3265 | + <AttributeIterator qname="xs:QName(,,pid)"> |
3266 | + <SingletonIterator value="xs:string(2)"/> |
3267 | + </AttributeIterator> |
3268 | + <AttributeIterator qname="xs:QName(,,locid)"> |
3269 | + <SingletonIterator value="xs:string(7)"/> |
3270 | + </AttributeIterator> |
3271 | + <AttributeIterator qname="xs:QName(,,qty)"> |
3272 | + <SingletonIterator value="xs:string(1)"/> |
3273 | + </AttributeIterator> |
3274 | + <AttributeIterator qname="xs:QName(,,date)"> |
3275 | + <SingletonIterator value="xs:string(2014-01-01)"/> |
3276 | + </AttributeIterator> |
3277 | + </FnConcatIterator> |
3278 | + </ElementIterator> |
3279 | + </FnConcatIterator> |
3280 | + </ElementIterator> |
3281 | + </CtxVarDeclareIterator> |
3282 | + <CtxVarDeclareIterator varid="6" varname="locations"> |
3283 | + <ElementIterator> |
3284 | + <SingletonIterator value="xs:QName(,,locations)"/> |
3285 | + <FnConcatIterator> |
3286 | + <ElementIterator> |
3287 | + <SingletonIterator value="xs:QName(,,loc)"/> |
3288 | + <FnConcatIterator> |
3289 | + <AttributeIterator qname="xs:QName(,,id)"> |
3290 | + <SingletonIterator value="xs:string(5)"/> |
3291 | + </AttributeIterator> |
3292 | + <AttributeIterator qname="xs:QName(,,city)"> |
3293 | + <SingletonIterator value="xs:string(paris)"/> |
3294 | + </AttributeIterator> |
3295 | + </FnConcatIterator> |
3296 | + </ElementIterator> |
3297 | + <ElementIterator> |
3298 | + <SingletonIterator value="xs:QName(,,loc)"/> |
3299 | + <FnConcatIterator> |
3300 | + <AttributeIterator qname="xs:QName(,,id)"> |
3301 | + <SingletonIterator value="xs:string(4)"/> |
3302 | + </AttributeIterator> |
3303 | + <AttributeIterator qname="xs:QName(,,city)"> |
3304 | + <SingletonIterator value="xs:string(san fransisco)"/> |
3305 | + </AttributeIterator> |
3306 | + </FnConcatIterator> |
3307 | + </ElementIterator> |
3308 | + <ElementIterator> |
3309 | + <SingletonIterator value="xs:QName(,,loc)"/> |
3310 | + <FnConcatIterator> |
3311 | + <AttributeIterator qname="xs:QName(,,id)"> |
3312 | + <SingletonIterator value="xs:string(7)"/> |
3313 | + </AttributeIterator> |
3314 | + <AttributeIterator qname="xs:QName(,,city)"> |
3315 | + <SingletonIterator value="xs:string(chania)"/> |
3316 | + </AttributeIterator> |
3317 | + </FnConcatIterator> |
3318 | + </ElementIterator> |
3319 | + </FnConcatIterator> |
3320 | + </ElementIterator> |
3321 | + </CtxVarDeclareIterator> |
3322 | + <flwor::FLWORIterator> |
3323 | + <LetVariable name="$$opt_temp_0" materialize="true"> |
3324 | + <HoistIterator> |
3325 | + <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,loc)" typename="*" nill allowed="0"> |
3326 | + <CtxVarIterator varid="6" varname="locations" varkind="global"/> |
3327 | + </ChildAxisIterator> |
3328 | + </HoistIterator> |
3329 | + </LetVariable> |
3330 | + <ReturnClause> |
3331 | + <TryCatchIterator> |
3332 | + <GenericArithIterator_MultiplyOperation> |
3333 | + <PromoteIterator type="xs:anyAtomicType"> |
3334 | + <FnDataIterator> |
3335 | + <CtxVarIterator varid="4" varname="x" varkind="global"/> |
3336 | + </FnDataIterator> |
3337 | + </PromoteIterator> |
3338 | + <PromoteIterator type="xs:anyAtomicType"> |
3339 | + <FnDataIterator> |
3340 | + <CtxVarIterator varid="4" varname="x" varkind="global"/> |
3341 | + </FnDataIterator> |
3342 | + </PromoteIterator> |
3343 | + </GenericArithIterator_MultiplyOperation> |
3344 | + <flwor::FLWORIterator> |
3345 | + <ForVariable name="s"> |
3346 | + <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,sale)" typename="*" nill allowed="0"> |
3347 | + <CtxVarIterator varid="5" varname="sales" varkind="global"/> |
3348 | + </ChildAxisIterator> |
3349 | + </ForVariable> |
3350 | + <LetVariable name="$$opt_temp_1" materialize="true"> |
3351 | + <HoistIterator> |
3352 | + <PromoteIterator type="xs:anyAtomicType"> |
3353 | + <FnDataIterator> |
3354 | + <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,locid)" typename="*" nill allowed="0"> |
3355 | + <ForVarIterator varname="s"/> |
3356 | + </AttributeAxisIterator> |
3357 | + </FnDataIterator> |
3358 | + </PromoteIterator> |
3359 | + </HoistIterator> |
3360 | + </LetVariable> |
3361 | + <ForVariable name="l"> |
3362 | + <UnhoistIterator> |
3363 | + <LetVarIterator varname="$$opt_temp_0"/> |
3364 | + </UnhoistIterator> |
3365 | + </ForVariable> |
3366 | + <WhereClause> |
3367 | + <FnBooleanIterator> |
3368 | + <CompareIterator> |
3369 | + <UnhoistIterator> |
3370 | + <LetVarIterator varname="$$opt_temp_1"/> |
3371 | + </UnhoistIterator> |
3372 | + <PromoteIterator type="xs:anyAtomicType"> |
3373 | + <FnDataIterator> |
3374 | + <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,id)" typename="*" nill allowed="0"> |
3375 | + <ForVarIterator varname="l"/> |
3376 | + </AttributeAxisIterator> |
3377 | + </FnDataIterator> |
3378 | + </PromoteIterator> |
3379 | + </CompareIterator> |
3380 | + </FnBooleanIterator> |
3381 | + </WhereClause> |
3382 | + <ReturnClause> |
3383 | + <ElementIterator> |
3384 | + <SingletonIterator value="xs:QName(,,sale)"/> |
3385 | + <EnclosedIterator attr_cont="false"> |
3386 | + <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,city)" typename="*" nill allowed="0"> |
3387 | + <ForVarIterator varname="l"/> |
3388 | + </AttributeAxisIterator> |
3389 | + </EnclosedIterator> |
3390 | + </ElementIterator> |
3391 | + </ReturnClause> |
3392 | + </flwor::FLWORIterator> |
3393 | + </TryCatchIterator> |
3394 | + </ReturnClause> |
3395 | + </flwor::FLWORIterator> |
3396 | +</SequentialIterator> |
3397 | + |
3398 | |
3399 | === added file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/optim/hoist_window_01.iter' |
3400 | --- test/rbkt/ExpCompilerResults/IterPlan/zorba/optim/hoist_window_01.iter 1970-01-01 00:00:00 +0000 |
3401 | +++ test/rbkt/ExpCompilerResults/IterPlan/zorba/optim/hoist_window_01.iter 2013-05-16 10:15:45 +0000 |
3402 | @@ -0,0 +1,295 @@ |
3403 | +Iterator tree for const-folded expr: |
3404 | +<OrIterator> |
3405 | + <SingletonIterator value="xs:boolean(false)"/> |
3406 | + <SingletonIterator value="xs:boolean(false)"/> |
3407 | + <SingletonIterator value="xs:boolean(false)"/> |
3408 | +</OrIterator> |
3409 | + |
3410 | +Iterator tree for main query: |
3411 | +<SequentialIterator> |
3412 | + <CtxVarDeclareIterator varid="4" varname="sales"> |
3413 | + <ElementIterator> |
3414 | + <SingletonIterator value="xs:QName(,,sales)"/> |
3415 | + <FnConcatIterator> |
3416 | + <ElementIterator> |
3417 | + <SingletonIterator value="xs:QName(,,sale)"/> |
3418 | + <FnConcatIterator> |
3419 | + <AttributeIterator qname="xs:QName(,,pid)"> |
3420 | + <SingletonIterator value="xs:string(3)"/> |
3421 | + </AttributeIterator> |
3422 | + <AttributeIterator qname="xs:QName(,,locid)"> |
3423 | + <SingletonIterator value="xs:string(5)"/> |
3424 | + </AttributeIterator> |
3425 | + <AttributeIterator qname="xs:QName(,,qty)"> |
3426 | + <SingletonIterator value="xs:string(3)"/> |
3427 | + </AttributeIterator> |
3428 | + <AttributeIterator qname="xs:QName(,,date)"> |
3429 | + <SingletonIterator value="xs:string(2013-01-01)"/> |
3430 | + </AttributeIterator> |
3431 | + </FnConcatIterator> |
3432 | + </ElementIterator> |
3433 | + <ElementIterator> |
3434 | + <SingletonIterator value="xs:QName(,,sale)"/> |
3435 | + <FnConcatIterator> |
3436 | + <AttributeIterator qname="xs:QName(,,pid)"> |
3437 | + <SingletonIterator value="xs:string(3)"/> |
3438 | + </AttributeIterator> |
3439 | + <AttributeIterator qname="xs:QName(,,locid)"> |
3440 | + <SingletonIterator value="xs:string(5)"/> |
3441 | + </AttributeIterator> |
3442 | + <AttributeIterator qname="xs:QName(,,qty)"> |
3443 | + <SingletonIterator value="xs:string(5)"/> |
3444 | + </AttributeIterator> |
3445 | + <AttributeIterator qname="xs:QName(,,date)"> |
3446 | + <SingletonIterator value="xs:string(2013-01-02)"/> |
3447 | + </AttributeIterator> |
3448 | + </FnConcatIterator> |
3449 | + </ElementIterator> |
3450 | + <ElementIterator> |
3451 | + <SingletonIterator value="xs:QName(,,sale)"/> |
3452 | + <FnConcatIterator> |
3453 | + <AttributeIterator qname="xs:QName(,,pid)"> |
3454 | + <SingletonIterator value="xs:string(2)"/> |
3455 | + </AttributeIterator> |
3456 | + <AttributeIterator qname="xs:QName(,,locid)"> |
3457 | + <SingletonIterator value="xs:string(4)"/> |
3458 | + </AttributeIterator> |
3459 | + <AttributeIterator qname="xs:QName(,,qty)"> |
3460 | + <SingletonIterator value="xs:string(1)"/> |
3461 | + </AttributeIterator> |
3462 | + <AttributeIterator qname="xs:QName(,,date)"> |
3463 | + <SingletonIterator value="xs:string(2013-01-01)"/> |
3464 | + </AttributeIterator> |
3465 | + </FnConcatIterator> |
3466 | + </ElementIterator> |
3467 | + <ElementIterator> |
3468 | + <SingletonIterator value="xs:QName(,,sale)"/> |
3469 | + <FnConcatIterator> |
3470 | + <AttributeIterator qname="xs:QName(,,pid)"> |
3471 | + <SingletonIterator value="xs:string(2)"/> |
3472 | + </AttributeIterator> |
3473 | + <AttributeIterator qname="xs:QName(,,locid)"> |
3474 | + <SingletonIterator value="xs:string(4)"/> |
3475 | + </AttributeIterator> |
3476 | + <AttributeIterator qname="xs:QName(,,qty)"> |
3477 | + <SingletonIterator value="xs:string(1)"/> |
3478 | + </AttributeIterator> |
3479 | + <AttributeIterator qname="xs:QName(,,date)"> |
3480 | + <SingletonIterator value="xs:string(2014-01-01)"/> |
3481 | + </AttributeIterator> |
3482 | + </FnConcatIterator> |
3483 | + </ElementIterator> |
3484 | + <ElementIterator> |
3485 | + <SingletonIterator value="xs:QName(,,sale)"/> |
3486 | + <FnConcatIterator> |
3487 | + <AttributeIterator qname="xs:QName(,,pid)"> |
3488 | + <SingletonIterator value="xs:string(2)"/> |
3489 | + </AttributeIterator> |
3490 | + <AttributeIterator qname="xs:QName(,,locid)"> |
3491 | + <SingletonIterator value="xs:string(7)"/> |
3492 | + </AttributeIterator> |
3493 | + <AttributeIterator qname="xs:QName(,,qty)"> |
3494 | + <SingletonIterator value="xs:string(1)"/> |
3495 | + </AttributeIterator> |
3496 | + <AttributeIterator qname="xs:QName(,,date)"> |
3497 | + <SingletonIterator value="xs:string(2014-01-01)"/> |
3498 | + </AttributeIterator> |
3499 | + </FnConcatIterator> |
3500 | + </ElementIterator> |
3501 | + </FnConcatIterator> |
3502 | + </ElementIterator> |
3503 | + </CtxVarDeclareIterator> |
3504 | + <CtxVarDeclareIterator varid="5" varname="locations"> |
3505 | + <ElementIterator copyInputNodes="false"> |
3506 | + <SingletonIterator value="xs:QName(,,locations)"/> |
3507 | + <FnConcatIterator> |
3508 | + <ElementIterator copyInputNodes="false"> |
3509 | + <SingletonIterator value="xs:QName(,,loc)"/> |
3510 | + <FnConcatIterator> |
3511 | + <AttributeIterator qname="xs:QName(,,id)"> |
3512 | + <SingletonIterator value="xs:string(5)"/> |
3513 | + </AttributeIterator> |
3514 | + <AttributeIterator qname="xs:QName(,,city)"> |
3515 | + <SingletonIterator value="xs:string(paris)"/> |
3516 | + </AttributeIterator> |
3517 | + </FnConcatIterator> |
3518 | + </ElementIterator> |
3519 | + <ElementIterator copyInputNodes="false"> |
3520 | + <SingletonIterator value="xs:QName(,,loc)"/> |
3521 | + <FnConcatIterator> |
3522 | + <AttributeIterator qname="xs:QName(,,id)"> |
3523 | + <SingletonIterator value="xs:string(4)"/> |
3524 | + </AttributeIterator> |
3525 | + <AttributeIterator qname="xs:QName(,,city)"> |
3526 | + <SingletonIterator value="xs:string(san fransisco)"/> |
3527 | + </AttributeIterator> |
3528 | + </FnConcatIterator> |
3529 | + </ElementIterator> |
3530 | + <ElementIterator copyInputNodes="false"> |
3531 | + <SingletonIterator value="xs:QName(,,loc)"/> |
3532 | + <FnConcatIterator> |
3533 | + <AttributeIterator qname="xs:QName(,,id)"> |
3534 | + <SingletonIterator value="xs:string(7)"/> |
3535 | + </AttributeIterator> |
3536 | + <AttributeIterator qname="xs:QName(,,city)"> |
3537 | + <SingletonIterator value="xs:string(chania)"/> |
3538 | + </AttributeIterator> |
3539 | + </FnConcatIterator> |
3540 | + </ElementIterator> |
3541 | + </FnConcatIterator> |
3542 | + </ElementIterator> |
3543 | + </CtxVarDeclareIterator> |
3544 | + <flwor::TupleStreamIterator> |
3545 | + <flwor::WindowIterator> |
3546 | + <WindowVariable name="yearly-sales"> |
3547 | + <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,sale)" typename="*" nill allowed="0"> |
3548 | + <CtxVarIterator varid="4" varname="sales" varkind="global"/> |
3549 | + </ChildAxisIterator> |
3550 | + </WindowVariable> |
3551 | + <WinCondVariable name="start-CurrentIn"/> |
3552 | + <WinCondVariable name="start-CurrentInPrevIn"/> |
3553 | + <WinCondVariable name="start-CurrentInPrevInCurrentOut"/> |
3554 | + <AndIterator> |
3555 | + <TypedValueCompareIterator_STRING> |
3556 | + <SubstringIntOptIterator> |
3557 | + <PromoteIterator type="xs:string"> |
3558 | + <FnDataIterator> |
3559 | + <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,date)" typename="*" nill allowed="0"> |
3560 | + <ForVarIterator varname="s"/> |
3561 | + </AttributeAxisIterator> |
3562 | + </FnDataIterator> |
3563 | + </PromoteIterator> |
3564 | + <SingletonIterator value="xs:integer(1)"/> |
3565 | + <SingletonIterator value="xs:integer(4)"/> |
3566 | + </SubstringIntOptIterator> |
3567 | + <SubstringIntOptIterator> |
3568 | + <PromoteIterator type="xs:string"> |
3569 | + <FnDataIterator> |
3570 | + <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,date)" typename="*" nill allowed="0"> |
3571 | + <ForVarIterator varname="p"/> |
3572 | + </AttributeAxisIterator> |
3573 | + </FnDataIterator> |
3574 | + </PromoteIterator> |
3575 | + <SingletonIterator value="xs:integer(1)"/> |
3576 | + <SingletonIterator value="xs:integer(4)"/> |
3577 | + </SubstringIntOptIterator> |
3578 | + </TypedValueCompareIterator_STRING> |
3579 | + <flwor::FLWORIterator> |
3580 | + <LetVariable name="$$opt_temp_1" materialize="true"> |
3581 | + <HoistIterator> |
3582 | + <PromoteIterator type="xs:anyAtomicType"> |
3583 | + <FnDataIterator> |
3584 | + <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,locid)" typename="*" nill allowed="0"> |
3585 | + <ForVarIterator varname="s"/> |
3586 | + </AttributeAxisIterator> |
3587 | + </FnDataIterator> |
3588 | + </PromoteIterator> |
3589 | + </HoistIterator> |
3590 | + </LetVariable> |
3591 | + <ForVariable name="$$context-item"> |
3592 | + <UnhoistIterator> |
3593 | + <LetVarIterator varname="$$opt_temp_0"/> |
3594 | + </UnhoistIterator> |
3595 | + </ForVariable> |
3596 | + <WhereClause> |
3597 | + <AndIterator> |
3598 | + <CompareIterator> |
3599 | + <PromoteIterator type="xs:anyAtomicType"> |
3600 | + <FnDataIterator> |
3601 | + <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,id)" typename="*" nill allowed="0"> |
3602 | + <ForVarIterator varname="$$context-item"/> |
3603 | + </AttributeAxisIterator> |
3604 | + </FnDataIterator> |
3605 | + </PromoteIterator> |
3606 | + <UnhoistIterator> |
3607 | + <LetVarIterator varname="$$opt_temp_1"/> |
3608 | + </UnhoistIterator> |
3609 | + </CompareIterator> |
3610 | + <CompareIterator> |
3611 | + <PromoteIterator type="xs:anyAtomicType"> |
3612 | + <FnDataIterator> |
3613 | + <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,city)" typename="*" nill allowed="0"> |
3614 | + <ForVarIterator varname="$$context-item"/> |
3615 | + </AttributeAxisIterator> |
3616 | + </FnDataIterator> |
3617 | + </PromoteIterator> |
3618 | + <SingletonIterator value="xs:string(paris)"/> |
3619 | + </CompareIterator> |
3620 | + </AndIterator> |
3621 | + </WhereClause> |
3622 | + <ReturnClause> |
3623 | + <ForVarIterator varname="$$context-item"/> |
3624 | + </ReturnClause> |
3625 | + </flwor::FLWORIterator> |
3626 | + </AndIterator> |
3627 | + <WinCondVariable name="end-NextIn"/> |
3628 | + <TypedValueCompareIterator_STRING> |
3629 | + <SubstringIntOptIterator> |
3630 | + <PromoteIterator type="xs:string"> |
3631 | + <FnDataIterator> |
3632 | + <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,date)" typename="*" nill allowed="0"> |
3633 | + <ForVarIterator varname="s"/> |
3634 | + </AttributeAxisIterator> |
3635 | + </FnDataIterator> |
3636 | + </PromoteIterator> |
3637 | + <SingletonIterator value="xs:integer(1)"/> |
3638 | + <SingletonIterator value="xs:integer(4)"/> |
3639 | + </SubstringIntOptIterator> |
3640 | + <SubstringIntOptIterator> |
3641 | + <PromoteIterator type="xs:string"> |
3642 | + <FnDataIterator> |
3643 | + <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,date)" typename="*" nill allowed="0"> |
3644 | + <ForVarIterator varname="n"/> |
3645 | + </AttributeAxisIterator> |
3646 | + </FnDataIterator> |
3647 | + </PromoteIterator> |
3648 | + <SingletonIterator value="xs:integer(1)"/> |
3649 | + <SingletonIterator value="xs:integer(4)"/> |
3650 | + </SubstringIntOptIterator> |
3651 | + </TypedValueCompareIterator_STRING> |
3652 | + <flwor::LetIterator> |
3653 | + <LetVariable name="$$opt_temp_0" materialize="true"/> |
3654 | + <flwor::TupleSourceIterator/> |
3655 | + <HoistIterator> |
3656 | + <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,loc)" typename="*" nill allowed="0"> |
3657 | + <CtxVarIterator varid="5" varname="locations" varkind="global"/> |
3658 | + </ChildAxisIterator> |
3659 | + </HoistIterator> |
3660 | + </flwor::LetIterator> |
3661 | + </flwor::WindowIterator> |
3662 | + <ElementIterator> |
3663 | + <SingletonIterator value="xs:QName(,,yearly-sales)"/> |
3664 | + <FnConcatIterator> |
3665 | + <AttributeIterator qname="xs:QName(,,year)"> |
3666 | + <EnclosedIterator attr_cont="true"> |
3667 | + <SubstringIntOptIterator> |
3668 | + <PromoteIterator type="xs:string"> |
3669 | + <FnDataIterator> |
3670 | + <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,date)" typename="*" nill allowed="0"> |
3671 | + <ForVarIterator varname="s"/> |
3672 | + </AttributeAxisIterator> |
3673 | + </FnDataIterator> |
3674 | + </PromoteIterator> |
3675 | + <SingletonIterator value="xs:integer(1)"/> |
3676 | + <SingletonIterator value="xs:integer(4)"/> |
3677 | + </SubstringIntOptIterator> |
3678 | + </EnclosedIterator> |
3679 | + </AttributeIterator> |
3680 | + <AttributeIterator qname="xs:QName(,,qty)"> |
3681 | + <EnclosedIterator attr_cont="true"> |
3682 | + <FnSumIterator> |
3683 | + <FnDataIterator> |
3684 | + <NodeDistinctIterator allow-atomics="false" check-only="false"> |
3685 | + <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,qty)" typename="*" nill allowed="0"> |
3686 | + <LetVarIterator varname="yearly-sales"/> |
3687 | + </AttributeAxisIterator> |
3688 | + </NodeDistinctIterator> |
3689 | + </FnDataIterator> |
3690 | + </FnSumIterator> |
3691 | + </EnclosedIterator> |
3692 | + </AttributeIterator> |
3693 | + </FnConcatIterator> |
3694 | + </ElementIterator> |
3695 | + </flwor::TupleStreamIterator> |
3696 | +</SequentialIterator> |
3697 | + |
3698 | |
3699 | === modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/optim/var_inline_05.iter' |
3700 | --- test/rbkt/ExpCompilerResults/IterPlan/zorba/optim/var_inline_05.iter 2013-02-07 17:24:36 +0000 |
3701 | +++ test/rbkt/ExpCompilerResults/IterPlan/zorba/optim/var_inline_05.iter 2013-05-16 10:15:45 +0000 |
3702 | @@ -23,6 +23,35 @@ |
3703 | <ForVarIterator varname="e"/> |
3704 | <ForVarIterator varname="s"/> |
3705 | </SpecificNumArithIterator_SubtractOperation_INTEGER> |
3706 | + <UnhoistIterator> |
3707 | + <LetVarIterator varname="$$opt_temp_0"/> |
3708 | + </UnhoistIterator> |
3709 | + </TypedValueCompareIterator_INTEGER> |
3710 | + </FnBooleanIterator> |
3711 | + <flwor::LetIterator> |
3712 | + <LetVariable name="$$opt_temp_0" materialize="true"/> |
3713 | + <flwor::ForIterator> |
3714 | + <ForVariable name="x"/> |
3715 | + <flwor::TupleSourceIterator/> |
3716 | + <ElementIterator copyInputNodes="false"> |
3717 | + <SingletonIterator value="xs:QName(,,a)"/> |
3718 | + <FnConcatIterator> |
3719 | + <ElementIterator copyInputNodes="false"> |
3720 | + <SingletonIterator value="xs:QName(,,b)"/> |
3721 | + <TextIterator> |
3722 | + <SingletonIterator value="xs:string(1)"/> |
3723 | + </TextIterator> |
3724 | + </ElementIterator> |
3725 | + <ElementIterator copyInputNodes="false"> |
3726 | + <SingletonIterator value="xs:QName(,,b)"/> |
3727 | + <TextIterator> |
3728 | + <SingletonIterator value="xs:string(2)"/> |
3729 | + </TextIterator> |
3730 | + </ElementIterator> |
3731 | + </FnConcatIterator> |
3732 | + </ElementIterator> |
3733 | + </flwor::ForIterator> |
3734 | + <HoistIterator> |
3735 | <CastIterator type="xs:integer"> |
3736 | <FnDataIterator> |
3737 | <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,b)" typename="*" nill allowed="0" target_position="1"> |
3738 | @@ -30,29 +59,8 @@ |
3739 | </ChildAxisIterator> |
3740 | </FnDataIterator> |
3741 | </CastIterator> |
3742 | - </TypedValueCompareIterator_INTEGER> |
3743 | - </FnBooleanIterator> |
3744 | - <flwor::ForIterator> |
3745 | - <ForVariable name="x"/> |
3746 | - <flwor::TupleSourceIterator/> |
3747 | - <ElementIterator copyInputNodes="false"> |
3748 | - <SingletonIterator value="xs:QName(,,a)"/> |
3749 | - <FnConcatIterator> |
3750 | - <ElementIterator copyInputNodes="false"> |
3751 | - <SingletonIterator value="xs:QName(,,b)"/> |
3752 | - <TextIterator> |
3753 | - <SingletonIterator value="xs:string(1)"/> |
3754 | - </TextIterator> |
3755 | - </ElementIterator> |
3756 | - <ElementIterator copyInputNodes="false"> |
3757 | - <SingletonIterator value="xs:QName(,,b)"/> |
3758 | - <TextIterator> |
3759 | - <SingletonIterator value="xs:string(2)"/> |
3760 | - </TextIterator> |
3761 | - </ElementIterator> |
3762 | - </FnConcatIterator> |
3763 | - </ElementIterator> |
3764 | - </flwor::ForIterator> |
3765 | + </HoistIterator> |
3766 | + </flwor::LetIterator> |
3767 | </flwor::WindowIterator> |
3768 | <ElementIterator> |
3769 | <SingletonIterator value="xs:QName(,,window)"/> |
3770 | |
3771 | === modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/xmark/q4.iter' |
3772 | --- test/rbkt/ExpCompilerResults/IterPlan/zorba/xmark/q4.iter 2013-02-07 17:24:36 +0000 |
3773 | +++ test/rbkt/ExpCompilerResults/IterPlan/zorba/xmark/q4.iter 2013-05-16 10:15:45 +0000 |
3774 | @@ -31,6 +31,13 @@ |
3775 | </ChildAxisIterator> |
3776 | </ChildAxisIterator> |
3777 | </ForVariable> |
3778 | + <LetVariable name="$$opt_temp_0" materialize="true"> |
3779 | + <HoistIterator> |
3780 | + <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,bidder)" typename="*" nill allowed="0"> |
3781 | + <ForVarIterator varname="b"/> |
3782 | + </ChildAxisIterator> |
3783 | + </HoistIterator> |
3784 | + </LetVariable> |
3785 | <WhereClause> |
3786 | <FnExistsIterator> |
3787 | <flwor::TupleStreamIterator> |
3788 | @@ -63,9 +70,9 @@ |
3789 | <SingletonIterator value="xs:string(person20)"/> |
3790 | </CompareIterator> |
3791 | </flwor::WhereIterator> |
3792 | - <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,bidder)" typename="*" nill allowed="0"> |
3793 | - <ForVarIterator varname="b"/> |
3794 | - </ChildAxisIterator> |
3795 | + <UnhoistIterator> |
3796 | + <LetVarIterator varname="$$opt_temp_0"/> |
3797 | + </UnhoistIterator> |
3798 | </flwor::ForIterator> |
3799 | <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,personref)" typename="*" nill allowed="0"> |
3800 | <ForVarIterator varname="$$context-item"/> |
3801 | |
3802 | === added file 'test/rbkt/ExpQueryResults/zorba/optim/hoist_trycatch_01.xml.res' |
3803 | --- test/rbkt/ExpQueryResults/zorba/optim/hoist_trycatch_01.xml.res 1970-01-01 00:00:00 +0000 |
3804 | +++ test/rbkt/ExpQueryResults/zorba/optim/hoist_trycatch_01.xml.res 2013-05-16 10:15:45 +0000 |
3805 | @@ -0,0 +1,1 @@ |
3806 | +<sale city="paris"/><sale city="paris"/><sale city="san fransisco"/><sale city="san fransisco"/><sale city="chania"/> |
3807 | |
3808 | === added file 'test/rbkt/ExpQueryResults/zorba/optim/hoist_window_01.xml.res' |
3809 | --- test/rbkt/ExpQueryResults/zorba/optim/hoist_window_01.xml.res 1970-01-01 00:00:00 +0000 |
3810 | +++ test/rbkt/ExpQueryResults/zorba/optim/hoist_window_01.xml.res 2013-05-16 10:15:45 +0000 |
3811 | @@ -0,0 +1,1 @@ |
3812 | +<yearly-sales year="2013" qty="9"/> |
3813 | |
3814 | === modified file 'test/rbkt/Queries/zorba/hashjoins/gflwor_04.xq' |
3815 | --- test/rbkt/Queries/zorba/hashjoins/gflwor_04.xq 2013-02-21 16:34:45 +0000 |
3816 | +++ test/rbkt/Queries/zorba/hashjoins/gflwor_04.xq 2013-05-16 10:15:45 +0000 |
3817 | @@ -24,78 +24,87 @@ |
3818 | |
3819 | (: |
3820 | |
3821 | -flwor_expr (0x812cda0) |
3822 | +Expression tree after optimization for main query |
3823 | +flwor_expr (0x8c202b8) |
3824 | [ |
3825 | - FOR (0x812bad8) a (0x812ba54) |
3826 | - [ |
3827 | - concatenate/2 (0x812b9f4) [ 1, 2 ] |
3828 | - ] |
3829 | - FOR (0x812c028) x (0x812bfa4) |
3830 | - [ |
3831 | - concatenate/3 (0x812bf44) [ |
3832 | - elem_expr (0x812bee0) [ |
3833 | - const_expr (0x812be8c) [ xs:QName(,,a) ] |
3834 | - text_expr (0x812be34) [ const_expr (0x812bde0) [ xs:string(1) ] ] |
3835 | - ] |
3836 | - elem_expr (0x812bd7c) [ |
3837 | - const_expr (0x812bd28) [ xs:QName(,,a) ] |
3838 | - text_expr (0x812bcd0) [ const_expr (0x812bc7c) [ xs:string(2) ] ] |
3839 | - ] |
3840 | - elem_expr (0x812bc18) [ |
3841 | - const_expr (0x812bbc4) [ xs:QName(,,a) ] |
3842 | - text_expr (0x812bb6c) [ const_expr (0x812bb18) [ xs:string(3) ] ] |
3843 | - ] |
3844 | - ] |
3845 | - ] |
3846 | - COUNT (0x812c0ec) w (0x812c068) |
3847 | - LET (0x812c864) y (0x812c7e0) |
3848 | - [ |
3849 | - flwor_expr (0x812c77c) |
3850 | + FOR (0x8c1f0c4) a (0x8c1f044) |
3851 | + [ |
3852 | + concatenate#2 (0x8c1efe8) [ xs:integer(1) xs:integer(2) ] |
3853 | + ] |
3854 | + LET (0x8c20474) $$opt_temp_0 (0x8c20398) |
3855 | + [ |
3856 | + hoist#1 (0x8c20418) [ local:foo#1(0x8c1f710) [ vref(0x8c1f6c0) [ a (0x8c1f044) ] ] ] |
3857 | + ] |
3858 | + LET (0x8c20ccc) $$opt_temp_4 (0x8c20c4c) |
3859 | + [ |
3860 | + create-internal-index#2 (0x8c20bf0) [ |
3861 | + const_expr (0x8c2085c) [ xs:QName(,,tempIndex0) ] |
3862 | + flwor_expr (0x8c20b90) |
3863 | + [ |
3864 | + FOR (0x8c20a58) $$opt_temp_2 (0x8c20958) AT $$opt_temp_3 (0x8c209d8) |
3865 | + [ |
3866 | + unhoist#1 (0x8c208ac) [ vref (0x8c20908) [ $$opt_temp_0 (0x8c20398) ] ] |
3867 | + ] |
3868 | + RETURN (0x8c20b90) |
3869 | + [ |
3870 | + value-index-entry-builder#2 (0x8c20b34) [ |
3871 | + vref (0x8c20ae4) [ $$opt_temp_2 (0x8c20958) ] |
3872 | + vref (0x8c20a94) [ $$opt_temp_2 (0x8c20958) ] |
3873 | + ] |
3874 | + ] |
3875 | + ] |
3876 | + ] |
3877 | + ] |
3878 | + FOR (0x8c1f5d8) x (0x8c1f558) |
3879 | + [ |
3880 | + concatenate#3 (0x8c1f4fc) [ <a>1</a>, <a>2</a>, <a>3</a> ] |
3881 | + ] |
3882 | + LET (0x8c20638) $$opt_temp_1 (0x8c2055c) |
3883 | + [ |
3884 | + hoist#1 (0x8c205dc) [ |
3885 | + cast_expr xs:integer? (0x8c1f98c) [ |
3886 | + data#1 (0x8c1f930) [ vref (0x8c1f8e0) [ x (0x8c1f558) ] ] |
3887 | + ] |
3888 | + ] |
3889 | + ] |
3890 | + COUNT (0x8c1f694) w (0x8c1f614) |
3891 | + LET (0x8c1fdb8) y (0x8c1fd38) |
3892 | + [ |
3893 | + flwor_expr (0x8c1fcd8) |
3894 | [ |
3895 | - FOR (0x812c314) z (0x812c290) |
3896 | - [ |
3897 | - local:foo/1 (0x812c170) [ vref (0x812c11c) [ a (0x812ba54) ] ] |
3898 | - ] |
3899 | - WHERE (0x812c77c) |
3900 | - [ |
3901 | - boolean/1 (0x812c698) [ |
3902 | - value-equal-integer/2 (0x812c4b8) [ |
3903 | - cast_expr xs:integer? (0x812c408) [ |
3904 | - data/1 (0x812c3a8) [ vref (0x812c354) [ x (0x812bfa4) ] ] |
3905 | - ] |
3906 | - vref (0x812c464) [ z (0x812c290) ] |
3907 | - ] |
3908 | + FOR (0x8c1f8a4) z (0x8c1f824) |
3909 | + [ |
3910 | + probe-index-point-value#2 (0x8c20d08) [ |
3911 | + const_expr (0x8c2085c) [ xs:QName(,,tempIndex0) ] |
3912 | + unhoist#1 (0x8c206c4) [ vref (0x8c20674) [ $$opt_temp_1 (0x8c2055c) ] ] |
3913 | ] |
3914 | ] |
3915 | - RETURN (0x812c77c) |
3916 | + RETURN (0x8c1fcd8) |
3917 | [ |
3918 | - vref (0x812c728) [ z (0x812c290) ] |
3919 | + vref (0x8c1fc88) [ z (0x8c1f824) ] |
3920 | ] |
3921 | ] |
3922 | ] |
3923 | - RETURN (0x812cda0) |
3924 | + RETURN (0x8c202b8) |
3925 | [ |
3926 | - concatenate/2 (0x812cd40) [ |
3927 | - elem_expr (0x812ccdc) [ |
3928 | - copy nodes = 0 |
3929 | - const_expr (0x812cc88) [ xs:QName(,,res) ] |
3930 | - enclosed-expr/1 (0x812cc28) [ |
3931 | - concatenate/4 (0x812cbc8) [ |
3932 | - vref (0x812cb74) [ x (0x812bfa4) ] |
3933 | - vref (0x812cb20) [ w (0x812c068) ] |
3934 | - count/1 (0x812cac0) [ |
3935 | - vref (0x812ca6c) [ y (0x812c7e0) ] |
3936 | - ] |
3937 | - sum_integer/1 (0x812c94c) [ |
3938 | - vref (0x812c8f8) [ y (0x812c7e0) ] |
3939 | - ] |
3940 | + concatenate#2 (0x8c2025c) [ |
3941 | + elem_expr (0x8c201fc) [ |
3942 | + copy nodes = 1 |
3943 | + const_expr (0x8c201ac) [ xs:QName(,,res) ] |
3944 | + enclosed-expr#1 (0x8c20150) [ |
3945 | + concatenate#4 (0x8c200f4) [ |
3946 | + vref (0x8c200a4) [ x (0x8c1f558) ] |
3947 | + vref (0x8c20054) [ w (0x8c1f614) ] |
3948 | + count#1 (0x8c1fff8) [ vref (0x8c1ffa8) [ y (0x8c1fd38) ] ] |
3949 | + sum_integer#1 (0x8c1fe94) [ vref (0x8c1fe44) [ y (0x8c1fd38) ] ] |
3950 | ] |
3951 | ] |
3952 | ] |
3953 | - const_expr (0x812c8a4) [ xs:string( |
3954 | + const_expr (0x8c1fdf4) [ xs:string( |
3955 | ) ] |
3956 | ] |
3957 | ] |
3958 | ] |
3959 | |
3960 | + |
3961 | :) |
3962 | |
3963 | === added file 'test/rbkt/Queries/zorba/optim/hoist_trycatch_01.xq' |
3964 | --- test/rbkt/Queries/zorba/optim/hoist_trycatch_01.xq 1970-01-01 00:00:00 +0000 |
3965 | +++ test/rbkt/Queries/zorba/optim/hoist_trycatch_01.xq 2013-05-16 10:15:45 +0000 |
3966 | @@ -0,0 +1,115 @@ |
3967 | + |
3968 | + |
3969 | +declare variable $x external; |
3970 | + |
3971 | + |
3972 | +declare variable $sales := |
3973 | +<sales> |
3974 | +<sale pid="3" locid="5" qty="3" date="2013-01-01"/> |
3975 | +<sale pid="3" locid="5" qty="5" date="2013-01-02"/> |
3976 | +<sale pid="2" locid="4" qty="1" date="2013-01-01"/> |
3977 | +<sale pid="2" locid="4" qty="1" date="2014-01-01"/> |
3978 | +<sale pid="2" locid="7" qty="1" date="2014-01-01"/> |
3979 | +</sales>; |
3980 | + |
3981 | +declare variable $locations := |
3982 | +<locations> |
3983 | +<loc id="5" city="paris"/> |
3984 | +<loc id="4" city="san fransisco"/> |
3985 | +<loc id="7" city="chania"/> |
3986 | +</locations>; |
3987 | + |
3988 | + |
3989 | +try |
3990 | +{ |
3991 | + $x * $x |
3992 | +} |
3993 | +catch * |
3994 | +{ |
3995 | + for $s in $sales/sale |
3996 | + for $l in $locations/loc |
3997 | + where $s/@locid eq $l/@id |
3998 | + return <sale>{$l/@city}</sale> |
3999 | +} |
4000 | + |
4001 | + |
4002 | +(: |
4003 | + |
4004 | +path-1.1 = 0xbfffeac0 prev = NULL theExpr = NULL |
4005 | + |
4006 | +path-2.1 = 0xbfffe9f8 prev = NULL theExpr = NULL |
4007 | + |
4008 | +path-2.2 = 0xbfffe8d8 prev = 0xbfffe9f8 theExpr = 0x8125c88 |
4009 | + |
4010 | + |
4011 | + trycatch_expr (0x8125c88) |
4012 | + [ |
4013 | + multiply#2 (0x8125aa8) [ |
4014 | + promote_expr xs:anyAtomicType? (0x8125b68) [ |
4015 | + data#1 (0x8125b08) [ |
4016 | + vref (0x8125a00) [ x (0x81229c4) ] |
4017 | + ] |
4018 | + ] |
4019 | + promote_expr xs:anyAtomicType? (0x8125c28) [ |
4020 | + data#1 (0x8125bc8) [ |
4021 | + vref (0x8125a54) [ x (0x81229c4) ] |
4022 | + ] |
4023 | + ] |
4024 | + ] |
4025 | + CATCH |
4026 | + flwor_expr (0x8134404) |
4027 | + [ |
4028 | + FOR (0x8126610) s (0x812658c) |
4029 | + [ |
4030 | + relpath_expr (0x812634c) [ |
4031 | + vref (0x81263a8) [ sales (0x8122a48) ] |
4032 | + REL STEP child::match_expr [name_test(sale)] |
4033 | + ] |
4034 | + ] |
4035 | + FOR (0x813397c) l (0x81338f8) |
4036 | + [ |
4037 | + relpath_expr (0x8126650) [ |
4038 | + vref (0x81266ac) [ locations (0x8122acc) ] |
4039 | + REL STEP child::match_expr [name_test(loc)] |
4040 | + ] |
4041 | + ] |
4042 | + WHERE (0x8134404) |
4043 | + [ |
4044 | + boolean#1 (0x813401c) [ |
4045 | + value-equal#2 (0x8133e3c) [ |
4046 | + promote_expr xs:anyAtomicType? (0x8133efc) [ |
4047 | + data#1 (0x8133e9c) [ |
4048 | + relpath_expr (0x81339bc) [ |
4049 | + vref (0x8133a18) [ s (0x812658c) ] |
4050 | + REL STEP attribute::match_expr [name_test(locid)] |
4051 | + ] |
4052 | + ] |
4053 | + ] |
4054 | + promote_expr xs:anyAtomicType? (0x8133fbc) [ |
4055 | + data#1 (0x8133f5c) [ |
4056 | + relpath_expr (0x8133bfc) [ |
4057 | + vref (0x8133c58) [ l (0x81338f8) ] |
4058 | + REL STEP attribute::match_expr [name_test(id)] |
4059 | + ] |
4060 | + ] |
4061 | + ] |
4062 | + ] |
4063 | + ] |
4064 | + ] |
4065 | + RETURN (0x8134404) |
4066 | + [ |
4067 | + elem_expr (0x81343a0) [ |
4068 | + copy nodes = 0 |
4069 | + const_expr (0x813434c) [ xs:QName(,,sale) ] |
4070 | + enclosed-expr#1 (0x81342ec) [ |
4071 | + relpath_expr (0x81340ac) [ |
4072 | + vref (0x8134108) [ l (0x81338f8) ] |
4073 | + REL STEP attribute::match_expr [name_test(city)] |
4074 | + ] |
4075 | + ] |
4076 | + ] |
4077 | + ] |
4078 | + ] |
4079 | + ] |
4080 | + |
4081 | +:) |
4082 | |
4083 | === added file 'test/rbkt/Queries/zorba/optim/hoist_window_01.xq' |
4084 | --- test/rbkt/Queries/zorba/optim/hoist_window_01.xq 1970-01-01 00:00:00 +0000 |
4085 | +++ test/rbkt/Queries/zorba/optim/hoist_window_01.xq 2013-05-16 10:15:45 +0000 |
4086 | @@ -0,0 +1,28 @@ |
4087 | +declare variable $sales := |
4088 | +<sales> |
4089 | +<sale pid="3" locid="5" qty="3" date="2013-01-01"/> |
4090 | +<sale pid="3" locid="5" qty="5" date="2013-01-02"/> |
4091 | +<sale pid="2" locid="4" qty="1" date="2013-01-01"/> |
4092 | +<sale pid="2" locid="4" qty="1" date="2014-01-01"/> |
4093 | +<sale pid="2" locid="7" qty="1" date="2014-01-01"/> |
4094 | +</sales>; |
4095 | + |
4096 | +declare variable $locations := |
4097 | +<locations> |
4098 | +<loc id="5" city="paris"/> |
4099 | +<loc id="4" city="san fransisco"/> |
4100 | +<loc id="7" city="chania"/> |
4101 | +</locations>; |
4102 | + |
4103 | + |
4104 | +for tumbling window $yearly-sales in $sales/sale |
4105 | + |
4106 | +start $s previous $p when |
4107 | +substring($s/@date, 1, 4) ne substring($p/@date, 1, 4) |
4108 | +and |
4109 | +$locations/loc[@id eq $s/@locid and @city eq "paris"] |
4110 | + |
4111 | +end next $n when substring($s/@date, 1, 4) ne substring($n/@date, 1, 4) |
4112 | + |
4113 | +return <yearly-sales year="{substring($s/@date, 1, 4)}" |
4114 | + qty="{sum($yearly-sales/@qty)}"/> |
Validation queue starting for merge proposal. zorbatest. lambda. nu:8080/ remotequeue/ gen-flwor- opt-2013- 05-16T10- 58-07.097Z/ log.html
Log at: http://