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

Proposed by Daniel Turcanu
Status: Superseded
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
Chris Hillery Needs Fixing
Zorba Coders Pending
Markos Zaharioudakis Pending
Review via email: mp+89025@code.launchpad.net

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

This proposal has been superseded by a proposal from 2012-02-01.

Commit message

Fix in plan serializer about preparing user_functions plan for serialization.

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 :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

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 :
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 :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Chris Hillery (ceejatec) wrote :

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 :

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 :

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

10535. By Daniel Turcanu

Update to trunk

10536. By Daniel Turcanu

Fix plan serializer for some full text classes

10537. By Matthias Brantner

fix for bug #924205

10538. By Daniel Turcanu

Update to trunk

Unmerged revisions

10538. By Daniel Turcanu

Update to trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/api/xqueryimpl.cpp'
--- src/api/xqueryimpl.cpp 2012-01-11 17:30:25 +0000
+++ src/api/xqueryimpl.cpp 2012-02-01 21:49:19 +0000
@@ -193,7 +193,8 @@
193 }193 }
194 else194 else
195 {195 {
196 ar.compiler_cb = theCompilerCB;196 //ar.compiler_cb = theCompilerCB;
197 theCompilerCB->prepare_for_serialize();
197 }198 }
198199
199 ar & theCompilerCB;200 ar & theCompilerCB;
200201
=== modified file 'src/compiler/api/compilercb.cpp'
--- src/compiler/api/compilercb.cpp 2012-01-11 17:30:25 +0000
+++ src/compiler/api/compilercb.cpp 2012-02-01 21:49:19 +0000
@@ -27,6 +27,7 @@
27#include "system/properties.h"27#include "system/properties.h"
2828
29#include "zorbaserialization/serialization_engine.h"29#include "zorbaserialization/serialization_engine.h"
30#include "functions/udf.h"
3031
3132
32namespace zorba 33namespace zorba
@@ -120,6 +121,7 @@
120 theTimeout(timeout),121 theTimeout(timeout),
121 theTempIndexCounter(0)122 theTempIndexCounter(0)
122{123{
124 theLocalUdfs = new rclist<user_function*>;
123}125}
124126
125127
@@ -143,6 +145,7 @@
143 theTempIndexCounter(0),145 theTempIndexCounter(0),
144 theConfig(cb.theConfig)146 theConfig(cb.theConfig)
145{147{
148 theLocalUdfs = new rclist<user_function*>;
146}149}
147150
148151
@@ -169,6 +172,20 @@
169{172{
170}173}
171174
175//compile all the user_functions so the expr tree is stable at serialize
176void CompilerCB::prepare_for_serialize()
177{
178 rclist<user_function*>::iterator udf_it;
179 for(udf_it=theLocalUdfs->begin(); udf_it != theLocalUdfs->end(); udf_it++)
180 {
181 (*udf_it)->prepare_for_serialize(this);
182 }
183}
184
185rchandle<rclist<user_function*> > CompilerCB::get_local_udfs()
186{
187 return theLocalUdfs;
188}
172189
173/*******************************************************************************190/*******************************************************************************
174191
175192
=== modified file 'src/compiler/api/compilercb.h'
--- src/compiler/api/compilercb.h 2012-01-11 17:30:25 +0000
+++ src/compiler/api/compilercb.h 2012-02-01 21:49:19 +0000
@@ -29,7 +29,7 @@
29// without having the definition of static_context availble.29// without having the definition of static_context availble.
30# include "context/static_context.h"30# include "context/static_context.h"
31#endif31#endif
3232#include "zorbatypes/rclist.h"
33#include "zorbaserialization/class_serializer.h"33#include "zorbaserialization/class_serializer.h"
3434
35namespace zorba {35namespace zorba {
@@ -39,7 +39,6 @@
39#endif39#endif
40class static_context;40class static_context;
4141
42
43/*******************************************************************************42/*******************************************************************************
44 There is one CompilerCB per query plus one CompilerCB per invocation of an43 There is one CompilerCB per query plus one CompilerCB per invocation of an
45 eval or xqdoc expression that appears in the query. The query-level ccb is44 eval or xqdoc expression that appears in the query. The query-level ccb is
@@ -167,10 +166,14 @@
167166
168 config theConfig;167 config theConfig;
169168
169 rchandle<rclist<user_function*> > theLocalUdfs;//for plan serializer
170
170public:171public:
171 SERIALIZABLE_CLASS(CompilerCB);172 SERIALIZABLE_CLASS(CompilerCB);
172 CompilerCB(::zorba::serialization::Archiver& ar);173 CompilerCB(::zorba::serialization::Archiver& ar);
173 void serialize(::zorba::serialization::Archiver& ar);174 void serialize(::zorba::serialization::Archiver& ar);
175 void prepare_for_serialize();
176 rchandle<rclist<user_function*> > get_local_udfs();
174177
175public:178public:
176 CompilerCB(XQueryDiagnostics*, long timeout = -1);179 CompilerCB(XQueryDiagnostics*, long timeout = -1);
177180
=== modified file 'src/compiler/expression/flwor_expr.cpp'
--- src/compiler/expression/flwor_expr.cpp 2011-12-21 14:40:33 +0000
+++ src/compiler/expression/flwor_expr.cpp 2012-02-01 21:49:19 +0000
@@ -803,7 +803,7 @@
803803
804flwor_clause_t materialize_clause::clone(expr::substitution_t& subst) const804flwor_clause_t materialize_clause::clone(expr::substitution_t& subst) const
805{805{
806 ZORBA_ASSERT(false);806 return new materialize_clause(theContext, get_loc());
807}807}
808808
809809
810810
=== modified file 'src/compiler/expression/ftnode.cpp'
--- src/compiler/expression/ftnode.cpp 2011-07-17 20:05:49 +0000
+++ src/compiler/expression/ftnode.cpp 2012-02-01 21:49:19 +0000
@@ -363,7 +363,7 @@
363363
364void ftextension_selection::serialize( serialization::Archiver &ar ) {364void ftextension_selection::serialize( serialization::Archiver &ar ) {
365 serialize_baseclass( ar, (ftprimary*)this );365 serialize_baseclass( ar, (ftprimary*)this );
366 ar & pragmas_;366 //ar & pragmas_;
367 ar & ftselection_;367 ar & ftselection_;
368}368}
369369
@@ -392,7 +392,7 @@
392392
393void ftextension_option::serialize( serialization::Archiver &ar ) {393void ftextension_option::serialize( serialization::Archiver &ar ) {
394 serialize_baseclass( ar, (ftmatch_option*)this );394 serialize_baseclass( ar, (ftmatch_option*)this );
395 ar & qname_;395 //ar & qname_;
396 ar & val_;396 ar & val_;
397}397}
398398
399399
=== modified file 'src/compiler/expression/var_expr.cpp'
--- src/compiler/expression/var_expr.cpp 2012-01-11 17:30:25 +0000
+++ src/compiler/expression/var_expr.cpp 2012-02-01 21:49:19 +0000
@@ -134,6 +134,7 @@
134 ar & theCopyClause;134 ar & theCopyClause;
135 ar & theParamPos;135 ar & theParamPos;
136 ar & theUDF;136 ar & theUDF;
137 ar & theSetExprs;
137 ar & theIsPrivate;138 ar & theIsPrivate;
138 ar & theIsExternal;139 ar & theIsExternal;
139 ar & theIsMutable;140 ar & theIsMutable;
140141
=== modified file 'src/compiler/rewriter/rules/flwor_rules.cpp'
--- src/compiler/rewriter/rules/flwor_rules.cpp 2011-09-02 20:43:46 +0000
+++ src/compiler/rewriter/rules/flwor_rules.cpp 2012-02-01 21:49:19 +0000
@@ -627,6 +627,10 @@
627 {627 {
628 // TODO628 // TODO
629 }629 }
630 else if (kind == flwor_clause::materialize_clause)
631 {
632 // TODO
633 }
630 else634 else
631 {635 {
632 ZORBA_ASSERT(false);636 ZORBA_ASSERT(false);
633637
=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp 2012-01-25 10:24:39 +0000
+++ src/compiler/translator/translator.cpp 2012-02-01 21:49:19 +0000
@@ -3340,7 +3340,7 @@
3340 }3340 }
3341 else // Process UDF (non-external) function declaration3341 else // Process UDF (non-external) function declaration
3342 {3342 {
3343 f = new user_function(loc, sig, NULL, scriptKind); // no body for now3343 f = new user_function(loc, sig, NULL, scriptKind, theCCB); // no body for now
3344 }3344 }
33453345
3346 f->setAnnotations(theAnnotations);3346 f->setAnnotations(theAnnotations);
@@ -10433,7 +10433,8 @@
10433 user_function* udf = new user_function(loc,10433 user_function* udf = new user_function(loc,
10434 fn->getSignature(),10434 fn->getSignature(),
10435 NULL, // no body for now10435 NULL, // no body for now
10436 fn->getScriptingKind());10436 fn->getScriptingKind(),
10437 theCCB);
1043710438
10438 std::vector<expr_t> foArgs(arity);10439 std::vector<expr_t> foArgs(arity);
10439 std::vector<var_expr_t> udfArgs(arity);10440 std::vector<var_expr_t> udfArgs(arity);
@@ -10641,7 +10642,8 @@
10641 user_function_t udf(new user_function(loc,10642 user_function_t udf(new user_function(loc,
10642 signature(0, paramTypes, returnType),10643 signature(0, paramTypes, returnType),
10643 body.getp(),10644 body.getp(),
10644 body->get_scripting_detail()));10645 body->get_scripting_detail(),
10646 theCCB));
10645 udf->setArgVars(argVars);10647 udf->setArgVars(argVars);
10646 udf->setOptimized(true);10648 udf->setOptimized(true);
1064710649
1064810650
=== modified file 'src/context/static_context.cpp'
--- src/context/static_context.cpp 2012-01-23 10:06:24 +0000
+++ src/context/static_context.cpp 2012-02-01 21:49:19 +0000
@@ -22,6 +22,7 @@
22#include <zorba/external_module.h>22#include <zorba/external_module.h>
23#include <zorba/serialization_callback.h>23#include <zorba/serialization_callback.h>
2424
25#include "functions/udf.h"
25#include "zorbaserialization/serialization_engine.h"26#include "zorbaserialization/serialization_engine.h"
2627
27#include "zorbamisc/ns_consts.h"28#include "zorbamisc/ns_consts.h"
2829
=== modified file 'src/context/static_context.h'
--- src/context/static_context.h 2012-01-23 10:06:24 +0000
+++ src/context/static_context.h 2012-02-01 21:49:19 +0000
@@ -599,6 +599,8 @@
599599
600 void serialize(serialization::Archiver& ar);600 void serialize(serialization::Archiver& ar);
601601
602 void prepare_for_serialize(CompilerCB *compiler_cb);
603
602public:604public:
603 static_context(::zorba::serialization::Archiver& ar);605 static_context(::zorba::serialization::Archiver& ar);
604606
605607
=== modified file 'src/functions/udf.cpp'
--- src/functions/udf.cpp 2012-01-14 21:58:23 +0000
+++ src/functions/udf.cpp 2012-02-01 21:49:19 +0000
@@ -50,7 +50,8 @@
50 const QueryLoc& loc,50 const QueryLoc& loc,
51 const signature& sig,51 const signature& sig,
52 expr_t expr_body,52 expr_t expr_body,
53 short scriptingKind)53 short scriptingKind,
54 CompilerCB *compilerCB)
54 :55 :
55 function(sig, FunctionConsts::FN_UNKNOWN),56 function(sig, FunctionConsts::FN_UNKNOWN),
56 theLoc(loc),57 theLoc(loc),
@@ -68,6 +69,8 @@
68 resetFlag(FunctionConsts::isBuiltin);69 resetFlag(FunctionConsts::isBuiltin);
69 setDeterministic(true);70 setDeterministic(true);
70 setPrivate(false);71 setPrivate(false);
72 theLocalUdfs = compilerCB->get_local_udfs();
73 theLocalUdfs->push_back(this);
71}74}
7275
7376
@@ -88,8 +91,22 @@
88********************************************************************************/91********************************************************************************/
89user_function::~user_function()92user_function::~user_function()
90{93{
91}94 if(theLocalUdfs != NULL)
9295 theLocalUdfs->remove(this);
96}
97
98
99void user_function::prepare_for_serialize(CompilerCB *compilerCB)
100{
101 uint32_t planStateSize;
102 getPlan(compilerCB, planStateSize);
103 std::vector<user_function*>::iterator udf_it;
104 for(udf_it=theMutuallyRecursiveUDFs.begin(); udf_it!=theMutuallyRecursiveUDFs.end();udf_it++)
105 {
106 if((*udf_it)->thePlan == NULL)
107 (*udf_it)->prepare_for_serialize(compilerCB);
108 }
109}
93110
94/*******************************************************************************111/*******************************************************************************
95112
@@ -124,8 +141,10 @@
124 getPlan(ar.compiler_cb);141 getPlan(ar.compiler_cb);
125 }142 }
126#else143#else
127 uint32_t planStateSize;144 //uint32_t planStateSize;
128 getPlan(ar.compiler_cb, planStateSize);145 //getPlan(ar.compiler_cb, planStateSize);
146 assert(thePlan != NULL);
147 ZORBA_ASSERT(thePlan != NULL);
129#endif148#endif
130 }149 }
131 catch(...)150 catch(...)
132151
=== modified file 'src/functions/udf.h'
--- src/functions/udf.h 2012-01-14 21:58:23 +0000
+++ src/functions/udf.h 2012-02-01 21:49:19 +0000
@@ -20,6 +20,7 @@
20#include "functions/function.h"20#include "functions/function.h"
2121
22#include "compiler/expression/expr_base.h"22#include "compiler/expression/expr_base.h"
23#include "zorbatypes/rclist.h"
2324
2425
25namespace zorba 26namespace zorba
@@ -131,17 +132,21 @@
131 bool theCacheResults;132 bool theCacheResults;
132 bool theCacheComputed;133 bool theCacheComputed;
133134
135 rchandle<rclist<user_function*> > theLocalUdfs;//for plan serializer
136
134public:137public:
135 SERIALIZABLE_CLASS(user_function)138 SERIALIZABLE_CLASS(user_function)
136 user_function(::zorba::serialization::Archiver& ar);139 user_function(::zorba::serialization::Archiver& ar);
137 void serialize(::zorba::serialization::Archiver& ar);140 void serialize(::zorba::serialization::Archiver& ar);
141 void prepare_for_serialize(CompilerCB *compilerCB);
138142
139public:143public:
140 user_function(144 user_function(
141 const QueryLoc& loc,145 const QueryLoc& loc,
142 const signature& sig,146 const signature& sig,
143 expr_t expr_body,147 expr_t expr_body,
144 short kind);148 short kind,
149 CompilerCB *compilerCB);
145150
146 virtual ~user_function();151 virtual ~user_function();
147152
148153
=== modified file 'src/util/uri_util.cpp'
--- src/util/uri_util.cpp 2011-06-26 09:24:24 +0000
+++ src/util/uri_util.cpp 2012-02-01 21:49:19 +0000
@@ -53,7 +53,7 @@
5353
54///////////////////////////////////////////////////////////////////////////////54///////////////////////////////////////////////////////////////////////////////
5555
56ZORBA_DLL_PUBLIC extern signed char const hex2dec[] = { 56extern signed char const hex2dec[] = {
57 /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */57 /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
58 /* 0 */ -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,58 /* 0 */ -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
59 /* 1 */ -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,59 /* 1 */ -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
@@ -79,7 +79,7 @@
79/**79/**
80 * Characters that need not be percent-encoded (%xx) in URIs. See RFC 3986.80 * Characters that need not be percent-encoded (%xx) in URIs. See RFC 3986.
81 */81 */
82ZORBA_DLL_PUBLIC extern char const uri_safe[256] = {82extern char const uri_safe[256] = {
83 /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */83 /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
84 /* 0 */ 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,84 /* 0 */ 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
85 /* 1 */ 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,85 /* 1 */ 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
8686
=== modified file 'src/util/uri_util.h'
--- src/util/uri_util.h 2011-11-26 16:54:51 +0000
+++ src/util/uri_util.h 2012-02-01 21:49:19 +0000
@@ -80,8 +80,8 @@
8080
81////////// Encoding ///////////////////////////////////////////////////////////81////////// Encoding ///////////////////////////////////////////////////////////
8282
83extern char const uri_safe[];83ZORBA_DLL_PUBLIC extern char const uri_safe[];
84extern signed char const hex2dec[];84ZORBA_DLL_PUBLIC extern signed char const hex2dec[];
8585
86/**86/**
87 * A %back_insert_iterator can be used to append characters to a string87 * A %back_insert_iterator can be used to append characters to a string
8888
=== modified file 'src/zorbaserialization/archiver.cpp'
--- src/zorbaserialization/archiver.cpp 2011-07-13 01:56:45 +0000
+++ src/zorbaserialization/archiver.cpp 2012-02-01 21:49:19 +0000
@@ -27,6 +27,7 @@
27#include "class_serializer.h"27#include "class_serializer.h"
28#include "mem_archiver.h"28#include "mem_archiver.h"
2929
30
30namespace zorba31namespace zorba
31{32{
3233
@@ -112,7 +113,7 @@
112 current_level(0),113 current_level(0),
113 internal_archive(internal_archive),114 internal_archive(internal_archive),
114 theUserCallback(0),115 theUserCallback(0),
115 compiler_cb(0),116 //compiler_cb(0),
116 dont_allow_delay_for_plan_sctx(false)117 dont_allow_delay_for_plan_sctx(false)
117{118{
118119
@@ -195,6 +196,7 @@
195 ref_field = check_nonclass_pointer(type, orig_ptr);196 ref_field = check_nonclass_pointer(type, orig_ptr);
196 if(ref_field)197 if(ref_field)
197 {198 {
199 assert((field_treat != ARCHIVE_FIELD_NORMAL) || (ref_field->field_treat != ARCHIVE_FIELD_NORMAL));
198 if(get_is_temp_field_one_level() && (field_treat == ARCHIVE_FIELD_IS_PTR) && (allow_delay2 == ALLOW_DELAY))200 if(get_is_temp_field_one_level() && (field_treat == ARCHIVE_FIELD_IS_PTR) && (allow_delay2 == ALLOW_DELAY))
199 allow_delay2 = DONT_ALLOW_DELAY;201 allow_delay2 = DONT_ALLOW_DELAY;
200 if(field_treat == ARCHIVE_FIELD_NORMAL)202 if(field_treat == ARCHIVE_FIELD_NORMAL)
@@ -309,6 +311,7 @@
309 }311 }
310 if(ref_field)312 if(ref_field)
311 {313 {
314 assert((field_treat != ARCHIVE_FIELD_NORMAL) || (ref_field->field_treat != ARCHIVE_FIELD_NORMAL));
312 if(get_is_temp_field_one_level() && (field_treat == ARCHIVE_FIELD_IS_PTR) && (allow_delay2 == ALLOW_DELAY))315 if(get_is_temp_field_one_level() && (field_treat == ARCHIVE_FIELD_IS_PTR) && (allow_delay2 == ALLOW_DELAY))
313 allow_delay2 = DONT_ALLOW_DELAY;316 allow_delay2 = DONT_ALLOW_DELAY;
314 if(field_treat == ARCHIVE_FIELD_NORMAL)317 if(field_treat == ARCHIVE_FIELD_NORMAL)
315318
=== modified file 'src/zorbaserialization/archiver.h'
--- src/zorbaserialization/archiver.h 2011-10-03 09:18:49 +0000
+++ src/zorbaserialization/archiver.h 2012-02-01 21:49:19 +0000
@@ -202,7 +202,7 @@
202 SerializationCallback* theUserCallback;202 SerializationCallback* theUserCallback;
203203
204public:204public:
205 CompilerCB *compiler_cb;///to workaround user defined function compile-at-runtime205 //CompilerCB *compiler_cb;///to workaround user defined function compile-at-runtime
206 bool dont_allow_delay_for_plan_sctx;206 bool dont_allow_delay_for_plan_sctx;
207public:207public:
208 Archiver(bool is_serializing_out, bool internal_archive=false);208 Archiver(bool is_serializing_out, bool internal_archive=false);
209209
=== modified file 'src/zorbaserialization/zorba_class_serializer.h'
--- src/zorbaserialization/zorba_class_serializer.h 2011-07-07 12:05:43 +0000
+++ src/zorbaserialization/zorba_class_serializer.h 2012-02-01 21:49:19 +0000
@@ -28,6 +28,7 @@
28#include "zorbaserialization/archiver.h"28#include "zorbaserialization/archiver.h"
2929
30#include "store/api/shared_types.h"30#include "store/api/shared_types.h"
31#include "diagnostics/assert.h"
3132
32#include <stdio.h>33#include <stdio.h>
33#include <map>34#include <map>
@@ -224,7 +225,8 @@
224 bool is_ref;225 bool is_ref;
225 ENUM_ALLOW_DELAY allow_delay = ar.get_allow_delay();226 ENUM_ALLOW_DELAY allow_delay = ar.get_allow_delay();
226 is_ref = ar.add_compound_field("rchandle<T>", 0, !FIELD_IS_CLASS, "", &obj, ARCHIVE_FIELD_NORMAL);227 is_ref = ar.add_compound_field("rchandle<T>", 0, !FIELD_IS_CLASS, "", &obj, ARCHIVE_FIELD_NORMAL);
227 if(!is_ref)228 assert(!is_ref);
229 ZORBA_ASSERT(!is_ref);
228 {230 {
229 T *p = obj.getp();231 T *p = obj.getp();
230 if(allow_delay != ALLOW_DELAY)232 if(allow_delay != ALLOW_DELAY)
@@ -242,10 +244,6 @@
242 ar.set_is_temp_field_one_level(false);244 ar.set_is_temp_field_one_level(false);
243 ar.add_end_compound_field();245 ar.add_end_compound_field();
244 }246 }
245 else
246 {
247 assert(false);
248 }
249 }247 }
250 else248 else
251 {249 {
252250
=== modified file 'src/zorbatypes/rchandle.h'
--- src/zorbatypes/rchandle.h 2011-07-12 20:15:01 +0000
+++ src/zorbatypes/rchandle.h 2012-02-01 21:49:19 +0000
@@ -92,9 +92,9 @@
9292
93 long getRefCount() const { return theRefCount; }93 long getRefCount() const { return theRefCount; }
9494
95 long* getSharedRefCounter() const { ZORBA_FATAL(0, ""); return NULL; } 95 //long* getSharedRefCounter() const { ZORBA_FATAL(0, ""); return NULL; }
96 96
97 SYNC_CODE(RCLock* getRCLock() const { ZORBA_FATAL(0, ""); return NULL; });97 //SYNC_CODE(RCLock* getRCLock() const { ZORBA_FATAL(0, ""); return NULL; });
9898
99 void addReference(long* sharedCounter SYNC_PARAM2(RCLock* lock)) const;99 void addReference(long* sharedCounter SYNC_PARAM2(RCLock* lock)) const;
100100
101101
=== added file 'src/zorbatypes/rclist.h'
--- src/zorbatypes/rclist.h 1970-01-01 00:00:00 +0000
+++ src/zorbatypes/rclist.h 2012-02-01 21:49:19 +0000
@@ -0,0 +1,37 @@
1/*
2 * Copyright 2006-2008 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#include <list>
17#include "common/common.h"
18#include "zorbatypes/rchandle.h"
19#pragma once
20#ifndef ZORBA_REF_COUNTED_STD_LIST
21#define ZORBA_REF_COUNTED_STD_LIST
22
23namespace zorba
24{
25
26template <typename T>
27class rclist : public RCObject, public std::list<T>
28{
29 SYNC_CODE(mutable RCLock lock;)
30public:
31 long* getSharedRefCounter() const { return NULL; }
32 SYNC_CODE(RCLock* getRCLock() const { return &lock; });
33};
34
35}//end namespace zorba
36
37#endif

Subscribers

People subscribed via source and target branches