Merge lp:~zorba-coders/zorba/plan-serializer into lp:zorba

Proposed by Matthias Brantner
Status: Merged
Approved by: Chris Hillery
Approved revision: 10537
Merged at revision: 10640
Proposed branch: lp:~zorba-coders/zorba/plan-serializer
Merge into: lp:zorba
Diff against target: 492 lines (+121/-28)
19 files modified
src/api/xqueryimpl.cpp (+2/-1)
src/compiler/api/compilercb.cpp (+17/-0)
src/compiler/api/compilercb.h (+5/-2)
src/compiler/expression/flwor_expr.cpp (+1/-1)
src/compiler/expression/ftnode.cpp (+2/-2)
src/compiler/expression/var_expr.cpp (+1/-0)
src/compiler/rewriter/rules/flwor_rules.cpp (+4/-0)
src/compiler/translator/translator.cpp (+5/-3)
src/context/static_context.cpp (+1/-0)
src/context/static_context.h (+2/-0)
src/functions/udf.cpp (+24/-5)
src/functions/udf.h (+6/-1)
src/util/uri_util.cpp (+2/-2)
src/util/uri_util.h (+2/-2)
src/zorbaserialization/archiver.cpp (+4/-1)
src/zorbaserialization/archiver.h (+1/-1)
src/zorbaserialization/zorba_class_serializer.h (+3/-5)
src/zorbatypes/rchandle.h (+2/-2)
src/zorbatypes/rclist.h (+37/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/plan-serializer
Reviewer Review Type Date Requested Status
Matthias Brantner Approve
Chris Hillery Approve
Markos Zaharioudakis Pending
Review via email: mp+91174@code.launchpad.net

This proposal supersedes a proposal from 2012-01-18.

Commit message

several fixes for the plan serializer + implemented materialize_clause::clone()

Description of the change

Fix in plan serializer about preparing user_functions plan for serialization.

To post a comment you must log in.
Revision history for this message
Markos Zaharioudakis (markos-za) wrote : Posted in a previous version of this proposal

I would like to understand this better. What is the problem that this change fixes?

Revision history for this message
Daniel Turcanu (danielturcanu) wrote : Posted in a previous version of this proposal

The user_functions were compiled during plan serialization, and this modified some expr trees that were already serialized. I had to ensure that all user_functions are compiled before plan serialization is started.

Revision history for this message
Markos Zaharioudakis (markos-za) wrote : Posted in a previous version of this proposal

> The user_functions were compiled during plan serialization, and this modified
> some expr trees that were already serialized. I had to ensure that all
> user_functions are compiled before plan serialization is started.

Yes, I understood that myself, but what exactly was modified after having been serialized?

Revision history for this message
Daniel Turcanu (danielturcanu) wrote : Posted in a previous version of this proposal

For example in one test, in flwor_expr object, theClauses was receiving another flwor_clause in the vector, which made the vector to increase and move to another space. But the initial flwor_clause had already been serialized, and its address was registered for address duplication detection. Sometimes another object would be allocated at the same address, and the plan serializer thought it is the same object. This only occured sometimes, so the problem was hard to debug.
So as a rule, all the objects should freeze during plan serialization, nothing should change.

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

The attempt to merge lp:~danielturcanu/zorba/plan-serializer into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:273 (message):
  Validation queue job plan-serializer-2012-01-18T10-22-58.412Z is finished.
  The final status was:

  No tests were run - build or configure step must have failed.

  Not commiting changes.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

Revision history for this message
Chris Hillery (ceejatec) wrote : Posted in a previous version of this proposal

Code does not compile. I would fix if this branch was owned by ~zorba-coders, but since it's ~danielturcanu, we'll need Daniel to fix it.

[ 13%] Building CXX object src/CMakeFiles/zorba_simplestore.dir/api/xqueryimpl.cpp.o
.In file included from ../../src/api/xqueryimpl.cpp:58:
../../src/compiler/api/compilercb.h:169: warning: '>>' operator will be treated as two right angle brackets in C++0x
../../src/compiler/api/compilercb.h:169: warning: suggest parentheses around '>>' expression
../../src/compiler/api/compilercb.h:169: error: 'theLocalUdfs' was not declared in this scope
../../src/compiler/api/compilercb.h:169: error: '>>' should be '> >' within a nested template argument list
../../src/compiler/api/compilercb.h:176: warning: '>>' operator will be treated as two right angle brackets in C++0x
../../src/compiler/api/compilercb.h:176: warning: suggest parentheses around '>>' expression
../../src/compiler/api/compilercb.h:176: error: a function call cannot appear in a constant-expression
../../src/compiler/api/compilercb.h:176: error: '>>' should be '> >' within a nested template argument list

Revision history for this message
Markos Zaharioudakis (markos-za) wrote : Posted in a previous version of this proposal

> For example in one test, in flwor_expr object, theClauses was receiving
> another flwor_clause in the vector, which made the vector to increase and move
> to another space. But the initial flwor_clause had already been serialized,
> and its address was registered for address duplication detection. Sometimes
> another object would be allocated at the same address, and the plan serializer
> thought it is the same object. This only occured sometimes, so the problem was
> hard to debug.
> So as a rule, all the objects should freeze during plan serialization, nothing
> should change.

I am sorry, but this still does not answer my question. I assume that the flwor_expr is inside the body of a udf. Are you saying that this body is somehow serialized, without having being optimized yet? If yes, I don't understand how this is possible, given that user_function::serialize() will first optimize the body (if not optimized already) before serializing it. Either I am missing something, or the real bug is somewhere else and you are just covering it up with this patch.

Revision history for this message
Daniel Turcanu (danielturcanu) wrote : Posted in a previous version of this proposal

In my debugging I saw that the flwor_expr is outside the udf. So when compiling a udf, probably the optimizer is changing the expression tree in other places as well, probably the caller of the udf, but I cannot say for sure. This woulnd't surprise me, it should be normal for an optimizer.

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

The attempt to merge lp:~danielturcanu/zorba/plan-serializer into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:273 (message):
  Validation queue job plan-serializer-2012-01-18T16-04-09.348Z is finished.
  The final status was:

  1 tests did not succeed - changes not commited.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

Revision history for this message
Chris Hillery (ceejatec) wrote : Posted in a previous version of this proposal
Download full text (3.3 KiB)

zorba_data-converters_module/converters/base64/binaryReadWrite.xq Failed

/home/ceej/zo/testing/zorbatest/tester/remotequeue/plan-serializer-2012-01-18T16-04-09.348Z/bzr/zorba/build/src/libzorba_simplestore.so.2.1.0 [0x7fde24a51399]
/home/ceej/zo/testing/zorbatest/tester/remotequeue/plan-serializer-2012-01-18T16-04-09.348Z/bzr/zorba/build/src/libzorba_simplestore.so.2.1.0 [0x7fde24a5152e]
/home/ceej/zo/testing/zorbatest/tester/remotequeue/plan-serializer-2012-01-18T16-04-09.348Z/bzr/zorba/build/src/libzorba_simplestore.so.2.1.0 [0x7fde2495d70c]
/home/ceej/zo/testing/zorbatest/tester/remotequeue/plan-serializer-2012-01-18T16-04-09.348Z/bzr/zorba/build/src/libzorba_simplestore.so.2.1.0 [0x7fde24960637]
/home/ceej/zo/testing/zorbatest/tester/remotequeue/plan-serializer-2012-01-18T16-04-09.348Z/bzr/zorba/build/src/libzorba_simplestore.so.2.1.0 [0x7fde249b3f07]
/home/ceej/zo/testing/zorbatest/tester/remotequeue/plan-serializer-2012-01-18T16-04-09.348Z/bzr/zorba/build/src/libzorba_simplestore.so.2.1.0 [0x7fde249a55cd]
/home/ceej/zo/testing/zorbatest/tester/remotequeue/plan-serializer-2012-01-18T16-04-09.348Z/bzr/zorba/build/src/libzorba_simplestore.so.2.1.0 [0x7fde249a5536]
/home/ceej/zo/testing/zorbatest/tester/remotequeue/plan-serializer-2012-01-18T16-04-09.348Z/bzr/zorba/build/src/libzorba_simplestore.so.2.1.0 [0x7fde249a5536]
/home/ceej/zo/testing/zorbatest/tester/remotequeue/plan-serializer-2012-01-18T16-04-09.348Z/bzr/zorba/build/src/libzorba_simplestore.so.2.1.0 [0x7fde249a5536]
/home/ceej/zo/testing/zorbatest/tester/remotequeue/plan-serializer-2012-01-18T16-04-09.348Z/bzr/zorba/build/src/libzorba_simplestore.so.2.1.0 [0x7fde249a5536]
/home/ceej/zo/testing/zorbatest/tester/remotequeue/plan-serializer-2012-01-18T16-04-09.348Z/bzr/zorba/build/src/libzorba_simplestore.so.2.1.0 [0x7fde249a5536]
/home/ceej/zo/testing/zorbatest/tester/remotequeue/plan-serializer-2012-01-18T16-04-09.348Z/bzr/zorba/build/src/libzorba_simplestore.so.2.1.0 [0x7fde2499f30d]
/home/ceej/zo/testing/zorbatest/tester/remotequeue/plan-serializer-2012-01-18T16-04-09.348Z/bzr/zorba/build/src/libzorba_simplestore.so.2.1.0 [0x7fde249a2ce1]
/home/ceej/zo/testing/zorbatest/tester/remotequeue/plan-serializer-2012-01-18T16-04-09.348Z/bzr/zorba/build/src/libzorba_simplestore.so.2.1.0 [0x7fde24b8967e]
/home/ceej/zo/testing/zorbatest/tester/remotequeue/plan-serializer-2012-01-18T16-04-09.348Z/bzr/zorba/build/src/libzorba_simplestore.so.2.1.0 [0x7fde24b8a0a8]
/home/ceej/zo/testing/zorbatest/tester/remotequeue/plan-serializer-2012-01-18T16-04-09.348Z/bzr/zorba/build/src/libzorba_simplestore.so.2.1.0(_ZN5zorba10CompilerCB21prepare_for_serializeEv+0x2c) [0x7fde249d39bc]
/home/ceej/zo/testing/zorbatest/tester/remotequeue/plan-serializer-2012-01-18T16-04-09.348Z/bzr/zorba/build/src/libzorba_simplestore.so.2.1.0 [0x7fde2475ad59]
/home/ceej/zo/testing/zorbatest/tester/remotequeue/plan-serializer-2012-01-18T16-04-09.348Z/bzr/zorba/build/src/libzorba_simplestore.so.2.1.0 [0x7fde2475b16a]
/home/ceej/zo/testing/zorbatest/tester/remotequeue/plan-serializer-2012-01-18T16-04-09.348Z/bzr/zorba/build/test/rbkt/testdriver [0x408044]
/lib64/libc.so.6(__libc_start_main+0xfa) [0x325ac1e32a]
/home/ceej/zo...

Read more...

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal
Revision history for this message
Chris Hillery (ceejatec) wrote : Posted in a previous version of this proposal

It appears that Zorba is randomly hanging with these changes (the validation queue kills it after 40 minutes). The first time, it locked up running the test zorba_excel_module/excel/text/right/excel_right1.xq . The second time, all tests actually completed, but it locked up doing the post-processing of Test.xml. Still waiting to see whether the third time's the charm.

However, on the second run, it did successfully upload the results to CDash:

http://zorbatest.lambda.nu:8080/cdash/viewTest.php?onlyfailed&buildid=29852

13 tests failed, including the same assertion crash in base64/binaryReadWrite.xq as before. The other 12 failures were XQFTTS tests, which failed for various reasons including segfaults.

These changes aren't ready to merge yet.

review: Needs Fixing
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

The attempt to merge lp:~zorba-coders/zorba/plan-serializer into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:274 (message):
  Validation queue job plan-serializer-2012-02-01T01-43-27.799Z is finished.
  The final status was:

  13 tests did not succeed - changes not commited.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

Revision history for this message
Chris Hillery (ceejatec) wrote : Posted in a previous version of this proposal

Ok, the third run succeeded in time, and you can see the same 13 test failures.

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

The attempt to merge lp:~zorba-coders/zorba/plan-serializer into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:274 (message):
  Validation queue job plan-serializer-2012-02-01T21-51-04.553Z is finished.
  The final status was:

  No tests were run - build or configure step must have failed.

  Not commiting changes.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

Revision history for this message
Chris Hillery (ceejatec) wrote :

I killed Matthias' validation queue run, because it wouldn't have proven anything - I didn't have ZORBA_TEST_PLAN_SERIALIZATION ON yet. I'm restarting it now with that flag set.

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 plan-serializer-2012-02-01T22-06-51.313Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1. Got: 4 Pending.

Revision history for this message
Chris Hillery (ceejatec) wrote :

Looks good!

Please don't re-Approved this merge proposal yet. I'll need to re-enable ZORBA_TEST_PLAN_SERIALIZATION one last time for the final submission. Once there's two Approve votes I'll do that.

review: Approve
Revision history for this message
Matthias Brantner (matthias-brantner) :
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 plan-serializer-2012-02-02T01-07-10.053Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/api/xqueryimpl.cpp'
2--- src/api/xqueryimpl.cpp 2012-01-11 17:30:25 +0000
3+++ src/api/xqueryimpl.cpp 2012-02-01 21:49:22 +0000
4@@ -193,7 +193,8 @@
5 }
6 else
7 {
8- ar.compiler_cb = theCompilerCB;
9+ //ar.compiler_cb = theCompilerCB;
10+ theCompilerCB->prepare_for_serialize();
11 }
12
13 ar & theCompilerCB;
14
15=== modified file 'src/compiler/api/compilercb.cpp'
16--- src/compiler/api/compilercb.cpp 2012-01-11 17:30:25 +0000
17+++ src/compiler/api/compilercb.cpp 2012-02-01 21:49:22 +0000
18@@ -27,6 +27,7 @@
19 #include "system/properties.h"
20
21 #include "zorbaserialization/serialization_engine.h"
22+#include "functions/udf.h"
23
24
25 namespace zorba
26@@ -120,6 +121,7 @@
27 theTimeout(timeout),
28 theTempIndexCounter(0)
29 {
30+ theLocalUdfs = new rclist<user_function*>;
31 }
32
33
34@@ -143,6 +145,7 @@
35 theTempIndexCounter(0),
36 theConfig(cb.theConfig)
37 {
38+ theLocalUdfs = new rclist<user_function*>;
39 }
40
41
42@@ -169,6 +172,20 @@
43 {
44 }
45
46+//compile all the user_functions so the expr tree is stable at serialize
47+void CompilerCB::prepare_for_serialize()
48+{
49+ rclist<user_function*>::iterator udf_it;
50+ for(udf_it=theLocalUdfs->begin(); udf_it != theLocalUdfs->end(); udf_it++)
51+ {
52+ (*udf_it)->prepare_for_serialize(this);
53+ }
54+}
55+
56+rchandle<rclist<user_function*> > CompilerCB::get_local_udfs()
57+{
58+ return theLocalUdfs;
59+}
60
61 /*******************************************************************************
62
63
64=== modified file 'src/compiler/api/compilercb.h'
65--- src/compiler/api/compilercb.h 2012-01-11 17:30:25 +0000
66+++ src/compiler/api/compilercb.h 2012-02-01 21:49:22 +0000
67@@ -29,7 +29,7 @@
68 // without having the definition of static_context availble.
69 # include "context/static_context.h"
70 #endif
71-
72+#include "zorbatypes/rclist.h"
73 #include "zorbaserialization/class_serializer.h"
74
75 namespace zorba {
76@@ -39,7 +39,6 @@
77 #endif
78 class static_context;
79
80-
81 /*******************************************************************************
82 There is one CompilerCB per query plus one CompilerCB per invocation of an
83 eval or xqdoc expression that appears in the query. The query-level ccb is
84@@ -167,10 +166,14 @@
85
86 config theConfig;
87
88+ rchandle<rclist<user_function*> > theLocalUdfs;//for plan serializer
89+
90 public:
91 SERIALIZABLE_CLASS(CompilerCB);
92 CompilerCB(::zorba::serialization::Archiver& ar);
93 void serialize(::zorba::serialization::Archiver& ar);
94+ void prepare_for_serialize();
95+ rchandle<rclist<user_function*> > get_local_udfs();
96
97 public:
98 CompilerCB(XQueryDiagnostics*, long timeout = -1);
99
100=== modified file 'src/compiler/expression/flwor_expr.cpp'
101--- src/compiler/expression/flwor_expr.cpp 2011-12-21 14:40:33 +0000
102+++ src/compiler/expression/flwor_expr.cpp 2012-02-01 21:49:22 +0000
103@@ -803,7 +803,7 @@
104
105 flwor_clause_t materialize_clause::clone(expr::substitution_t& subst) const
106 {
107- ZORBA_ASSERT(false);
108+ return new materialize_clause(theContext, get_loc());
109 }
110
111
112
113=== modified file 'src/compiler/expression/ftnode.cpp'
114--- src/compiler/expression/ftnode.cpp 2011-07-17 20:05:49 +0000
115+++ src/compiler/expression/ftnode.cpp 2012-02-01 21:49:22 +0000
116@@ -363,7 +363,7 @@
117
118 void ftextension_selection::serialize( serialization::Archiver &ar ) {
119 serialize_baseclass( ar, (ftprimary*)this );
120- ar & pragmas_;
121+ //ar & pragmas_;
122 ar & ftselection_;
123 }
124
125@@ -392,7 +392,7 @@
126
127 void ftextension_option::serialize( serialization::Archiver &ar ) {
128 serialize_baseclass( ar, (ftmatch_option*)this );
129- ar & qname_;
130+ //ar & qname_;
131 ar & val_;
132 }
133
134
135=== modified file 'src/compiler/expression/var_expr.cpp'
136--- src/compiler/expression/var_expr.cpp 2012-01-11 17:30:25 +0000
137+++ src/compiler/expression/var_expr.cpp 2012-02-01 21:49:22 +0000
138@@ -134,6 +134,7 @@
139 ar & theCopyClause;
140 ar & theParamPos;
141 ar & theUDF;
142+ ar & theSetExprs;
143 ar & theIsPrivate;
144 ar & theIsExternal;
145 ar & theIsMutable;
146
147=== modified file 'src/compiler/rewriter/rules/flwor_rules.cpp'
148--- src/compiler/rewriter/rules/flwor_rules.cpp 2011-09-02 20:43:46 +0000
149+++ src/compiler/rewriter/rules/flwor_rules.cpp 2012-02-01 21:49:22 +0000
150@@ -627,6 +627,10 @@
151 {
152 // TODO
153 }
154+ else if (kind == flwor_clause::materialize_clause)
155+ {
156+ // TODO
157+ }
158 else
159 {
160 ZORBA_ASSERT(false);
161
162=== modified file 'src/compiler/translator/translator.cpp'
163--- src/compiler/translator/translator.cpp 2012-01-25 10:24:39 +0000
164+++ src/compiler/translator/translator.cpp 2012-02-01 21:49:22 +0000
165@@ -3340,7 +3340,7 @@
166 }
167 else // Process UDF (non-external) function declaration
168 {
169- f = new user_function(loc, sig, NULL, scriptKind); // no body for now
170+ f = new user_function(loc, sig, NULL, scriptKind, theCCB); // no body for now
171 }
172
173 f->setAnnotations(theAnnotations);
174@@ -10433,7 +10433,8 @@
175 user_function* udf = new user_function(loc,
176 fn->getSignature(),
177 NULL, // no body for now
178- fn->getScriptingKind());
179+ fn->getScriptingKind(),
180+ theCCB);
181
182 std::vector<expr_t> foArgs(arity);
183 std::vector<var_expr_t> udfArgs(arity);
184@@ -10641,7 +10642,8 @@
185 user_function_t udf(new user_function(loc,
186 signature(0, paramTypes, returnType),
187 body.getp(),
188- body->get_scripting_detail()));
189+ body->get_scripting_detail(),
190+ theCCB));
191 udf->setArgVars(argVars);
192 udf->setOptimized(true);
193
194
195=== modified file 'src/context/static_context.cpp'
196--- src/context/static_context.cpp 2012-01-23 10:06:24 +0000
197+++ src/context/static_context.cpp 2012-02-01 21:49:22 +0000
198@@ -22,6 +22,7 @@
199 #include <zorba/external_module.h>
200 #include <zorba/serialization_callback.h>
201
202+#include "functions/udf.h"
203 #include "zorbaserialization/serialization_engine.h"
204
205 #include "zorbamisc/ns_consts.h"
206
207=== modified file 'src/context/static_context.h'
208--- src/context/static_context.h 2012-01-23 10:06:24 +0000
209+++ src/context/static_context.h 2012-02-01 21:49:22 +0000
210@@ -599,6 +599,8 @@
211
212 void serialize(serialization::Archiver& ar);
213
214+ void prepare_for_serialize(CompilerCB *compiler_cb);
215+
216 public:
217 static_context(::zorba::serialization::Archiver& ar);
218
219
220=== modified file 'src/functions/udf.cpp'
221--- src/functions/udf.cpp 2012-01-14 21:58:23 +0000
222+++ src/functions/udf.cpp 2012-02-01 21:49:22 +0000
223@@ -50,7 +50,8 @@
224 const QueryLoc& loc,
225 const signature& sig,
226 expr_t expr_body,
227- short scriptingKind)
228+ short scriptingKind,
229+ CompilerCB *compilerCB)
230 :
231 function(sig, FunctionConsts::FN_UNKNOWN),
232 theLoc(loc),
233@@ -68,6 +69,8 @@
234 resetFlag(FunctionConsts::isBuiltin);
235 setDeterministic(true);
236 setPrivate(false);
237+ theLocalUdfs = compilerCB->get_local_udfs();
238+ theLocalUdfs->push_back(this);
239 }
240
241
242@@ -88,8 +91,22 @@
243 ********************************************************************************/
244 user_function::~user_function()
245 {
246-}
247-
248+ if(theLocalUdfs != NULL)
249+ theLocalUdfs->remove(this);
250+}
251+
252+
253+void user_function::prepare_for_serialize(CompilerCB *compilerCB)
254+{
255+ uint32_t planStateSize;
256+ getPlan(compilerCB, planStateSize);
257+ std::vector<user_function*>::iterator udf_it;
258+ for(udf_it=theMutuallyRecursiveUDFs.begin(); udf_it!=theMutuallyRecursiveUDFs.end();udf_it++)
259+ {
260+ if((*udf_it)->thePlan == NULL)
261+ (*udf_it)->prepare_for_serialize(compilerCB);
262+ }
263+}
264
265 /*******************************************************************************
266
267@@ -124,8 +141,10 @@
268 getPlan(ar.compiler_cb);
269 }
270 #else
271- uint32_t planStateSize;
272- getPlan(ar.compiler_cb, planStateSize);
273+ //uint32_t planStateSize;
274+ //getPlan(ar.compiler_cb, planStateSize);
275+ assert(thePlan != NULL);
276+ ZORBA_ASSERT(thePlan != NULL);
277 #endif
278 }
279 catch(...)
280
281=== modified file 'src/functions/udf.h'
282--- src/functions/udf.h 2012-01-14 21:58:23 +0000
283+++ src/functions/udf.h 2012-02-01 21:49:22 +0000
284@@ -20,6 +20,7 @@
285 #include "functions/function.h"
286
287 #include "compiler/expression/expr_base.h"
288+#include "zorbatypes/rclist.h"
289
290
291 namespace zorba
292@@ -131,17 +132,21 @@
293 bool theCacheResults;
294 bool theCacheComputed;
295
296+ rchandle<rclist<user_function*> > theLocalUdfs;//for plan serializer
297+
298 public:
299 SERIALIZABLE_CLASS(user_function)
300 user_function(::zorba::serialization::Archiver& ar);
301 void serialize(::zorba::serialization::Archiver& ar);
302+ void prepare_for_serialize(CompilerCB *compilerCB);
303
304 public:
305 user_function(
306 const QueryLoc& loc,
307 const signature& sig,
308 expr_t expr_body,
309- short kind);
310+ short kind,
311+ CompilerCB *compilerCB);
312
313 virtual ~user_function();
314
315
316=== modified file 'src/util/uri_util.cpp'
317--- src/util/uri_util.cpp 2011-06-26 09:24:24 +0000
318+++ src/util/uri_util.cpp 2012-02-01 21:49:22 +0000
319@@ -53,7 +53,7 @@
320
321 ///////////////////////////////////////////////////////////////////////////////
322
323-ZORBA_DLL_PUBLIC extern signed char const hex2dec[] = {
324+extern signed char const hex2dec[] = {
325 /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
326 /* 0 */ -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
327 /* 1 */ -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
328@@ -79,7 +79,7 @@
329 /**
330 * Characters that need not be percent-encoded (%xx) in URIs. See RFC 3986.
331 */
332-ZORBA_DLL_PUBLIC extern char const uri_safe[256] = {
333+extern char const uri_safe[256] = {
334 /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
335 /* 0 */ 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
336 /* 1 */ 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
337
338=== modified file 'src/util/uri_util.h'
339--- src/util/uri_util.h 2011-11-26 16:54:51 +0000
340+++ src/util/uri_util.h 2012-02-01 21:49:22 +0000
341@@ -80,8 +80,8 @@
342
343 ////////// Encoding ///////////////////////////////////////////////////////////
344
345-extern char const uri_safe[];
346-extern signed char const hex2dec[];
347+ZORBA_DLL_PUBLIC extern char const uri_safe[];
348+ZORBA_DLL_PUBLIC extern signed char const hex2dec[];
349
350 /**
351 * A %back_insert_iterator can be used to append characters to a string
352
353=== modified file 'src/zorbaserialization/archiver.cpp'
354--- src/zorbaserialization/archiver.cpp 2011-07-13 01:56:45 +0000
355+++ src/zorbaserialization/archiver.cpp 2012-02-01 21:49:22 +0000
356@@ -27,6 +27,7 @@
357 #include "class_serializer.h"
358 #include "mem_archiver.h"
359
360+
361 namespace zorba
362 {
363
364@@ -112,7 +113,7 @@
365 current_level(0),
366 internal_archive(internal_archive),
367 theUserCallback(0),
368- compiler_cb(0),
369+ //compiler_cb(0),
370 dont_allow_delay_for_plan_sctx(false)
371 {
372
373@@ -195,6 +196,7 @@
374 ref_field = check_nonclass_pointer(type, orig_ptr);
375 if(ref_field)
376 {
377+ assert((field_treat != ARCHIVE_FIELD_NORMAL) || (ref_field->field_treat != ARCHIVE_FIELD_NORMAL));
378 if(get_is_temp_field_one_level() && (field_treat == ARCHIVE_FIELD_IS_PTR) && (allow_delay2 == ALLOW_DELAY))
379 allow_delay2 = DONT_ALLOW_DELAY;
380 if(field_treat == ARCHIVE_FIELD_NORMAL)
381@@ -309,6 +311,7 @@
382 }
383 if(ref_field)
384 {
385+ assert((field_treat != ARCHIVE_FIELD_NORMAL) || (ref_field->field_treat != ARCHIVE_FIELD_NORMAL));
386 if(get_is_temp_field_one_level() && (field_treat == ARCHIVE_FIELD_IS_PTR) && (allow_delay2 == ALLOW_DELAY))
387 allow_delay2 = DONT_ALLOW_DELAY;
388 if(field_treat == ARCHIVE_FIELD_NORMAL)
389
390=== modified file 'src/zorbaserialization/archiver.h'
391--- src/zorbaserialization/archiver.h 2011-10-03 09:18:49 +0000
392+++ src/zorbaserialization/archiver.h 2012-02-01 21:49:22 +0000
393@@ -202,7 +202,7 @@
394 SerializationCallback* theUserCallback;
395
396 public:
397- CompilerCB *compiler_cb;///to workaround user defined function compile-at-runtime
398+ //CompilerCB *compiler_cb;///to workaround user defined function compile-at-runtime
399 bool dont_allow_delay_for_plan_sctx;
400 public:
401 Archiver(bool is_serializing_out, bool internal_archive=false);
402
403=== modified file 'src/zorbaserialization/zorba_class_serializer.h'
404--- src/zorbaserialization/zorba_class_serializer.h 2011-07-07 12:05:43 +0000
405+++ src/zorbaserialization/zorba_class_serializer.h 2012-02-01 21:49:22 +0000
406@@ -28,6 +28,7 @@
407 #include "zorbaserialization/archiver.h"
408
409 #include "store/api/shared_types.h"
410+#include "diagnostics/assert.h"
411
412 #include <stdio.h>
413 #include <map>
414@@ -224,7 +225,8 @@
415 bool is_ref;
416 ENUM_ALLOW_DELAY allow_delay = ar.get_allow_delay();
417 is_ref = ar.add_compound_field("rchandle<T>", 0, !FIELD_IS_CLASS, "", &obj, ARCHIVE_FIELD_NORMAL);
418- if(!is_ref)
419+ assert(!is_ref);
420+ ZORBA_ASSERT(!is_ref);
421 {
422 T *p = obj.getp();
423 if(allow_delay != ALLOW_DELAY)
424@@ -242,10 +244,6 @@
425 ar.set_is_temp_field_one_level(false);
426 ar.add_end_compound_field();
427 }
428- else
429- {
430- assert(false);
431- }
432 }
433 else
434 {
435
436=== modified file 'src/zorbatypes/rchandle.h'
437--- src/zorbatypes/rchandle.h 2011-07-12 20:15:01 +0000
438+++ src/zorbatypes/rchandle.h 2012-02-01 21:49:22 +0000
439@@ -92,9 +92,9 @@
440
441 long getRefCount() const { return theRefCount; }
442
443- long* getSharedRefCounter() const { ZORBA_FATAL(0, ""); return NULL; }
444+ //long* getSharedRefCounter() const { ZORBA_FATAL(0, ""); return NULL; }
445
446- SYNC_CODE(RCLock* getRCLock() const { ZORBA_FATAL(0, ""); return NULL; });
447+ //SYNC_CODE(RCLock* getRCLock() const { ZORBA_FATAL(0, ""); return NULL; });
448
449 void addReference(long* sharedCounter SYNC_PARAM2(RCLock* lock)) const;
450
451
452=== added file 'src/zorbatypes/rclist.h'
453--- src/zorbatypes/rclist.h 1970-01-01 00:00:00 +0000
454+++ src/zorbatypes/rclist.h 2012-02-01 21:49:22 +0000
455@@ -0,0 +1,37 @@
456+/*
457+ * Copyright 2006-2008 The FLWOR Foundation.
458+ *
459+ * Licensed under the Apache License, Version 2.0 (the "License");
460+ * you may not use this file except in compliance with the License.
461+ * You may obtain a copy of the License at
462+ *
463+ * http://www.apache.org/licenses/LICENSE-2.0
464+ *
465+ * Unless required by applicable law or agreed to in writing, software
466+ * distributed under the License is distributed on an "AS IS" BASIS,
467+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
468+ * See the License for the specific language governing permissions and
469+ * limitations under the License.
470+ */
471+#include <list>
472+#include "common/common.h"
473+#include "zorbatypes/rchandle.h"
474+#pragma once
475+#ifndef ZORBA_REF_COUNTED_STD_LIST
476+#define ZORBA_REF_COUNTED_STD_LIST
477+
478+namespace zorba
479+{
480+
481+template <typename T>
482+class rclist : public RCObject, public std::list<T>
483+{
484+ SYNC_CODE(mutable RCLock lock;)
485+public:
486+ long* getSharedRefCounter() const { return NULL; }
487+ SYNC_CODE(RCLock* getRCLock() const { return &lock; });
488+};
489+
490+}//end namespace zorba
491+
492+#endif

Subscribers

People subscribed via source and target branches