Merge lp:~zorba-coders/zorba/use-dataguide into lp:zorba

Proposed by Nicolae Brinza
Status: Needs review
Proposed branch: lp:~zorba-coders/zorba/use-dataguide
Merge into: lp:zorba
Diff against target: 7216 lines (+2682/-401)
186 files modified
src/annotations/annotations.cpp (+9/-0)
src/annotations/annotations.h (+4/-1)
src/common/shared_types.h (+3/-0)
src/compiler/codegen/plan_visitor.cpp (+16/-1)
src/compiler/expression/CMakeLists.txt (+2/-1)
src/compiler/expression/expr_base.cpp (+109/-0)
src/compiler/expression/expr_base.h (+12/-0)
src/compiler/expression/expr_clone.cpp (+3/-0)
src/compiler/expression/expr_type.cpp (+4/-0)
src/compiler/expression/json_dataguide.cpp (+358/-0)
src/compiler/expression/json_dataguide.h (+157/-0)
src/compiler/expression/var_expr.cpp (+1/-0)
src/compiler/rewriter/framework/default_optimizer.cpp (+10/-1)
src/compiler/rewriter/rules/nodeid_rules.cpp (+369/-0)
src/compiler/rewriter/rules/rule_base.h (+2/-1)
src/compiler/rewriter/rules/ruleset.h (+25/-0)
src/functions/function.cpp (+24/-0)
src/functions/function.h (+4/-2)
src/functions/pregenerated/func_accessors.h (+3/-10)
src/functions/pregenerated/func_any_uri.h (+0/-1)
src/functions/pregenerated/func_base64.h (+0/-2)
src/functions/pregenerated/func_booleans.h (+0/-3)
src/functions/pregenerated/func_collections.h (+12/-34)
src/functions/pregenerated/func_context.h (+0/-8)
src/functions/pregenerated/func_datetime.h (+0/-9)
src/functions/pregenerated/func_documents.h (+0/-5)
src/functions/pregenerated/func_durations_dates_times.h (+0/-21)
src/functions/pregenerated/func_errors_and_diagnostics.h (+0/-2)
src/functions/pregenerated/func_fetch.h (+0/-3)
src/functions/pregenerated/func_fn_hof_functions.h (+7/-7)
src/functions/pregenerated/func_fnput.h (+0/-1)
src/functions/pregenerated/func_ft_module.h (+0/-15)
src/functions/pregenerated/func_ic_ddl.h (+0/-3)
src/functions/pregenerated/func_index_func.h (+0/-1)
src/functions/pregenerated/func_item.h (+0/-1)
src/functions/pregenerated/func_json.h (+0/-2)
src/functions/pregenerated/func_jsoniq_functions.h (+4/-23)
src/functions/pregenerated/func_maps.h (+0/-9)
src/functions/pregenerated/func_maths.h (+0/-26)
src/functions/pregenerated/func_node_position.h (+0/-24)
src/functions/pregenerated/func_nodes.h (+5/-20)
src/functions/pregenerated/func_numerics.h (+3/-8)
src/functions/pregenerated/func_other_diagnostics.h (+0/-2)
src/functions/pregenerated/func_parse_fragment.h (+1/-3)
src/functions/pregenerated/func_parsing_and_serializing.h (+3/-2)
src/functions/pregenerated/func_qnames.h (+0/-8)
src/functions/pregenerated/func_random.h (+0/-3)
src/functions/pregenerated/func_reference.h (+0/-4)
src/functions/pregenerated/func_schema.h (+0/-3)
src/functions/pregenerated/func_sctx.h (+0/-25)
src/functions/pregenerated/func_sequences.h (+5/-32)
src/functions/pregenerated/func_strings.h (+2/-31)
src/functions/pregenerated/func_uris.h (+0/-3)
src/functions/pregenerated/func_xqdoc.h (+0/-2)
src/runtime/collections/collections_impl.cpp (+5/-4)
src/runtime/collections/pregenerated/collections.cpp (+1/-0)
src/runtime/collections/pregenerated/collections.h (+5/-1)
src/runtime/json/json_loader.cpp (+89/-6)
src/runtime/json/json_loader.h (+13/-2)
src/runtime/json/jsoniq_functions_impl.cpp (+1/-1)
src/runtime/json/pregenerated/jsoniq_functions.cpp (+1/-0)
src/runtime/json/pregenerated/jsoniq_functions.h (+5/-1)
src/runtime/spec/codegen-h.xq (+12/-2)
src/runtime/spec/collections/collections.xml (+15/-3)
src/runtime/spec/json/jsoniq_functions.xml (+10/-0)
src/runtime/spec/parsing_and_serializing/parsing_and_serializing.xml (+1/-0)
src/store/api/store.h (+3/-1)
src/store/naive/item.cpp (+3/-3)
src/store/naive/json_items.cpp (+13/-2)
src/store/naive/store.cpp (+2/-1)
src/store/naive/store.h (+1/-1)
src/system/globalenv.cpp (+2/-2)
src/system/zorba_properties.h (+12/-2)
src/system/zorba_properties.txt (+1/-0)
test/driver/specification.h (+15/-2)
test/driver/testdriver.cpp (+23/-4)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide-use/dataguide-use-01.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-01.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-02.xml.res (+3/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-03.xml.res (+3/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-04.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-05.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-06.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-07.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-08.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-09.xml.res (+3/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-10.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-11.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-12.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-13.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-14.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-15.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-16.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-17.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-18.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-19.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-20.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-21.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-22.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-23.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-24.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-25.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-26.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-27.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-28.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-29.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-30.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-31.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-32.xml.res (+3/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-33.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-34.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-35.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-36.xml.res (+2/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide-use/dataguide-use-01.xq (+3/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-01.jq (+19/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-01.spec (+2/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-02.jq (+29/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-02.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-03.jq (+38/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-03.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-04.jq (+22/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-04.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-05.jq (+25/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-05.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-06.jq (+26/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-06.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-07.jq (+27/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-07.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-08.jq (+27/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-08.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-09.jq (+33/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-09.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-10.jq (+27/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-10.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-11.jq (+25/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-11.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-12.jq (+28/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-12.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-13.jq (+29/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-13.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-14.jq (+29/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-14.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-15.jq (+29/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-15.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-16.jq (+31/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-16.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-17.jq (+31/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-17.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-18.jq (+32/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-18.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-19.jq (+32/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-19.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-20.jq (+38/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-20.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-21.jq (+33/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-21.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-22.jq (+38/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-22.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-23.jq (+39/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-23.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-24.jq (+32/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-24.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-25.jq (+20/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-25.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-26.jq (+20/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-26.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-27.jq (+22/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-27.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-28.jq (+22/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-28.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-29.jq (+228/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-29.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-30.jq (+25/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-30.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-31.jq (+17/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-31.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-32.jq (+24/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-32.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-33.jq (+14/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-33.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-34.jq (+19/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-34.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-35.jq (+24/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-35.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-36.jq (+25/-0)
test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-36.spec (+1/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/use-dataguide
Reviewer Review Type Date Requested Status
Paul J. Lucas Approve
Markos Zaharioudakis Needs Fixing
Matthias Brantner Approve
Nicolae Brinza Approve
Review via email: mp+176385@code.launchpad.net

Commit message

Implemented push-down of the projection information into the json loader.

Description of the change

Implemented push-down of the projection information into the json loader.

To post a comment you must log in.
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue starting for the following merge proposals:
https://code.launchpad.net/~zorba-coders/zorba/use-dataguide/+merge/176385

Progress dashboard at http://jenkins.lambda.nu/view/ValidationQueue

Revision history for this message
Nicolae Brinza (nbrinza) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue result for https://code.launchpad.net/~zorba-coders/zorba/use-dataguide/+merge/176385

Stage "BuildZorbaUbuntu" failed.

Check compiler output at http://jenkins.lambda.nu/job/BuildZorbaUbuntu/122/parsed_console to view the results.

lp:~zorba-coders/zorba/use-dataguide updated
11491. By Nicolae Brinza

Merged with Zorba trunk

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

Validation queue starting for the following merge proposals:
https://code.launchpad.net/~zorba-coders/zorba/use-dataguide/+merge/176385

Progress dashboard at http://jenkins.lambda.nu/view/ValidationQueue

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

Validation queue starting for the following merge proposals:
https://code.launchpad.net/~zorba-coders/zorba/use-dataguide/+merge/176385

Progress dashboard at http://jenkins.lambda.nu/view/ValidationQueue

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

Validation queue result for https://code.launchpad.net/~zorba-coders/zorba/use-dataguide/+merge/176385

Stage "TestZorbaUbuntu" failed.
1 tests failed (8384 total tests run).

Check test results at http://jenkins.lambda.nu/job/TestZorbaUbuntu/104/testReport/ to view the results.

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

Voting criteria failed for the following merge proposals:

https://code.launchpad.net/~zorba-coders/zorba/use-dataguide/+merge/176385 :
Votes: {'Approve': 1, 'Pending': 1}

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

Validation queue result for https://code.launchpad.net/~zorba-coders/zorba/use-dataguide/+merge/176385

Stage "CommitZorba" failed.

Check console output at http://jenkins.lambda.nu/job/CommitZorba/47/console to view the results.

lp:~zorba-coders/zorba/use-dataguide updated
11492. By Nicolae Brinza

Fixed a bug in the dataguide+json-loader.

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

Validation queue starting for the following merge proposals:
https://code.launchpad.net/~zorba-coders/zorba/use-dataguide/+merge/176385

Progress dashboard at http://jenkins.lambda.nu/view/ValidationQueue

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

Voting criteria failed for the following merge proposals:

https://code.launchpad.net/~zorba-coders/zorba/use-dataguide/+merge/176385 :
Votes: {'Approve': 1, 'Pending': 1}

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

Validation queue result for https://code.launchpad.net/~zorba-coders/zorba/use-dataguide/+merge/176385

Stage "CommitZorba" failed.

Check console output at http://jenkins.lambda.nu/job/CommitZorba/48/console to view the results.

Revision history for this message
Matthias Brantner (matthias-brantner) wrote :

I have tried some basic queries and there is a huge performance improvement. This is great.
However, I detected a memory leak and have one question.

- memory leak in translator.cpp:4823

==20325== 88 (32 direct, 56 indirect) bytes in 1 blocks are definitely lost in loss record 4 of 4
==20325== at 0x4C2B1C7: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==20325== by 0x55B8897: zorba::TranslatorImpl::begin_visit(zorba::AnnotationListParsenode const&) (translator.cpp:4823)
==20325== by 0x556447D: zorba::AnnotationListParsenode::accept(zorba::parsenode_visitor&) const (parsenodes.cpp:903)
==20325== by 0x55B18A8: zorba::TranslatorImpl::preprocessVFOList(zorba::VFO_DeclList const&) (translator.cpp:3904)
==20325== by 0x55A9951: zorba::TranslatorImpl::begin_visit(zorba::Prolog const&) (translator.cpp:2889)
==20325== by 0x5562201: zorba::Prolog::accept(zorba::parsenode_visitor&) const (parsenodes.cpp:262)
==20325== by 0x5561E7A: zorba::LibraryModule::accept(zorba::parsenode_visitor&) const (parsenodes.cpp:174)
==20325== by 0x559CCD8: zorba::translate_aux(zorba::TranslatorImpl*, zorba::parsenode const&, zorba::static_context*, unsigned long, zorba::ModulesInfo*, std::map<zorba::rstring<zorba::rstring_classes::rep<zorba::atomic_int, std::char_traits<char>, std::allocator<char> > >, zorba::rstring<zorba::rstring_classes::rep<zorba::atomic_int, std::char_traits<char>, std::allocator<char> > >, std::less<zorba::rstring<zorba::rstring_classes::rep<zorba::atomic_int, std::char_traits<char>, std::allocator<char> > > >, std::allocator<std::pair<zorba::rstring<zorba::rstring_classes::rep<zorba::atomic_int, std::char_traits<char>, std::allocator<char> > > const, zorba::rstring<zorba::rstring_classes::rep<zorba::atomic_int, std::char_traits<char>, std::allocator<char> > > > > > const&, bool, zorba::StaticContextConsts::xquery_version_t) (translator.cpp:16343)
==20325== by 0x55AF5C4: zorba::TranslatorImpl::end_visit(zorba::ModuleImport const&, void*) (translator.cpp:3589)
==20325== by 0x55635D3: zorba::ModuleImport::accept(zorba::parsenode_visitor&) const (parsenodes.cpp:667)
==20325== by 0x55A99BB: zorba::TranslatorImpl::begin_visit(zorba::Prolog const&) (translator.cpp:2899)

- In the following query, no dataguide seems to be pushed into the parser. Why?

import module namespace f = "http://expath.org/ns/file";

for $obj in parse-json(f:read-text(fn:resolve-uri("citylots-small.json")))
group by $s := $obj.STREET
return {
  street : $s,
  count : count($obj)
}

review: Needs Fixing
lp:~zorba-coders/zorba/use-dataguide updated
11493. By Nicolae Brinza

Fixed a memory leak.

Revision history for this message
Nicolae Brinza (nbrinza) wrote :

> I have tried some basic queries and there is a huge performance improvement.
> This is great.
> However, I detected a memory leak and have one question.
>
> - memory leak in translator.cpp:4823

I've fixed it.

>
> - In the following query, no dataguide seems to be pushed into the parser.
> Why?

The count() function is marked with the %explores-json annotation, because pruning objects that reach the function will modify the returned result. That is why the dataguide is empty.

--

Revision history for this message
Matthias Brantner (matthias-brantner) wrote :

> > - In the following query, no dataguide seems to be pushed into the parser.
> > Why?
>
> The count() function is marked with the %explores-json annotation, because
> pruning objects that reach the function will modify the returned result. That
> is why the dataguide is empty.
I don't understand why. In my example it wouldn't. The count functions could count
the number of empty objects or objects that contain only the STREET field.

review: Needs Information
Revision history for this message
Paul J. Lucas (paul-lucas) wrote :

I have no idea what problem this MP is supposed to solve; nor do I know what a "data guide" is.

review: Needs Information
Revision history for this message
Nicolae Brinza (nbrinza) wrote :

> I don't understand why. In my example it wouldn't. The count functions could
> count
> the number of empty objects or objects that contain only the STREET field.

I've looked into the test and here are the issues:
1) The fn:count() does not have the %explores-json annotation. I've confused it with the JSONiq array size() function.

2) Currently the dataguide does not distinguish between any of the fn: functions. So for example if you modify the query:

    for $obj in parse-json(f:read-text(fn:resolve-uri("citylots-small.json")))
    group by $s := $obj.STREET
    return {
      street : $s,
      count : count($obj),
      seq : subsequence($obj, 1, 100)
    }

then if you prune the input to have only the .STREET field you'll get an incorrect result. So currently the argument to subsequence() is "explored" and so the dataguide is "*" in this case. The same happens with count().

3) fn:count() is a special case as it only cares for the number of objects and not their contents. I think another annotation could be added, which would be the opposite of %explores-json and which would indicate that the function ignores the details of the object. Or I could just add some code in the dataguide collection to handle fn:count() separately.

--

lp:~zorba-coders/zorba/use-dataguide updated
11494. By Nicolae Brinza

Added special handler for fn:count() in the dataguide calculation. Added a test which covers it.

Revision history for this message
Nicolae Brinza (nbrinza) wrote :

Ok, it wasn't too much work -- I've added a special handler for fn:count() in the dataguide code and now the example you gave prunes all the fields except "price".

--

Revision history for this message
Nicolae Brinza (nbrinza) wrote :

I meant the "STREET" field. I've used "price" in the testcase.

Revision history for this message
Nicolae Brinza (nbrinza) wrote :

> I have no idea what problem this MP is supposed to solve; nor do I know what a
> "data guide" is.

Paul, I've made some changes to the JSON loader so that it skips creating nodes that are not in a given "template" (== dataguide). Since you've written the loader, could you please review only the changes to it and let me know if you find any problems, issues or anything else?

--

Revision history for this message
Matthias Brantner (matthias-brantner) wrote :

> > I don't understand why. In my example it wouldn't. The count functions could
> > count
> > the number of empty objects or objects that contain only the STREET field.
>
> I've looked into the test and here are the issues:
> 1) The fn:count() does not have the %explores-json annotation. I've confused
> it with the JSONiq array size() function.
>
> 2) Currently the dataguide does not distinguish between any of the fn:
> functions. So for example if you modify the query:
>
> for $obj in parse-json(f:read-text(fn:resolve-uri("citylots-small.json")))
> group by $s := $obj.STREET
> return {
> street : $s,
> count : count($obj),
> seq : subsequence($obj, 1, 100)
> }
>
> then if you prune the input to have only the .STREET field you'll get an
> incorrect result. So currently the argument to subsequence() is "explored" and
> so the dataguide is "*" in this case. The same happens with count().
>
> 3) fn:count() is a special case as it only cares for the number of objects and
> not their contents. I think another annotation could be added, which would be
> the opposite of %explores-json and which would indicate that the function
> ignores the details of the object. Or I could just add some code in the
> dataguide collection to handle fn:count() separately.
The way I see this is not a problem with the fn functions. The problem is related to the fact how the objects are used. In this case, the objects are used to construct a new object. The dataguide needs to handle that. Similar to serialization, this means that the entire object is needed.

review: Needs Information
Revision history for this message
Nicolae Brinza (nbrinza) wrote :

> The way I see this is not a problem with the fn functions. The problem is
> related to the fact how the objects are used. In this case, the objects are
> used to construct a new object. The dataguide needs to handle that. Similar to
> serialization, this means that the entire object is needed.

Yes, this is being handled and the usage of objects is being tracked. The process() function in the dataguide computation has a parameter for that -- propagates_to_output. You've actually seen it in action -- it is pessimistic and assumes all fn: functions propagate their input to the output. That is why the parameter to count() was assumed to be used and you've seen no pruning.

I've now made fn:count() a special case and it's input is no longer considered used for output and its parameter is allowed to be pruned. All the other functions are handled as if they propagate their input and skipping is allowed only where it's indeed possible.

--

Revision history for this message
Matthias Brantner (matthias-brantner) wrote :

I approve the changes now. I think that this still needs a little work if we start pushing-down the dataguide into collections.

review: Approve
Revision history for this message
Paul J. Lucas (paul-lucas) wrote :

Please match the rest of the code style, e.g.:

s/NULL/nullptr/
s/dataguide/dataguide_/

review: Needs Fixing
Revision history for this message
Markos Zaharioudakis (markos-za) wrote :

1. The following query constructs the wrong dataguide (and returns the wrong result):

jsoniq version "1.0";

declare variable $doc1 :=
"
  {
    \"foo\" : { \"name\" : \"moto\", \"price\" : 100 },
    \"boo\" : { \"name\" : \"car\", \"price\" : 1000 }
  }
";

let $v := exactly-one(jn:parse-json($doc1))
return
  if ($v.foo.name eq "moto")
  then
   $v
  else
   ()

2. The following query does not construct any dataguide at all, although it should:

jsoniq version "1.0";

import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";
import module namespace dml = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml";

declare variable $test external := 1;

ddl:create(xs:QName("sales"));
dml:insert-last(xs:QName("sales"),
  ( { "product" : { "name" : "broiler",
                     "price" : 100
                   },
      "category1" : { "category3" :
                       { "category4" : "value4" }
                   }
    }
  )
);

(
exactly-one
(
if ($test)
then
 dml:collection(xs:QName("sales"))[1]
else
 dml:collection(xs:QName("sales"))[2]
)
).category1

3. Window variables are not taken into account in getClauseVar

4. The implementation of the JsonDataguide rule does too much copying and allocations of dataguides. I have the feeling that this is not necessary. For example, what about the following approach?
- There is only one dataguide_cb allocated per JsonDataguide application. It contains one entry for each json "source" encountered during the application of the rule.
- There is also a single map from expr* to std::vector<expr*>. The map contains one entry for each expr that may receive return json items coming from a json "source". The value of the entry is the set of "sources" for the key expr.
I may be missing something, but if this works, it will eliminate all allocations and copies.

review: Needs Fixing
Revision history for this message
Markos Zaharioudakis (markos-za) wrote :

1. The following query constructs the wrong dataguide (and returns the wrong result):

jsoniq version "1.0";

declare variable $doc1 :=
"
  {
    \"foo\" : { \"name\" : \"moto\", \"price\" : 100 },
    \"boo\" : { \"name\" : \"car\", \"price\" : 1000 }
  }
";

let $v := exactly-one(jn:parse-json($doc1))
return
  if ($v.foo.name eq "moto")
  then
   $v
  else
   ()

2. The following query does not construct any dataguide at all, although it should:

jsoniq version "1.0";

import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";
import module namespace dml = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml";

declare variable $test external := 1;

ddl:create(xs:QName("sales"));
dml:insert-last(xs:QName("sales"),
  ( { "product" : { "name" : "broiler",
                     "price" : 100
                   },
      "category1" : { "category3" :
                       { "category4" : "value4" }
                   }
    }
  )
);

(
exactly-one
(
if ($test)
then
 dml:collection(xs:QName("sales"))[1]
else
 dml:collection(xs:QName("sales"))[2]
)
).category1

3. Window variables are not taken into account in getClauseVar

4. The implementation of the JsonDataguide rule does too much copying and allocations of dataguides. I have the feeling that this is not necessary. For example, what about the following approach?
- There is only one dataguide_cb allocated per JsonDataguide application. It contains one entry for each json "source" encountered during the application of the rule.
- There is also a single map from expr* to std::vector<expr*>. The map contains one entry for each expr that may receive return json items coming from a json "source". The value of the entry is the set of "sources" for the key expr.
I may be missing something, but if this works, it will eliminate all allocations and copies.

review: Needs Fixing
lp:~zorba-coders/zorba/use-dataguide updated
11495. By Nicolae Brinza

Merged with Zorba trunk

11496. By Nicolae Brinza

Dataguide work in progress.

11497. By Nicolae Brinza

Dataguide computations now support window clauses.

11498. By Nicolae Brinza

Fixed a problem with dataguides and plan serialization

11499. By Nicolae Brinza

Merged with Zorba trunk

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

Validation queue starting for the following merge proposals:
https://code.launchpad.net/~zorba-coders/zorba/use-dataguide/+merge/176385

Progress dashboard at http://jenkins.lambda.nu/view/ValidationQueue

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

Validation queue result for https://code.launchpad.net/~zorba-coders/zorba/use-dataguide/+merge/176385

Stage "TestZorbaUbuntu" failed.
27 tests failed (8441 total tests run).

Check test results at http://jenkins.lambda.nu/job/TestZorbaUbuntu/231/testReport/ to view the results.

lp:~zorba-coders/zorba/use-dataguide updated
11500. By Nicolae Brinza

Fixed regressions

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

Validation queue starting for the following merge proposals:
https://code.launchpad.net/~zorba-coders/zorba/use-dataguide/+merge/176385

Progress dashboard at http://jenkins.lambda.nu/view/ValidationQueue

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

Voting criteria failed for the following merge proposals:

https://code.launchpad.net/~zorba-coders/zorba/use-dataguide/+merge/176385 :
Votes: {'Approve': 2, 'Needs Fixing': 3}

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

Validation queue result for https://code.launchpad.net/~zorba-coders/zorba/use-dataguide/+merge/176385

Stage "CommitZorba" failed.

Check console output at http://jenkins.lambda.nu/job/CommitZorba/134/console to view the results.

Revision history for this message
Nicolae Brinza (nbrinza) wrote :

I have fixed issues 1 through 3.

Regarding point 4: your approach, if I understood it correctly, will only build the dataflow information, but not the dataguide itself. To compute it, it would require an additional pass through the expression tree and an additional data structure.

Regarding the copying in the current code -- first of all, the expr class has a dataguide_cb_t which is only an rchandle, so most of copying you see is just copying of pointers. In cases where data from json "sources" cannot reach expressions, just NULL pointers are propagated.

The operation that is costly in the current code is the cloning of dataguides, which is done in a clone-on-modify fashion. That portion could be improved through saving only incremental information instead of cloning and modifying an entire dataguide.

--

lp:~zorba-coders/zorba/use-dataguide updated
11501. By Nicolae Brinza

Addressed Paul's comments: s/NULL/nullptr/; s/dataguide/dataguide_/; etc.

Revision history for this message
Nicolae Brinza (nbrinza) wrote :

Paul, I've also addressed your comments on the merge proposal.

--

Revision history for this message
Paul J. Lucas (paul-lucas) :
review: Approve
Revision history for this message
Markos Zaharioudakis (markos-za) wrote :

1. The following query returns the wrong result:

jsoniq version "1.0";

declare variable $doc1 :=
"
  {
    \"foo\" : { \"name\" : \"moto\", \"price\" : 100 },
    \"boo\" : { \"name\" : \"car\", \"price\" : 1000 }
  }
";

(
let $v := exactly-one(jn:parse-json($doc1))
return
  if ($v.foo.name eq "moto")
  then
   $v
  else
   ()
).boo

2. You have now lost the dataguide that used to be produced in test dataguide-28.jq

lp:~zorba-coders/zorba/use-dataguide updated
11502. By Nicolae Brinza

Dataguide work in progress.

11503. By Nicolae Brinza

Dataguide work in progress.

11504. By Nicolae Brinza

Dataguide work in progress.

11505. By Nicolae Brinza

Fixes.

11506. By Nicolae Brinza

Merged with trunk

Unmerged revisions

11506. By Nicolae Brinza

Merged with trunk

11505. By Nicolae Brinza

Fixes.

11504. By Nicolae Brinza

Dataguide work in progress.

11503. By Nicolae Brinza

Dataguide work in progress.

11502. By Nicolae Brinza

Dataguide work in progress.

11501. By Nicolae Brinza

Addressed Paul's comments: s/NULL/nullptr/; s/dataguide/dataguide_/; etc.

11500. By Nicolae Brinza

Fixed regressions

11499. By Nicolae Brinza

Merged with Zorba trunk

11498. By Nicolae Brinza

Fixed a problem with dataguides and plan serialization

11497. By Nicolae Brinza

Dataguide computations now support window clauses.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/annotations/annotations.cpp'
2--- src/annotations/annotations.cpp 2013-07-25 14:10:17 +0000
3+++ src/annotations/annotations.cpp 2013-09-11 19:02:46 +0000
4@@ -133,6 +133,8 @@
5 ZANN(read-only-nodes, read_only_nodes);
6 ZANN(mutable-nodes, mutable_nodes);
7
8+ ZANN(explores-json, explores_json);
9+
10 #undef ZANN
11
12 // create a set of rules to detect conflicts between annotations
13@@ -401,6 +403,13 @@
14 }
15
16
17+void AnnotationList::push_back(
18+ AnnotationInternal::AnnotationId id)
19+{
20+ theAnnotationList.push_back(new AnnotationInternal(AnnotationInternal::lookup(id)));
21+}
22+
23+
24 /*******************************************************************************
25 Called from translator to detect duplicates and conflicting declarations
26 ********************************************************************************/
27
28=== modified file 'src/annotations/annotations.h'
29--- src/annotations/annotations.h 2013-07-06 06:59:32 +0000
30+++ src/annotations/annotations.h 2013-09-11 19:02:46 +0000
31@@ -86,7 +86,8 @@
32 zann_ordered,
33 zann_unordered,
34 zann_read_only_nodes,
35- zann_mutable_nodes,
36+ zann_mutable_nodes,
37+ zann_explores_json,
38
39 // must be at the end
40 zann_end
41@@ -188,6 +189,8 @@
42 void push_back(
43 const store::Item_t& qname,
44 const std::vector<const_expr*>& literals);
45+
46+ void push_back(AnnotationInternal::AnnotationId id);
47
48 void checkConflictingDeclarations(DeclarationKind k, const QueryLoc& loc) const;
49 };
50
51=== modified file 'src/common/shared_types.h'
52--- src/common/shared_types.h 2013-07-06 06:59:32 +0000
53+++ src/common/shared_types.h 2013-09-11 19:02:46 +0000
54@@ -106,6 +106,9 @@
55
56 typedef rchandle<CompilerCB> CompilerCB_t;
57
58+// JSON dataguide
59+class dataguide_cb;
60+typedef rchandle<dataguide_cb> dataguide_cb_t;
61
62 /* datetime stuff */
63 class DateTime;
64
65=== modified file 'src/compiler/codegen/plan_visitor.cpp'
66--- src/compiler/codegen/plan_visitor.cpp 2013-08-30 14:50:21 +0000
67+++ src/compiler/codegen/plan_visitor.cpp 2013-09-11 19:02:46 +0000
68@@ -49,6 +49,8 @@
69 #include "compiler/expression/function_item_expr.h"
70 #include "compiler/expression/path_expr.h"
71 #include "compiler/expression/var_expr.h"
72+#include "compiler/expression/json_dataguide.h"
73+
74 #include "compiler/parser/parse_constants.h"
75
76 #include "context/namespace_context.h"
77@@ -98,6 +100,9 @@
78 #include "runtime/hof/dynamic_fncall_iterator.h"
79 #include "runtime/misc/materialize.h"
80
81+#include "runtime/collections/collections.h"
82+#include "runtime/json/jsoniq_functions.h"
83+
84 #ifdef ZORBA_WITH_DEBUGGER
85 #include "debugger/debugger_commons.h"
86 #endif
87@@ -2460,7 +2465,7 @@
88 if (is_enclosed_expr(&v))
89 theConstructorsStack.push(&v);
90
91- return true;
92+ return true;
93 }
94
95
96@@ -2518,6 +2523,16 @@
97 user_function* udf = static_cast<user_function*>(func);
98 udf->computeResultCaching(theCCB->theXQueryDiagnostics);
99 }
100+ else if (dataguide_cb::func_uses_dataguide(func->getKind()) && v.get_dataguide() != NULL)
101+ {
102+ ZorbaCollectionIterator* collIter;
103+ if ((collIter = dynamic_cast<ZorbaCollectionIterator*>(iter.getp())))
104+ collIter->setDataguide(v.get_dataguide()->get_as_json(&v));
105+
106+ JSONParseIterator* parseIter;
107+ if ((parseIter = dynamic_cast<JSONParseIterator*>(iter.getp())))
108+ parseIter->setDataguide(v.get_dataguide()->get_as_json(&v));
109+ }
110 }
111 else
112 {
113
114=== modified file 'src/compiler/expression/CMakeLists.txt'
115--- src/compiler/expression/CMakeLists.txt 2013-02-07 17:24:36 +0000
116+++ src/compiler/expression/CMakeLists.txt 2013-09-11 19:02:46 +0000
117@@ -30,7 +30,8 @@
118 function_item_expr.cpp
119 pragma.cpp
120 mem_manager.cpp
121- expr_manager.cpp)
122+ expr_manager.cpp
123+ json_dataguide.cpp)
124
125 IF (NOT ZORBA_NO_FULL_TEXT)
126 LIST(APPEND EXPRESSION_SRCS
127
128=== modified file 'src/compiler/expression/expr_base.cpp'
129--- src/compiler/expression/expr_base.cpp 2013-05-29 04:17:01 +0000
130+++ src/compiler/expression/expr_base.cpp 2013-09-11 19:02:46 +0000
131@@ -26,6 +26,8 @@
132 #include "compiler/expression/expr_visitor.h"
133 #include "compiler/expression/expr_manager.h"
134
135+#include "compiler/expression/json_dataguide.h"
136+
137 #include "compiler/api/compilercb.h"
138
139 #include "functions/function.h"
140@@ -1418,6 +1420,29 @@
141 }
142
143
144+/*******************************************************************************
145+
146+********************************************************************************/
147+dataguide_cb* expr::get_dataguide()
148+{
149+ return theJsonDataguide;
150+}
151+
152+
153+dataguide_cb* expr::get_dataguide_or_new()
154+{
155+ if (!theJsonDataguide.getp())
156+ theJsonDataguide = new dataguide_cb();
157+ return theJsonDataguide;
158+}
159+
160+
161+dataguide_cb* expr::set_dataguide(dataguide_cb* a_json_dataguide)
162+{
163+ theJsonDataguide = a_json_dataguide;
164+ return theJsonDataguide;
165+}
166+
167
168 /*******************************************************************************
169
170@@ -1440,6 +1465,90 @@
171 return cloneExpr->get_return_type();
172 }
173
174+/*******************************************************************************
175+
176+********************************************************************************/
177+std::string expr::get_expr_kind_string() const
178+{
179+ const char* result;
180+
181+ switch (get_expr_kind())
182+ {
183+ case const_expr_kind: result = "const_expr"; break;
184+
185+ case var_expr_kind: result = "var_expr"; break;
186+
187+ case doc_expr_kind: result = "doc_expr"; break;
188+ case elem_expr_kind: result = "elem_expr"; break;
189+ case attr_expr_kind: result = "attr_expr"; break;
190+ case namespace_expr_kind: result = "namespace_expr"; break;
191+ case text_expr_kind: result = "text_expr"; break;
192+ case pi_expr_kind: result = "pi_expr"; break;
193+
194+ case relpath_expr_kind: result = "relpath_expr"; break;
195+ case axis_step_expr_kind: result = "axis_step_expr"; break;
196+ case match_expr_kind: result = "match_expr"; break;
197+
198+ case flwor_expr_kind: result = "flwor_expr"; break;
199+ case if_expr_kind: result = "if_expr"; break;
200+ case trycatch_expr_kind: result = "trycatch_expr"; break;
201+
202+ case fo_expr_kind: result = "fo_expr"; break;
203+ case dynamic_function_invocation_expr_kind: result = "dynamic_function_invocation_expr"; break;
204+ case argument_placeholder_expr_kind: result = "argument_placeholder_expr"; break;
205+ case function_item_expr_kind: result = "function_item_expr"; break;
206+
207+ case castable_expr_kind: result = "castable_expr"; break;
208+ case cast_expr_kind: result = "cast_expr"; break;
209+ case instanceof_expr_kind: result = "instanceof_expr"; break;
210+ case treat_expr_kind: result = "treat_expr"; break;
211+ case promote_expr_kind: result = "promote_expr"; break;
212+ case name_cast_expr_kind: result = "name_cast_expr"; break;
213+
214+ case validate_expr_kind: result = "validate_expr"; break;
215+
216+ case extension_expr_kind: result = "extension_expr"; break;
217+
218+ case order_expr_kind: result = "order_expr"; break;
219+
220+#ifndef ZORBA_NO_FULL_TEXT
221+ case ft_expr_kind: result = "ft_expr"; break;
222+#endif /* ZORBA_NO_FULL_TEXT */
223+
224+ case delete_expr_kind: result = "delete_expr"; break;
225+ case insert_expr_kind: result = "insert_expr"; break;
226+ case rename_expr_kind: result = "rename_expr"; break;
227+ case replace_expr_kind: result = "replace_expr"; break;
228+ case transform_expr_kind: result = "transform_expr"; break;
229+
230+ case block_expr_kind: result = "block_expr"; break;
231+ case var_decl_expr_kind: result = "var_decl_expr"; break;
232+ case var_set_expr_kind: result = "var_set_expr"; break;
233+ case apply_expr_kind: result = "apply_expr"; break;
234+ case exit_expr_kind: result = "exit_expr"; break;
235+ case exit_catcher_expr_kind: result = "exit_catcher_expr"; break;
236+ case flowctl_expr_kind: result = "flowctl_expr"; break;
237+ case while_expr_kind: result = "while_expr"; break;
238+
239+ case eval_expr_kind: result = "eval_expr"; break;
240+ case debugger_expr_kind: result = "debugger_expr"; break;
241+ case wrapper_expr_kind: result = "wrapper_expr"; break;
242+ case function_trace_expr_kind: result = "function_trace_expr"; break;
243+
244+ case json_direct_object_expr_kind: result = "json_direct_object_expr"; break;
245+ case json_object_expr_kind: result = "json_object_expr"; break;
246+ case json_array_expr_kind: result = "json_array_expr"; break;
247+
248+ case unknown_expr_kind: result = "unknown_expr"; break;
249+
250+ default:
251+ result = "expr kind not in list. Add it to expr_base::get_expr_kind_string()";
252+ break;
253+ }
254+
255+ return std::string(result);
256+}
257+
258
259 } // namespace zorba
260 /* vim:set et sw=2 ts=2: */
261
262=== modified file 'src/compiler/expression/expr_base.h'
263--- src/compiler/expression/expr_base.h 2013-05-29 04:17:01 +0000
264+++ src/compiler/expression/expr_base.h 2013-09-11 19:02:46 +0000
265@@ -45,6 +45,7 @@
266
267 class CompilerCB;
268
269+
270 enum expr_kind_t
271 {
272 const_expr_kind,
273@@ -198,6 +199,8 @@
274 uint8_t theVisitId;
275
276 FreeVars theFreeVars;
277+
278+ dataguide_cb_t theJsonDataguide;
279
280 public:
281 static bool is_sequential(unsigned short theScriptingKind);
282@@ -223,6 +226,8 @@
283 user_function* get_udf() const { return theUDF; }
284
285 expr_kind_t get_expr_kind() const { return static_cast<expr_kind_t>(theKind); }
286+
287+ std::string get_expr_kind_string() const;
288
289 const QueryLoc& get_loc() const { return theLoc; }
290
291@@ -404,6 +409,13 @@
292 void clear_annotations();
293
294 xqtref_t get_return_type_with_empty_input(const expr* input) const;
295+
296+ dataguide_cb* get_dataguide();
297+
298+ // If the object's dataguide is NULL, will create a new one and return it
299+ dataguide_cb* get_dataguide_or_new();
300+
301+ dataguide_cb* set_dataguide(dataguide_cb* a_json_dataguide);
302
303 protected:
304 virtual void compute_scripting_kind() = 0;
305
306=== modified file 'src/compiler/expression/expr_clone.cpp'
307--- src/compiler/expression/expr_clone.cpp 2013-07-02 21:32:23 +0000
308+++ src/compiler/expression/expr_clone.cpp 2013-09-11 19:02:46 +0000
309@@ -27,6 +27,7 @@
310 #include "compiler/expression/ft_expr.h"
311 #include "compiler/expression/ftnode.h"
312 #include "compiler/expression/expr_manager.h"
313+#include "compiler/expression/json_dataguide.h"
314
315 #include "compiler/api/compilercb.h"
316
317@@ -337,6 +338,8 @@
318 cloneExpr->theArgs.push_back(e->theArgs[i]->clone(udf, subst));
319
320 cloneExpr->theScriptingKind = e->theScriptingKind;
321+
322+ cloneExpr->theJsonDataguide = e->theJsonDataguide;
323
324 newExpr = cloneExpr;
325 break;
326
327=== modified file 'src/compiler/expression/expr_type.cpp'
328--- src/compiler/expression/expr_type.cpp 2013-08-16 13:00:06 +0000
329+++ src/compiler/expression/expr_type.cpp 2013-09-11 19:02:46 +0000
330@@ -648,6 +648,10 @@
331 const FunctionXQType* funcType = static_cast<const FunctionXQType*>(fiType.getp());
332 newType = funcType->get_return_type();
333 }
334+ else if (fiType->type_kind() == XQType::STRUCTURED_ITEM_KIND && e->get_args().size() == 1)
335+ {
336+ newType = rtm.STRUCTURED_ITEM_TYPE_STAR;
337+ }
338 else
339 {
340 newType = rtm.ITEM_TYPE_STAR;
341
342=== added file 'src/compiler/expression/json_dataguide.cpp'
343--- src/compiler/expression/json_dataguide.cpp 1970-01-01 00:00:00 +0000
344+++ src/compiler/expression/json_dataguide.cpp 2013-09-11 19:02:46 +0000
345@@ -0,0 +1,358 @@
346+/*
347+ * Copyright 2006-2013 The FLWOR Foundation.
348+ *
349+ * Licensed under the Apache License, Version 2.0 (the "License");
350+ * you may not use this file except in compliance with the License.
351+ * You may obtain a copy of the License at
352+ *
353+ * http://www.apache.org/licenses/LICENSE-2.0
354+ *
355+ * Unless required by applicable law or agreed to in writing, software
356+ * distributed under the License is distributed on an "AS IS" BASIS,
357+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
358+ * See the License for the specific language governing permissions and
359+ * limitations under the License.
360+ */
361+#include "stdafx.h"
362+
363+#include "system/globalenv.h"
364+#include "store/api/item_factory.h"
365+
366+#include "compiler/expression/expr_base.h"
367+#include "compiler/expression/json_dataguide.h"
368+
369+
370+namespace zorba
371+{
372+
373+/*******************************************************************************
374+
375+********************************************************************************/
376+void dataguide_node::add_to_leaves(store::Item* key)
377+{
378+ if ((keys.size() == 0 || is_star) && propagates_to_output) // no children == leaf
379+ {
380+ if (is_star)
381+ is_star = false;
382+
383+ keys.push_back(key);
384+ values.push_back(dataguide_node());
385+ return;
386+ }
387+
388+ for (unsigned int i=0; i != keys.size(); i++)
389+ values[i].add_to_leaves(key);
390+}
391+
392+
393+void dataguide_node::add_to_leaves(const dataguide_node* other)
394+{
395+ if ((keys.size() == 0 || is_star)) // no children == leaf
396+ {
397+ if (is_star)
398+ is_star = false;
399+
400+ clone(other);
401+ return;
402+ }
403+
404+ for (unsigned int i=0; i != keys.size(); i++)
405+ values[i].add_to_leaves(other);
406+}
407+
408+
409+void dataguide_node::set_star_on_leaves()
410+{
411+ if (is_star)
412+ return;
413+
414+ if (keys.size() == 0)
415+ {
416+ is_star = true;
417+ return;
418+ }
419+
420+ for (unsigned int i=0; i != keys.size(); i++)
421+ values[i].set_star_on_leaves();
422+}
423+
424+
425+void dataguide_node::set_propagates_on_leaves(bool propagates)
426+{
427+ if (keys.size() == 0)
428+ {
429+ is_star = propagates;
430+ propagates_to_output = propagates_to_output && propagates;
431+ return;
432+ }
433+
434+ for (unsigned int i=0; i != keys.size(); i++)
435+ values[i].set_propagates_on_leaves(propagates);
436+}
437+
438+
439+void dataguide_node::do_union(const dataguide_node* other)
440+{
441+ if (other->is_star)
442+ is_star = true;
443+
444+ for (unsigned int i=0; i<other->keys.size(); i++)
445+ {
446+ bool found = false;
447+ unsigned int j = 0;
448+ for ( ; j<keys.size(); j++)
449+ if (keys[j]->equals(other->keys[i]))
450+ {
451+ found = true;
452+ break;
453+ }
454+
455+ if (found)
456+ {
457+ values[i].do_union(&other->values[j]);
458+ }
459+ else
460+ {
461+ keys.push_back(other->keys[i]);
462+ values.push_back(dataguide_node(other->propagates_to_output));
463+ values.back().do_union(&other->values[i]);
464+ }
465+ }
466+}
467+
468+
469+void dataguide_node::clone(const dataguide_node* other)
470+{
471+ is_star = other->is_star;
472+ propagates_to_output = other->propagates_to_output;
473+
474+ for (unsigned int i=0; i<other->keys.size(); i++)
475+ {
476+ keys.push_back(other->keys[i]);
477+ values.push_back(dataguide_node(other->propagates_to_output));
478+ values.back().clone(&other->values[i]);
479+ }
480+}
481+
482+
483+dataguide_node* dataguide_node::get(store::Item* key)
484+{
485+ for (unsigned int i=0; i<keys.size(); i++)
486+ if (keys[i]->equals(key))
487+ return &values[i];
488+
489+ return NULL;
490+}
491+
492+
493+store::Item_t dataguide_node::get_as_json()
494+{
495+ std::vector<store::Item_t> vals;
496+ std::vector<store::Item_t> ks;
497+
498+ if (is_star)
499+ {
500+ store::Item_t star_string;
501+ zstring star = zstring("*");
502+ GENV_ITEMFACTORY->createString(star_string, star);
503+ ks.push_back(star_string);
504+
505+ star = "";
506+ GENV_ITEMFACTORY->createString(star_string, star);
507+ vals.push_back(star_string);
508+ }
509+ else
510+ {
511+ for (unsigned int i=0; i<values.size(); i++)
512+ {
513+ if (values[i].is_star)
514+ {
515+ store::Item_t star_string;
516+ zstring star = zstring("*");
517+ GENV_ITEMFACTORY->createString(star_string, star);
518+ vals.push_back(star_string);
519+ }
520+ else
521+ vals.push_back(values[i].get_as_json());
522+
523+ ks.push_back(keys[i]);
524+ }
525+ }
526+
527+ store::Item_t result;
528+ GENV_ITEMFACTORY->createJSONObject(result, ks, vals);
529+
530+ return result;
531+}
532+
533+
534+zstring dataguide_node::toString()
535+{
536+ return get_as_json()->show();
537+}
538+
539+
540+/*******************************************************************************
541+
542+********************************************************************************/
543+dataguide_cb::dataguide_cb()
544+{
545+}
546+
547+
548+void dataguide_cb::add_to_leaves(store::Item* object_name)
549+{
550+ // Append the given object to each leaf node
551+ map_type::iterator i = theDataguideMap.begin();
552+ for ( ; i != theDataguideMap.end(); i++)
553+ {
554+ i->second.add_to_leaves(object_name);
555+ }
556+}
557+
558+
559+void dataguide_cb::add_to_leaves(dataguide_node* other)
560+{
561+ // Append the given dataguide to each leaf node
562+ map_type::iterator i = theDataguideMap.begin();
563+ for ( ; i != theDataguideMap.end(); i++)
564+ {
565+ i->second.add_to_leaves(other);
566+ }
567+}
568+
569+
570+void dataguide_cb::set_star_on_leaves()
571+{
572+ map_type::iterator i = theDataguideMap.begin();
573+ for ( ; i != theDataguideMap.end(); i++)
574+ {
575+ i->second.set_star_on_leaves();
576+ }
577+}
578+
579+
580+void dataguide_cb::set_star_on_roots()
581+{
582+ map_type::iterator i = theDataguideMap.begin();
583+ for ( ; i != theDataguideMap.end(); i++)
584+ {
585+ i->second.is_star = true;
586+ }
587+}
588+
589+
590+void dataguide_cb::set_propagates_on_leaves(bool propagates)
591+{
592+ map_type::iterator i = theDataguideMap.begin();
593+ for ( ; i != theDataguideMap.end(); i++)
594+ {
595+ i->second.set_propagates_on_leaves(propagates);
596+ }
597+}
598+
599+
600+dataguide_node* dataguide_cb::add_source(expr* e)
601+{
602+ theDataguideMap[e] = dataguide_node();
603+ return &theDataguideMap[e];
604+}
605+
606+
607+void dataguide_cb::do_union(const dataguide_cb *other)
608+{
609+ if (this == other || other == NULL)
610+ return;
611+
612+ map_type::const_iterator it = other->theDataguideMap.begin();
613+ for (; it != other->theDataguideMap.end(); ++it)
614+ {
615+ theDataguideMap[it->first].do_union(&it->second);
616+ }
617+}
618+
619+
620+void dataguide_cb::do_union(expr* other)
621+{
622+ if (other == NULL)
623+ return;
624+
625+ do_union(other->get_dataguide());
626+}
627+
628+
629+dataguide_cb_t dataguide_cb::clone()
630+{
631+ dataguide_cb_t new_dg = new dataguide_cb();
632+
633+ map_type::iterator it = theDataguideMap.begin();
634+ for (; it != theDataguideMap.end(); ++it)
635+ {
636+ dataguide_node* new_node = new_dg->add_source(it->first);
637+ new_node->clone(&it->second);
638+ }
639+
640+ return new_dg;
641+}
642+
643+
644+dataguide_node* dataguide_cb::get_dataguide_for_source(expr* e)
645+{
646+ map_type::iterator it = theDataguideMap.find(e);
647+
648+ if (it != theDataguideMap.end())
649+ return &it->second;
650+ else
651+ return NULL;
652+}
653+
654+
655+bool dataguide_cb::is_empty(expr* e)
656+{
657+ return theDataguideMap[e].keys.size() == 0 || theDataguideMap[e].is_star;
658+}
659+
660+
661+store::Item_t dataguide_cb::get_as_json(expr* e)
662+{
663+ if (theDataguideMap[e].is_star)
664+ return NULL;
665+ else
666+ return theDataguideMap[e].get_as_json();
667+}
668+
669+
670+zstring dataguide_cb::toString()
671+{
672+ std::stringstream str;
673+ str << this;
674+ str << " {";
675+
676+ map_type::iterator it = theDataguideMap.begin();
677+ for (; it != theDataguideMap.end(); ++it)
678+ {
679+ str << " " << it->first << ": " << it->second.toString();
680+ }
681+
682+ str << "}";
683+ return str.str();
684+}
685+
686+
687+bool dataguide_cb::func_uses_dataguide(FunctionConsts::FunctionKind kind)
688+{
689+ if (kind == FunctionConsts::STATIC_COLLECTIONS_DML_COLLECTION_1 ||
690+ kind == FunctionConsts::STATIC_COLLECTIONS_DML_COLLECTION_2 ||
691+ kind == FunctionConsts::STATIC_COLLECTIONS_DML_COLLECTION_3 ||
692+ kind == FunctionConsts::DYNAMIC_COLLECTIONS_DML_COLLECTION_1 ||
693+ kind == FunctionConsts::DYNAMIC_COLLECTIONS_DML_COLLECTION_2 ||
694+ kind == FunctionConsts::DYNAMIC_COLLECTIONS_DML_COLLECTION_3 ||
695+ kind == FunctionConsts::FN_JSONIQ_PARSE_JSON_1 ||
696+ kind == FunctionConsts::FN_JSONIQ_PARSE_JSON_2)
697+ return true;
698+ else
699+ return false;
700+}
701+
702+}
703+/* vim:set et sw=2 ts=2: */
704
705=== added file 'src/compiler/expression/json_dataguide.h'
706--- src/compiler/expression/json_dataguide.h 1970-01-01 00:00:00 +0000
707+++ src/compiler/expression/json_dataguide.h 2013-09-11 19:02:46 +0000
708@@ -0,0 +1,157 @@
709+/*
710+ * Copyright 2006-2013 The FLWOR Foundation.
711+ *
712+ * Licensed under the Apache License, Version 2.0 (the "License");
713+ * you may not use this file except in compliance with the License.
714+ * You may obtain a copy of the License at
715+ *
716+ * http://www.apache.org/licenses/LICENSE-2.0
717+ *
718+ * Unless required by applicable law or agreed to in writing, software
719+ * distributed under the License is distributed on an "AS IS" BASIS,
720+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
721+ * See the License for the specific language governing permissions and
722+ * limitations under the License.
723+ */
724+#pragma once
725+#ifndef ZORBA_COMPILER_JSON_DATAGUIDE
726+#define ZORBA_COMPILER_JSON_DATAGUIDE
727+
728+#include "zorbautils/string_util.h"
729+#include "store/api/item.h"
730+#include "functions/function_consts.h"
731+
732+
733+namespace zorba
734+{
735+
736+class expr;
737+
738+
739+/******************************************************************************
740+ The node of a dataguide tree.
741+
742+ is_star:
743+ --------
744+ Set to true if all the key/value pairs of an object need to retrieved from
745+ the JSON store. This includes all child objects.
746+
747+ keys:
748+ values:
749+ -------
750+ Key=value pairs of the dataguide. If key X is contained in the keys vector,
751+ then the corresponding object must be retrieved from the store. The values
752+ is either:
753+ -- another list of key/value pairs denoting child objects that must be
754+ retreived
755+ -- star: all child objects beyond this point must be retrieved.
756+ -- empty: no projection information. All child nodes will be retrieved if
757+ the list remains empty at the end of the analysis.
758+*******************************************************************************/
759+class dataguide_node
760+{
761+public:
762+ bool is_star;
763+
764+ bool propagates_to_output;
765+
766+ std::vector<store::Item_t> keys;
767+
768+ std::vector<dataguide_node> values;
769+
770+
771+public:
772+ dataguide_node(bool propagates = true) : is_star(false), propagates_to_output(propagates) { }
773+
774+ void add_to_leaves(store::Item* key);
775+
776+ void add_to_leaves(const dataguide_node* other);
777+
778+ void set_star_on_leaves();
779+
780+ void set_propagates_on_leaves(bool propagates);
781+
782+ void do_union(const dataguide_node* other);
783+
784+ // returns the child dataguide node associated with the given key, or NULL if there is none
785+ dataguide_node* get(store::Item* key);
786+
787+ // recursively constructs "this" to be a clone of the other dataguide
788+ void clone(const dataguide_node* other);
789+
790+ store::Item_t get_as_json();
791+
792+ zstring toString();
793+};
794+
795+
796+/******************************************************************************
797+ The JSON dataguide control block
798+
799+ theDataguideMap:
800+ ----------------
801+ A mapping of expressions (keys) to dataguide trees that contain the projection
802+ information. Each key in the map is a source expression which currently
803+ include JSON database collection retrieval functions (db:collection) and
804+ JSON parse function.
805+ In a UDF, all formal parameters are added to the sources set in order to
806+ allow projection information to be "added" to the expressions that invoke
807+ the UDF.
808+*******************************************************************************/
809+class dataguide_cb : public SimpleRCObject
810+{
811+friend class JsonDataguide;
812+
813+public:
814+ typedef std::map<expr*, dataguide_node> map_type;
815+
816+protected:
817+ std::map<expr*,dataguide_node> theDataguideMap;
818+
819+
820+public:
821+ dataguide_cb();
822+
823+ dataguide_node* add_source(expr* e);
824+
825+ void add_to_leaves(store::Item* object_name);
826+
827+ void add_to_leaves(dataguide_node* other);
828+
829+ void set_star_on_leaves();
830+
831+ void set_star_on_roots();
832+
833+ // Note: the function will also modify the is_star flag.
834+ void set_propagates_on_leaves(bool propagates);
835+
836+ void do_union(const dataguide_cb* other);
837+
838+ void do_union(expr *other);
839+
840+ dataguide_cb_t clone();
841+
842+ dataguide_node* get_dataguide_for_source(expr* e);
843+
844+ bool is_empty(expr *e);
845+
846+ store::Item_t get_as_json(expr *e);
847+
848+ zstring toString();
849+
850+public:
851+
852+ static bool func_uses_dataguide(FunctionConsts::FunctionKind kind);
853+};
854+
855+
856+}
857+
858+#endif // ZORBA_COMPILER_JSON_DATAGUIDE
859+
860+/*
861+ * Local variables:
862+ * mode: c++
863+ * End:
864+ */
865+/* vim:set et sw=2 ts=2: */
866
867=== modified file 'src/compiler/expression/var_expr.cpp'
868--- src/compiler/expression/var_expr.cpp 2013-04-24 01:35:58 +0000
869+++ src/compiler/expression/var_expr.cpp 2013-09-11 19:02:46 +0000
870@@ -23,6 +23,7 @@
871 #include "compiler/expression/flwor_expr.h"
872 #include "compiler/expression/expr_visitor.h"
873 #include "compiler/api/compilercb.h"
874+#include "compiler/expression/json_dataguide.h"
875
876 #include "types/typeops.h"
877
878
879=== modified file 'src/compiler/rewriter/framework/default_optimizer.cpp'
880--- src/compiler/rewriter/framework/default_optimizer.cpp 2013-05-15 10:27:06 +0000
881+++ src/compiler/rewriter/framework/default_optimizer.cpp 2013-09-11 19:02:46 +0000
882@@ -266,7 +266,16 @@
883 driverMarkNodeCopyProps.rewrite(rCtx);
884 }
885 }
886-
887+
888+ // Compute Json Dataguide
889+ RuleOnceDriver<JsonDataguide> driverJsonDataguide;
890+ driverJsonDataguide.rewrite(rCtx);
891+
892+ if (Properties::instance()->printDataguide())
893+ {
894+ driverJsonDataguide.getRule()->printDataguides(rCtx.getRoot());
895+ }
896+
897 return modified;
898 }
899
900
901=== modified file 'src/compiler/rewriter/rules/nodeid_rules.cpp'
902--- src/compiler/rewriter/rules/nodeid_rules.cpp 2013-06-15 02:57:08 +0000
903+++ src/compiler/rewriter/rules/nodeid_rules.cpp 2013-09-11 19:02:46 +0000
904@@ -36,6 +36,8 @@
905 #include "functions/func_node_sort_distinct.h"
906 #include "functions/udf.h"
907
908+#include "compiler/expression/json_dataguide.h"
909+
910 #include "diagnostics/assert.h"
911
912
913@@ -1538,5 +1540,372 @@
914 }
915
916
917+/*******************************************************************************
918+
919+********************************************************************************/
920+expr* JsonDataguide::apply(
921+ RewriterContext& rCtx,
922+ expr* node,
923+ bool& modified)
924+{
925+ process(node, true);
926+
927+ if (node->get_dataguide() != NULL)
928+ {
929+ std::map<expr*,dataguide_node>::iterator i = node->get_dataguide()->theDataguideMap.begin();
930+ for ( ; i != node->get_dataguide()->theDataguideMap.end(); ++i)
931+ {
932+ i->first->set_dataguide(node->get_dataguide());
933+ }
934+ }
935+
936+ return NULL;
937+}
938+
939+
940+void JsonDataguide::printDataguides(expr* root)
941+{
942+ dataguide_cb* dg = root->get_dataguide();
943+ if (dg == NULL)
944+ return;
945+
946+ std::map<expr*,dataguide_node>::iterator i = dg->theDataguideMap.begin();
947+ for ( ; i != dg->theDataguideMap.end(); ++i)
948+ {
949+ if (i->first->get_expr_kind() != fo_expr_kind)
950+ continue;
951+
952+ fo_expr* fo = static_cast<fo_expr*>(i->first);
953+ store::Item_t json_dg = dg->get_as_json(fo);
954+ if (json_dg.getp())
955+ std::cout << "Dataguide for function " << fo->get_func()->getName()->getStringValue() << "() at "
956+ << fo->get_loc().getLineBegin() << ":" << fo->get_loc().getColumnBegin() << ": "
957+ << json_dg->show() << std::endl;
958+ }
959+}
960+
961+
962+// For a given expression that is bound to a clause var (for/let/groupby/window), find the var_expr (or vector
963+// of var_expr's for window clause).
964+// Returns true if the given node is the domain expression of a for/let/groupby/window clause,
965+// or false otherwise.
966+bool getClauseInfo(flwor_expr* flwor, expr* node, std::vector<var_expr*>& clause_vars, flwor_clause::ClauseKind& clause_kind, bool& groupby_grouping_spec)
967+{
968+ groupby_grouping_spec = false;
969+
970+ for (unsigned int i=0; i < flwor->num_clauses(); i++)
971+ {
972+ flwor_clause* c = flwor->get_clause(i);
973+ clause_kind = c->get_kind();
974+
975+ if (clause_kind == flwor_clause::for_clause ||
976+ clause_kind == flwor_clause::let_clause)
977+ {
978+ forlet_clause* fc = static_cast<forlet_clause*>(c);
979+ if (fc->get_expr() == node)
980+ {
981+ clause_vars.push_back(fc->get_var());
982+ return true;
983+ }
984+ }
985+ else if (clause_kind == flwor_clause::where_clause)
986+ {
987+ if (static_cast<where_clause*>(c)->get_expr() == node)
988+ {
989+ return true;
990+ }
991+ }
992+ else if (clause_kind == flwor_clause::groupby_clause)
993+ {
994+ groupby_clause* gc = static_cast<groupby_clause*>(c);
995+ flwor_clause::rebind_list_t::iterator it = gc->beginGroupVars();
996+ for ( ; it != gc->endGroupVars(); ++it)
997+ if (it->first == node)
998+ {
999+ groupby_grouping_spec = true;
1000+ clause_vars.push_back(it->second);
1001+ return true;
1002+ }
1003+
1004+ it = gc->beginNonGroupVars();
1005+ for ( ; it != gc->endNonGroupVars(); ++it)
1006+ if (it->first == node)
1007+ {
1008+ clause_vars.push_back(it->second);
1009+ return true;
1010+ }
1011+ }
1012+ else if (clause_kind == flwor_clause::window_clause)
1013+ {
1014+ window_clause* wc = static_cast<window_clause*>(c);
1015+ if (wc->get_expr() == node)
1016+ {
1017+ clause_vars.push_back(wc->get_var());
1018+ flwor_wincond* wincond = wc->get_win_start();
1019+ if (wincond)
1020+ {
1021+ const flwor_wincond::vars in_vars = wincond->get_in_vars();
1022+ clause_vars.push_back(in_vars.prev);
1023+ clause_vars.push_back(in_vars.curr);
1024+ clause_vars.push_back(in_vars.next);
1025+ const flwor_wincond::vars out_vars = wincond->get_out_vars();
1026+ clause_vars.push_back(out_vars.prev);
1027+ clause_vars.push_back(out_vars.curr);
1028+ clause_vars.push_back(out_vars.next);
1029+ }
1030+
1031+ wincond = wc->get_win_stop();
1032+ if (wincond)
1033+ {
1034+ const flwor_wincond::vars in_vars = wincond->get_in_vars();
1035+ clause_vars.push_back(in_vars.prev);
1036+ clause_vars.push_back(in_vars.curr);
1037+ clause_vars.push_back(in_vars.next);
1038+ const flwor_wincond::vars out_vars = wincond->get_out_vars();
1039+ clause_vars.push_back(out_vars.prev);
1040+ clause_vars.push_back(out_vars.curr);
1041+ clause_vars.push_back(out_vars.next);
1042+ }
1043+
1044+ return true;
1045+ }
1046+ }
1047+ }
1048+
1049+ return false;
1050+}
1051+
1052+
1053+// Propagates the dataguide from the child to the parent
1054+void propagate_dg(expr* child, expr* node)
1055+{
1056+ if (child->get_dataguide() == NULL)
1057+ return;
1058+
1059+ if (node->get_dataguide())
1060+ {
1061+ if (node->get_dataguide()->getRefCount() > 1)
1062+ node->set_dataguide(node->get_dataguide()->clone());
1063+ node->get_dataguide()->do_union(child);
1064+ }
1065+ else
1066+ {
1067+ node->set_dataguide(child->get_dataguide());
1068+ }
1069+}
1070+
1071+
1072+void JsonDataguide::iterateChildren(expr* node)
1073+{
1074+ fo_expr* fo = NULL;
1075+ flwor_expr* flwor = NULL;
1076+
1077+ if (node->get_expr_kind() == flwor_expr_kind)
1078+ flwor = static_cast<flwor_expr*>(node);
1079+ else if (node->get_expr_kind() == fo_expr_kind)
1080+ fo = static_cast<fo_expr*>(node);
1081+ else if (node->get_expr_kind() == function_trace_expr_kind)
1082+ static_cast<function_trace_expr*>(node)->get_input()->set_dataguide(NULL);
1083+
1084+ // If we're in a UDF root expr, add all parameter variables to the sources set
1085+ if (node->get_udf() != NULL && node->get_udf()->getBody() == node && ! node->get_udf()->isRecursive())
1086+ {
1087+ for (unsigned int i=0; i<node->get_udf()->numArgs(); i++)
1088+ {
1089+ var_expr* v = node->get_udf()->getArgVar(i);
1090+ v->get_dataguide_or_new()->add_source(v);
1091+ }
1092+ }
1093+
1094+ ExprIterator iter(node);
1095+ while (!iter.done())
1096+ {
1097+ expr* child = (**iter);
1098+ if (child == NULL)
1099+ continue;
1100+
1101+ // Is true if the items produced by the current child will be passed on by the node to the parent.
1102+ bool child_items_propagate = true;
1103+
1104+ bool child_dataguide_propagates = true;
1105+
1106+ std::vector<var_expr*> clause_vars;
1107+ flwor_clause::ClauseKind clause_kind;
1108+ bool groupby_grouping_spec;
1109+ bool have_clause = false;
1110+
1111+ if (flwor)
1112+ {
1113+ have_clause = getClauseInfo(flwor, child, clause_vars, clause_kind, groupby_grouping_spec);
1114+ }
1115+
1116+ if (child->get_expr_kind() == var_decl_expr_kind ||
1117+ (node->get_expr_kind() == if_expr_kind && static_cast<if_expr*>(node)->get_cond_expr() == child) ||
1118+ (fo && fo->get_func()->getKind() == FunctionConsts::FN_COUNT_1) ||
1119+ (fo && fo->get_func()->isUdf() && !static_cast<user_function*>(fo->get_func())->isRecursive()) ||
1120+ (have_clause && clause_kind == flwor_clause::where_clause)
1121+ )
1122+ {
1123+ child_items_propagate = false;
1124+ }
1125+
1126+ if (have_clause && ! ((clause_kind == flwor_clause::groupby_clause && groupby_grouping_spec) ||
1127+ clause_kind == flwor_clause::where_clause))
1128+ {
1129+ child_dataguide_propagates = false;
1130+ }
1131+
1132+ process(child, child_items_propagate);
1133+
1134+ if (have_clause)
1135+ {
1136+ for (unsigned int i=0; i<clause_vars.size(); i++)
1137+ if (clause_vars[i] != NULL)
1138+ clause_vars[i]->set_dataguide(child->get_dataguide());
1139+ }
1140+
1141+ if (child_dataguide_propagates)
1142+ {
1143+ propagate_dg(child, node);
1144+ }
1145+
1146+ iter.next();
1147+ } // while
1148+
1149+ // std::cerr << "--> " << node << " = " << node->get_expr_kind_string() << " dataguide: " << (node->get_dataguide() ? node->get_dataguide()->toString() : "") << std::endl;
1150+}
1151+
1152+
1153+void JsonDataguide::process(expr* node, bool child_items_propagate)
1154+{
1155+ iterateChildren(node);
1156+
1157+ switch (node->get_expr_kind())
1158+ {
1159+ case dynamic_function_invocation_expr_kind:
1160+ {
1161+ dynamic_function_invocation_expr* fo = static_cast<dynamic_function_invocation_expr*>(node);
1162+ expr* sourceExpr = fo->get_input();
1163+ TypeManager* tm = sourceExpr->get_type_manager();
1164+ xqtref_t sourceType = sourceExpr->get_return_type();
1165+
1166+ if ((TypeOps::is_subtype(tm, *sourceType, *GENV_TYPESYSTEM.JSON_ITEM_TYPE_STAR)
1167+ || TypeOps::is_subtype(tm, *sourceType, *GENV_TYPESYSTEM.STRUCTURED_ITEM_TYPE_STAR))
1168+ && fo->get_args().size() == 1
1169+ && fo->get_args()[0]->get_expr_kind() == const_expr_kind)
1170+ {
1171+ dataguide_cb_t dg = fo->get_dataguide() ? fo->get_dataguide()->clone().getp() : new dataguide_cb();
1172+ dg->add_to_leaves(static_cast<const_expr*>(fo->get_args()[0])->get_val());
1173+ fo->set_dataguide(dg);
1174+ }
1175+
1176+ break;
1177+ }
1178+ case fo_expr_kind :
1179+ {
1180+ fo_expr* fo = static_cast<fo_expr*>(node);
1181+ function* f = fo->get_func();
1182+
1183+ if (fo->get_dataguide() &&
1184+ (f->getKind() == FunctionConsts::OP_ZORBA_SINGLE_OBJECT_LOOKUP_2 ||
1185+ f->getKind() == FunctionConsts::OP_ZORBA_MULTI_OBJECT_LOOKUP_2))
1186+ {
1187+ if (fo->get_arg(1)->get_expr_kind() == const_expr_kind)
1188+ {
1189+ if (node->get_dataguide()->getRefCount() > 1)
1190+ node->set_dataguide(node->get_dataguide()->clone());
1191+
1192+ fo->get_dataguide()->add_to_leaves(static_cast<const_expr*>(fo->get_arg(1))->get_val());
1193+ }
1194+ else
1195+ {
1196+ fo->get_dataguide()->set_star_on_leaves();
1197+ }
1198+ }
1199+ else if (f->getKind() == FunctionConsts::FN_COUNT_1)
1200+ {
1201+ // Special handling for fn:count(): skip setting star even if it propagates to output
1202+ return;
1203+ }
1204+ else if (dataguide_cb::func_uses_dataguide(f->getKind()))
1205+ {
1206+ fo->get_dataguide_or_new()->add_source(fo);
1207+ }
1208+ else if (f->isExternal()
1209+ ||
1210+ (f->getAnnotationList()
1211+ &&
1212+ f->getAnnotationList()->contains(AnnotationInternal::zann_explores_json)))
1213+ {
1214+ if (fo->get_dataguide())
1215+ fo->get_dataguide()->set_star_on_leaves();
1216+ }
1217+ else if (f->isUdf())
1218+ {
1219+ user_function* udf = static_cast<user_function*>(f);
1220+
1221+ // The body of a UDF will be NULL when compiling an eval expression and
1222+ // plan serialization has been employed. Assume the function might be recursive in this case.
1223+ if (udf->getBody() == NULL || udf->isRecursive())
1224+ {
1225+ if (fo->get_dataguide())
1226+ fo->get_dataguide()->set_star_on_leaves();
1227+ }
1228+ else
1229+ {
1230+ // Iterate through the effective parameters and prepend to them the function's formal parameter's dataguide
1231+ for (unsigned int i=0; i<udf->numArgs(); i++)
1232+ {
1233+ dataguide_cb_t new_dg;
1234+ dataguide_node* var_dg = NULL;
1235+
1236+ if (udf->getBody()->get_dataguide())
1237+ var_dg = udf->getBody()->get_dataguide()->get_dataguide_for_source(udf->getArgVar(i));
1238+
1239+ if (var_dg)
1240+ {
1241+ new_dg = fo->get_arg(i)->get_dataguide_or_new();
1242+ new_dg->add_to_leaves(var_dg);
1243+ }
1244+
1245+ if (fo->get_dataguide())
1246+ fo->get_dataguide()->do_union(new_dg);
1247+ else
1248+ fo->set_dataguide(new_dg);
1249+ } // for
1250+ }
1251+ }
1252+
1253+ break;
1254+ }
1255+ case var_decl_expr_kind:
1256+ {
1257+ var_decl_expr* vd = static_cast<var_decl_expr*>(node);
1258+ if (vd->get_expr() && vd->get_var_expr())
1259+ vd->get_var_expr()->set_dataguide(vd->get_expr()->get_dataguide());
1260+ break;
1261+ }
1262+ case eval_expr_kind:
1263+ {
1264+ // invalidate all dataguides
1265+ dataguide_cb* dg = node->get_dataguide_or_new();
1266+ dg->set_star_on_roots();
1267+ break;
1268+ }
1269+
1270+ default:
1271+ break;
1272+ } // switch
1273+
1274+ if (node->get_dataguide())
1275+ {
1276+ if (node->get_dataguide()->getRefCount() > 1)
1277+ node->set_dataguide(node->get_dataguide()->clone());
1278+
1279+ node->get_dataguide()->set_propagates_on_leaves(child_items_propagate);
1280+ }
1281+}
1282+
1283+
1284 }
1285 /* vim:set et sw=2 ts=2: */
1286
1287=== modified file 'src/compiler/rewriter/rules/rule_base.h'
1288--- src/compiler/rewriter/rules/rule_base.h 2013-02-07 17:24:36 +0000
1289+++ src/compiler/rewriter/rules/rule_base.h 2013-09-11 19:02:46 +0000
1290@@ -55,7 +55,8 @@
1291 InlineFunctions,
1292 PartialEval,
1293 EchoNodes,
1294- PlanPrinter
1295+ PlanPrinter,
1296+ JsonDataguide
1297 } RuleKind;
1298
1299 private:
1300
1301=== modified file 'src/compiler/rewriter/rules/ruleset.h'
1302--- src/compiler/rewriter/rules/ruleset.h 2013-05-13 10:10:08 +0000
1303+++ src/compiler/rewriter/rules/ruleset.h 2013-09-11 19:02:46 +0000
1304@@ -223,6 +223,31 @@
1305 };
1306
1307
1308+/*******************************************************************************
1309+
1310+********************************************************************************/
1311+class JsonDataguide : public RewriteRule
1312+{
1313+public:
1314+ JsonDataguide()
1315+ :
1316+ RewriteRule(RewriteRule::JsonDataguide, "JsonDataguide")
1317+ {
1318+ }
1319+
1320+ expr* apply(RewriterContext& rCtx, expr* node, bool& modified);
1321+
1322+public:
1323+ // used for automated testing
1324+ void printDataguides(expr* root);
1325+
1326+protected:
1327+ void iterateChildren(expr* node);
1328+
1329+ void process(expr* node, bool child_items_propagate);
1330+};
1331+
1332+
1333 }
1334
1335 #endif /* ZORBA_REWRITE_RULE_H */
1336
1337=== modified file 'src/functions/function.cpp'
1338--- src/functions/function.cpp 2013-07-31 16:35:39 +0000
1339+++ src/functions/function.cpp 2013-09-11 19:02:46 +0000
1340@@ -137,6 +137,30 @@
1341 }
1342
1343
1344+void function::addAnnotation(AnnotationInternal::AnnotationId id)
1345+{
1346+ if (theAnnotationList == NULL)
1347+ theAnnotationList = new AnnotationList();
1348+
1349+ if (theAnnotationList->contains(id))
1350+ return;
1351+
1352+ theAnnotationList->push_back(id);
1353+
1354+ if (theAnnotationList->contains(AnnotationInternal::zann_nondeterministic))
1355+ setDeterministic(false);
1356+
1357+ setPrivate(theAnnotationList->contains(AnnotationInternal::fn_private));
1358+
1359+ if (isUpdating() &&
1360+ theAnnotationList->contains(AnnotationInternal::zann_sequential))
1361+ {
1362+ throw XQUERY_EXCEPTION(zerr::XSST0001,
1363+ ERROR_PARAMS(getName()->getStringValue()));
1364+ }
1365+}
1366+
1367+
1368 /*******************************************************************************
1369 This is a virstual method. It is redefined by udf and external-function
1370 classes.
1371
1372=== modified file 'src/functions/function.h'
1373--- src/functions/function.h 2013-08-02 21:35:01 +0000
1374+++ src/functions/function.h 2013-09-11 19:02:46 +0000
1375@@ -55,7 +55,7 @@
1376 #endif
1377 {
1378 protected:
1379- signature theSignature;
1380+ signature theSignature;
1381 FunctionConsts::FunctionKind theKind;
1382 uint32_t theFlags;
1383 AnnotationList * theAnnotationList;
1384@@ -171,8 +171,10 @@
1385 void setAnnotations(AnnotationList* annotations);
1386
1387 const AnnotationList* getAnnotationList() const { return theAnnotationList; }
1388+
1389+ void addAnnotation(AnnotationInternal::AnnotationId id);
1390
1391- bool validate_args(std::vector<PlanIter_t>& argv) const;
1392+ bool validate_args(std::vector<PlanIter_t>& argv) const;
1393
1394 bool isUpdating() const { return (getScriptingKind() & UPDATING_EXPR) != 0; }
1395
1396
1397=== modified file 'src/functions/pregenerated/func_accessors.h'
1398--- src/functions/pregenerated/func_accessors.h 2013-03-05 23:11:50 +0000
1399+++ src/functions/pregenerated/func_accessors.h 2013-09-11 19:02:46 +0000
1400@@ -46,7 +46,7 @@
1401 :
1402 function(sig, kind)
1403 {
1404-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
1405+ theXQueryVersion = StaticContextConsts::xquery_version_3_0;
1406 }
1407
1408 bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
1409@@ -62,7 +62,6 @@
1410 :
1411 function(sig, kind)
1412 {
1413-
1414 }
1415
1416 bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
1417@@ -79,7 +78,7 @@
1418 :
1419 function(sig, kind)
1420 {
1421-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
1422+ theXQueryVersion = StaticContextConsts::xquery_version_3_0;
1423 }
1424
1425 bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
1426@@ -95,7 +94,6 @@
1427 :
1428 function(sig, kind)
1429 {
1430-
1431 }
1432
1433 bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
1434@@ -112,7 +110,6 @@
1435 :
1436 function(sig, kind)
1437 {
1438-
1439 }
1440
1441 bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
1442@@ -129,7 +126,6 @@
1443 :
1444 function(sig, kind)
1445 {
1446-
1447 }
1448
1449 xqtref_t getReturnType(const fo_expr* caller) const;
1450@@ -154,7 +150,6 @@
1451 :
1452 function(sig, kind)
1453 {
1454-
1455 }
1456
1457 bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
1458@@ -171,7 +166,7 @@
1459 :
1460 function(sig, kind)
1461 {
1462-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
1463+ theXQueryVersion = StaticContextConsts::xquery_version_3_0;
1464 }
1465
1466 bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
1467@@ -187,7 +182,6 @@
1468 :
1469 function(sig, kind)
1470 {
1471-
1472 }
1473
1474 bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
1475@@ -204,7 +198,6 @@
1476 :
1477 function(sig, kind)
1478 {
1479-
1480 }
1481
1482 bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
1483
1484=== modified file 'src/functions/pregenerated/func_any_uri.h'
1485--- src/functions/pregenerated/func_any_uri.h 2013-03-05 23:11:50 +0000
1486+++ src/functions/pregenerated/func_any_uri.h 2013-09-11 19:02:46 +0000
1487@@ -46,7 +46,6 @@
1488 :
1489 function(sig, kind)
1490 {
1491-
1492 }
1493
1494 bool accessesDynCtx() const { return true; }
1495
1496=== modified file 'src/functions/pregenerated/func_base64.h'
1497--- src/functions/pregenerated/func_base64.h 2013-03-05 23:11:50 +0000
1498+++ src/functions/pregenerated/func_base64.h 2013-09-11 19:02:46 +0000
1499@@ -46,7 +46,6 @@
1500 :
1501 function(sig, kind)
1502 {
1503-
1504 }
1505
1506 CODEGEN_DECL();
1507@@ -61,7 +60,6 @@
1508 :
1509 function(sig, kind)
1510 {
1511-
1512 }
1513
1514 CODEGEN_DECL();
1515
1516=== modified file 'src/functions/pregenerated/func_booleans.h'
1517--- src/functions/pregenerated/func_booleans.h 2013-03-05 23:11:50 +0000
1518+++ src/functions/pregenerated/func_booleans.h 2013-09-11 19:02:46 +0000
1519@@ -46,7 +46,6 @@
1520 :
1521 function(sig, kind)
1522 {
1523-
1524 }
1525
1526 bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
1527@@ -63,7 +62,6 @@
1528 :
1529 function(sig, kind)
1530 {
1531-
1532 }
1533
1534 bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
1535@@ -80,7 +78,6 @@
1536 :
1537 function(sig, kind)
1538 {
1539-
1540 }
1541
1542 bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
1543
1544=== modified file 'src/functions/pregenerated/func_collections.h'
1545--- src/functions/pregenerated/func_collections.h 2013-03-05 23:11:50 +0000
1546+++ src/functions/pregenerated/func_collections.h 2013-09-11 19:02:46 +0000
1547@@ -46,7 +46,6 @@
1548 :
1549 function(sig, kind)
1550 {
1551-
1552 }
1553
1554 unsigned short getScriptingKind() const { return UPDATING_EXPR; }
1555@@ -67,7 +66,6 @@
1556 :
1557 function(sig, kind)
1558 {
1559-
1560 }
1561
1562 unsigned short getScriptingKind() const { return UPDATING_EXPR; }
1563@@ -88,7 +86,6 @@
1564 :
1565 function(sig, kind)
1566 {
1567-
1568 }
1569
1570 bool accessesDynCtx() const { return true; }
1571@@ -105,7 +102,6 @@
1572 :
1573 function(sig, kind)
1574 {
1575-
1576 }
1577
1578 bool accessesDynCtx() const { return true; }
1579@@ -122,7 +118,6 @@
1580 :
1581 function(sig, kind)
1582 {
1583-
1584 }
1585
1586 bool accessesDynCtx() const { return true; }
1587@@ -141,7 +136,6 @@
1588 :
1589 function(sig, kind)
1590 {
1591-
1592 }
1593
1594 bool accessesDynCtx() const { return true; }
1595@@ -172,7 +166,6 @@
1596 :
1597 function(sig, kind)
1598 {
1599-
1600 }
1601
1602 bool accessesDynCtx() const { return true; }
1603@@ -191,7 +184,6 @@
1604 :
1605 function(sig, kind)
1606 {
1607-
1608 }
1609
1610 bool accessesDynCtx() const { return true; }
1611@@ -210,7 +202,7 @@
1612 :
1613 function(sig, kind)
1614 {
1615-
1616+ addAnnotation(AnnotationInternal::zann_explores_json);
1617 }
1618
1619 unsigned short getScriptingKind() const { return UPDATING_EXPR; }
1620@@ -233,7 +225,7 @@
1621 :
1622 function(sig, kind)
1623 {
1624-
1625+ addAnnotation(AnnotationInternal::zann_explores_json);
1626 }
1627
1628 unsigned short getScriptingKind() const { return UPDATING_EXPR; }
1629@@ -256,7 +248,7 @@
1630 :
1631 function(sig, kind)
1632 {
1633-
1634+ addAnnotation(AnnotationInternal::zann_explores_json);
1635 }
1636
1637 unsigned short getScriptingKind() const { return UPDATING_EXPR; }
1638@@ -279,7 +271,7 @@
1639 :
1640 function(sig, kind)
1641 {
1642-
1643+ addAnnotation(AnnotationInternal::zann_explores_json);
1644 }
1645
1646 unsigned short getScriptingKind() const { return UPDATING_EXPR; }
1647@@ -302,7 +294,7 @@
1648 :
1649 function(sig, kind)
1650 {
1651-
1652+ addAnnotation(AnnotationInternal::zann_explores_json);
1653 }
1654
1655 unsigned short getScriptingKind() const { return UPDATING_EXPR; }
1656@@ -325,7 +317,7 @@
1657 :
1658 function(sig, kind)
1659 {
1660-
1661+ addAnnotation(AnnotationInternal::zann_explores_json);
1662 }
1663
1664 unsigned short getScriptingKind() const { return APPLYING_EXPR; }
1665@@ -350,7 +342,7 @@
1666 :
1667 function(sig, kind)
1668 {
1669-
1670+ addAnnotation(AnnotationInternal::zann_explores_json);
1671 }
1672
1673 unsigned short getScriptingKind() const { return APPLYING_EXPR; }
1674@@ -375,7 +367,7 @@
1675 :
1676 function(sig, kind)
1677 {
1678-
1679+ addAnnotation(AnnotationInternal::zann_explores_json);
1680 }
1681
1682 unsigned short getScriptingKind() const { return APPLYING_EXPR; }
1683@@ -400,7 +392,7 @@
1684 :
1685 function(sig, kind)
1686 {
1687-
1688+ addAnnotation(AnnotationInternal::zann_explores_json);
1689 }
1690
1691 unsigned short getScriptingKind() const { return APPLYING_EXPR; }
1692@@ -425,7 +417,7 @@
1693 :
1694 function(sig, kind)
1695 {
1696-
1697+ addAnnotation(AnnotationInternal::zann_explores_json);
1698 }
1699
1700 unsigned short getScriptingKind() const { return APPLYING_EXPR; }
1701@@ -450,7 +442,6 @@
1702 :
1703 function(sig, kind)
1704 {
1705-
1706 }
1707
1708 unsigned short getScriptingKind() const { return UPDATING_EXPR; }
1709@@ -475,7 +466,6 @@
1710 :
1711 function(sig, kind)
1712 {
1713-
1714 }
1715
1716 unsigned short getScriptingKind() const { return UPDATING_EXPR; }
1717@@ -496,7 +486,6 @@
1718 :
1719 function(sig, kind)
1720 {
1721-
1722 }
1723
1724 unsigned short getScriptingKind() const { return UPDATING_EXPR; }
1725@@ -517,7 +506,7 @@
1726 :
1727 function(sig, kind)
1728 {
1729-
1730+ addAnnotation(AnnotationInternal::zann_explores_json);
1731 }
1732
1733 unsigned short getScriptingKind() const { return UPDATING_EXPR; }
1734@@ -540,7 +529,6 @@
1735 :
1736 function(sig, kind)
1737 {
1738-
1739 }
1740
1741 unsigned short getScriptingKind() const { return UPDATING_EXPR; }
1742@@ -559,7 +547,6 @@
1743 :
1744 function(sig, kind)
1745 {
1746-
1747 }
1748
1749 bool accessesDynCtx() const { return true; }
1750@@ -576,7 +563,6 @@
1751 :
1752 function(sig, kind)
1753 {
1754-
1755 }
1756
1757 bool accessesDynCtx() const { return true; }
1758@@ -593,7 +579,6 @@
1759 :
1760 function(sig, kind)
1761 {
1762-
1763 }
1764
1765 bool accessesDynCtx() const { return true; }
1766@@ -610,7 +595,6 @@
1767 :
1768 function(sig, kind)
1769 {
1770-
1771 }
1772
1773 bool accessesDynCtx() const { return true; }
1774@@ -627,7 +611,6 @@
1775 :
1776 function(sig, kind)
1777 {
1778-
1779 }
1780
1781 CODEGEN_DECL();
1782@@ -642,7 +625,6 @@
1783 :
1784 function(sig, kind)
1785 {
1786-
1787 }
1788
1789 CODEGEN_DECL();
1790@@ -657,7 +639,6 @@
1791 :
1792 function(sig, kind)
1793 {
1794-
1795 }
1796
1797 CODEGEN_DECL();
1798@@ -672,7 +653,6 @@
1799 :
1800 function(sig, kind)
1801 {
1802-
1803 }
1804
1805 CODEGEN_DECL();
1806@@ -687,7 +667,6 @@
1807 :
1808 function(sig, kind)
1809 {
1810-
1811 }
1812
1813 CODEGEN_DECL();
1814@@ -702,7 +681,6 @@
1815 :
1816 function(sig, kind)
1817 {
1818-
1819 }
1820
1821 CODEGEN_DECL();
1822@@ -717,7 +695,7 @@
1823 :
1824 function(sig, kind)
1825 {
1826-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
1827+ theXQueryVersion = StaticContextConsts::xquery_version_3_0;
1828 }
1829
1830 CODEGEN_DECL();
1831
1832=== modified file 'src/functions/pregenerated/func_context.h'
1833--- src/functions/pregenerated/func_context.h 2013-03-05 23:11:50 +0000
1834+++ src/functions/pregenerated/func_context.h 2013-09-11 19:02:46 +0000
1835@@ -46,7 +46,6 @@
1836 :
1837 function(sig, kind)
1838 {
1839-
1840 }
1841
1842 bool accessesDynCtx() const { return true; }
1843@@ -63,7 +62,6 @@
1844 :
1845 function(sig, kind)
1846 {
1847-
1848 }
1849
1850 bool accessesDynCtx() const { return true; }
1851@@ -80,7 +78,6 @@
1852 :
1853 function(sig, kind)
1854 {
1855-
1856 }
1857
1858 bool accessesDynCtx() const { return true; }
1859@@ -97,7 +94,6 @@
1860 :
1861 function(sig, kind)
1862 {
1863-
1864 }
1865
1866 bool accessesDynCtx() const { return true; }
1867@@ -114,7 +110,6 @@
1868 :
1869 function(sig, kind)
1870 {
1871-
1872 }
1873
1874 bool accessesDynCtx() const { return true; }
1875@@ -131,7 +126,6 @@
1876 :
1877 function(sig, kind)
1878 {
1879-
1880 }
1881
1882 CODEGEN_DECL();
1883@@ -146,7 +140,6 @@
1884 :
1885 function(sig, kind)
1886 {
1887-
1888 }
1889
1890 CODEGEN_DECL();
1891@@ -161,7 +154,6 @@
1892 :
1893 function(sig, kind)
1894 {
1895-
1896 }
1897
1898 CODEGEN_DECL();
1899
1900=== modified file 'src/functions/pregenerated/func_datetime.h'
1901--- src/functions/pregenerated/func_datetime.h 2013-08-02 19:15:22 +0000
1902+++ src/functions/pregenerated/func_datetime.h 2013-09-11 19:02:46 +0000
1903@@ -47,7 +47,6 @@
1904 function(sig, kind)
1905 {
1906 setDeterministic(false);
1907-
1908 }
1909
1910 CODEGEN_DECL();
1911@@ -63,7 +62,6 @@
1912 function(sig, kind)
1913 {
1914 setDeterministic(false);
1915-
1916 }
1917
1918 CODEGEN_DECL();
1919@@ -79,7 +77,6 @@
1920 function(sig, kind)
1921 {
1922 setDeterministic(false);
1923-
1924 }
1925
1926 CODEGEN_DECL();
1927@@ -94,7 +91,6 @@
1928 :
1929 function(sig, kind)
1930 {
1931-
1932 }
1933
1934 CODEGEN_DECL();
1935@@ -109,7 +105,6 @@
1936 :
1937 function(sig, kind)
1938 {
1939-
1940 }
1941
1942 CODEGEN_DECL();
1943@@ -124,7 +119,6 @@
1944 :
1945 function(sig, kind)
1946 {
1947-
1948 }
1949
1950 CODEGEN_DECL();
1951@@ -139,7 +133,6 @@
1952 :
1953 function(sig, kind)
1954 {
1955-
1956 }
1957
1958 CODEGEN_DECL();
1959@@ -155,7 +148,6 @@
1960 function(sig, kind)
1961 {
1962 setDeterministic(false);
1963-
1964 }
1965
1966 CODEGEN_DECL();
1967@@ -171,7 +163,6 @@
1968 function(sig, kind)
1969 {
1970 setDeterministic(false);
1971-
1972 }
1973
1974 CODEGEN_DECL();
1975
1976=== modified file 'src/functions/pregenerated/func_documents.h'
1977--- src/functions/pregenerated/func_documents.h 2013-03-05 23:11:50 +0000
1978+++ src/functions/pregenerated/func_documents.h 2013-09-11 19:02:46 +0000
1979@@ -46,7 +46,6 @@
1980 :
1981 function(sig, kind)
1982 {
1983-
1984 }
1985
1986 unsigned short getScriptingKind() const { return UPDATING_EXPR; }
1987@@ -67,7 +66,6 @@
1988 :
1989 function(sig, kind)
1990 {
1991-
1992 }
1993
1994 unsigned short getScriptingKind() const { return UPDATING_EXPR; }
1995@@ -86,7 +84,6 @@
1996 :
1997 function(sig, kind)
1998 {
1999-
2000 }
2001
2002 bool accessesDynCtx() const { return true; }
2003@@ -103,7 +100,6 @@
2004 :
2005 function(sig, kind)
2006 {
2007-
2008 }
2009
2010 bool accessesDynCtx() const { return true; }
2011@@ -120,7 +116,6 @@
2012 :
2013 function(sig, kind)
2014 {
2015-
2016 }
2017
2018 bool accessesDynCtx() const { return true; }
2019
2020=== modified file 'src/functions/pregenerated/func_durations_dates_times.h'
2021--- src/functions/pregenerated/func_durations_dates_times.h 2013-03-05 23:11:50 +0000
2022+++ src/functions/pregenerated/func_durations_dates_times.h 2013-09-11 19:02:46 +0000
2023@@ -46,7 +46,6 @@
2024 :
2025 function(sig, kind)
2026 {
2027-
2028 }
2029
2030 CODEGEN_DECL();
2031@@ -61,7 +60,6 @@
2032 :
2033 function(sig, kind)
2034 {
2035-
2036 }
2037
2038 CODEGEN_DECL();
2039@@ -76,7 +74,6 @@
2040 :
2041 function(sig, kind)
2042 {
2043-
2044 }
2045
2046 CODEGEN_DECL();
2047@@ -91,7 +88,6 @@
2048 :
2049 function(sig, kind)
2050 {
2051-
2052 }
2053
2054 CODEGEN_DECL();
2055@@ -106,7 +102,6 @@
2056 :
2057 function(sig, kind)
2058 {
2059-
2060 }
2061
2062 CODEGEN_DECL();
2063@@ -121,7 +116,6 @@
2064 :
2065 function(sig, kind)
2066 {
2067-
2068 }
2069
2070 CODEGEN_DECL();
2071@@ -136,7 +130,6 @@
2072 :
2073 function(sig, kind)
2074 {
2075-
2076 }
2077
2078 CODEGEN_DECL();
2079@@ -151,7 +144,6 @@
2080 :
2081 function(sig, kind)
2082 {
2083-
2084 }
2085
2086 CODEGEN_DECL();
2087@@ -166,7 +158,6 @@
2088 :
2089 function(sig, kind)
2090 {
2091-
2092 }
2093
2094 CODEGEN_DECL();
2095@@ -181,7 +172,6 @@
2096 :
2097 function(sig, kind)
2098 {
2099-
2100 }
2101
2102 CODEGEN_DECL();
2103@@ -196,7 +186,6 @@
2104 :
2105 function(sig, kind)
2106 {
2107-
2108 }
2109
2110 CODEGEN_DECL();
2111@@ -211,7 +200,6 @@
2112 :
2113 function(sig, kind)
2114 {
2115-
2116 }
2117
2118 CODEGEN_DECL();
2119@@ -226,7 +214,6 @@
2120 :
2121 function(sig, kind)
2122 {
2123-
2124 }
2125
2126 CODEGEN_DECL();
2127@@ -241,7 +228,6 @@
2128 :
2129 function(sig, kind)
2130 {
2131-
2132 }
2133
2134 CODEGEN_DECL();
2135@@ -256,7 +242,6 @@
2136 :
2137 function(sig, kind)
2138 {
2139-
2140 }
2141
2142 CODEGEN_DECL();
2143@@ -271,7 +256,6 @@
2144 :
2145 function(sig, kind)
2146 {
2147-
2148 }
2149
2150 CODEGEN_DECL();
2151@@ -286,7 +270,6 @@
2152 :
2153 function(sig, kind)
2154 {
2155-
2156 }
2157
2158 CODEGEN_DECL();
2159@@ -301,7 +284,6 @@
2160 :
2161 function(sig, kind)
2162 {
2163-
2164 }
2165
2166 CODEGEN_DECL();
2167@@ -316,7 +298,6 @@
2168 :
2169 function(sig, kind)
2170 {
2171-
2172 }
2173
2174 CODEGEN_DECL();
2175@@ -331,7 +312,6 @@
2176 :
2177 function(sig, kind)
2178 {
2179-
2180 }
2181
2182 CODEGEN_DECL();
2183@@ -346,7 +326,6 @@
2184 :
2185 function(sig, kind)
2186 {
2187-
2188 }
2189
2190 CODEGEN_DECL();
2191
2192=== modified file 'src/functions/pregenerated/func_errors_and_diagnostics.h'
2193--- src/functions/pregenerated/func_errors_and_diagnostics.h 2013-03-05 23:11:50 +0000
2194+++ src/functions/pregenerated/func_errors_and_diagnostics.h 2013-09-11 19:02:46 +0000
2195@@ -46,7 +46,6 @@
2196 :
2197 function(sig, kind)
2198 {
2199-
2200 }
2201
2202 unsigned short getScriptingKind() const { return VACUOUS_EXPR; }
2203@@ -65,7 +64,6 @@
2204 :
2205 function(sig, kind)
2206 {
2207-
2208 }
2209
2210 bool isMap(csize producer) const { return producer == 0; }
2211
2212=== modified file 'src/functions/pregenerated/func_fetch.h'
2213--- src/functions/pregenerated/func_fetch.h 2013-03-05 23:11:50 +0000
2214+++ src/functions/pregenerated/func_fetch.h 2013-09-11 19:02:46 +0000
2215@@ -46,7 +46,6 @@
2216 :
2217 function(sig, kind)
2218 {
2219-
2220 }
2221
2222 bool accessesDynCtx() const { return true; }
2223@@ -63,7 +62,6 @@
2224 :
2225 function(sig, kind)
2226 {
2227-
2228 }
2229
2230 bool accessesDynCtx() const { return true; }
2231@@ -80,7 +78,6 @@
2232 :
2233 function(sig, kind)
2234 {
2235-
2236 }
2237
2238 bool accessesDynCtx() const { return true; }
2239
2240=== modified file 'src/functions/pregenerated/func_fn_hof_functions.h'
2241--- src/functions/pregenerated/func_fn_hof_functions.h 2013-06-04 21:47:40 +0000
2242+++ src/functions/pregenerated/func_fn_hof_functions.h 2013-09-11 19:02:46 +0000
2243@@ -46,7 +46,7 @@
2244 :
2245 function(sig, kind)
2246 {
2247-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
2248+ theXQueryVersion = StaticContextConsts::xquery_version_3_0;
2249 }
2250
2251 CODEGEN_DECL();
2252@@ -61,7 +61,7 @@
2253 :
2254 function(sig, kind)
2255 {
2256-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
2257+ theXQueryVersion = StaticContextConsts::xquery_version_3_0;
2258 }
2259
2260 CODEGEN_DECL();
2261@@ -76,7 +76,7 @@
2262 :
2263 function(sig, kind)
2264 {
2265-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
2266+ theXQueryVersion = StaticContextConsts::xquery_version_3_0;
2267 }
2268
2269 CODEGEN_DECL();
2270@@ -91,7 +91,7 @@
2271 :
2272 function(sig, kind)
2273 {
2274-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
2275+ theXQueryVersion = StaticContextConsts::xquery_version_3_0;
2276 }
2277
2278 CODEGEN_DECL();
2279@@ -106,7 +106,7 @@
2280 :
2281 function(sig, kind)
2282 {
2283-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
2284+ theXQueryVersion = StaticContextConsts::xquery_version_3_0;
2285 }
2286
2287 CODEGEN_DECL();
2288@@ -121,7 +121,7 @@
2289 :
2290 function(sig, kind)
2291 {
2292-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
2293+ theXQueryVersion = StaticContextConsts::xquery_version_3_0;
2294 }
2295
2296 CODEGEN_DECL();
2297@@ -136,7 +136,7 @@
2298 :
2299 function(sig, kind)
2300 {
2301-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
2302+ theXQueryVersion = StaticContextConsts::xquery_version_3_0;
2303 }
2304
2305 CODEGEN_DECL();
2306
2307=== modified file 'src/functions/pregenerated/func_fnput.h'
2308--- src/functions/pregenerated/func_fnput.h 2013-03-05 23:11:50 +0000
2309+++ src/functions/pregenerated/func_fnput.h 2013-09-11 19:02:46 +0000
2310@@ -46,7 +46,6 @@
2311 :
2312 function(sig, kind)
2313 {
2314-
2315 }
2316
2317 unsigned short getScriptingKind() const { return UPDATING_EXPR; }
2318
2319=== modified file 'src/functions/pregenerated/func_ft_module.h'
2320--- src/functions/pregenerated/func_ft_module.h 2013-06-26 00:10:23 +0000
2321+++ src/functions/pregenerated/func_ft_module.h 2013-09-11 19:02:46 +0000
2322@@ -46,7 +46,6 @@
2323 :
2324 function(sig, kind)
2325 {
2326-
2327 }
2328
2329 CODEGEN_DECL();
2330@@ -62,7 +61,6 @@
2331 :
2332 function(sig, kind)
2333 {
2334-
2335 }
2336
2337 CODEGEN_DECL();
2338@@ -78,7 +76,6 @@
2339 :
2340 function(sig, kind)
2341 {
2342-
2343 }
2344
2345 CODEGEN_DECL();
2346@@ -94,7 +91,6 @@
2347 :
2348 function(sig, kind)
2349 {
2350-
2351 }
2352
2353 CODEGEN_DECL();
2354@@ -110,7 +106,6 @@
2355 :
2356 function(sig, kind)
2357 {
2358-
2359 }
2360
2361 CODEGEN_DECL();
2362@@ -126,7 +121,6 @@
2363 :
2364 function(sig, kind)
2365 {
2366-
2367 }
2368
2369 CODEGEN_DECL();
2370@@ -142,7 +136,6 @@
2371 :
2372 function(sig, kind)
2373 {
2374-
2375 }
2376
2377 CODEGEN_DECL();
2378@@ -158,7 +151,6 @@
2379 :
2380 function(sig, kind)
2381 {
2382-
2383 }
2384
2385 CODEGEN_DECL();
2386@@ -174,7 +166,6 @@
2387 :
2388 function(sig, kind)
2389 {
2390-
2391 }
2392
2393 CODEGEN_DECL();
2394@@ -190,7 +181,6 @@
2395 :
2396 function(sig, kind)
2397 {
2398-
2399 }
2400
2401 CODEGEN_DECL();
2402@@ -206,7 +196,6 @@
2403 :
2404 function(sig, kind)
2405 {
2406-
2407 }
2408
2409 CODEGEN_DECL();
2410@@ -222,7 +211,6 @@
2411 :
2412 function(sig, kind)
2413 {
2414-
2415 }
2416
2417 CODEGEN_DECL();
2418@@ -238,7 +226,6 @@
2419 :
2420 function(sig, kind)
2421 {
2422-
2423 }
2424
2425 CODEGEN_DECL();
2426@@ -254,7 +241,6 @@
2427 :
2428 function(sig, kind)
2429 {
2430-
2431 }
2432
2433 CODEGEN_DECL();
2434@@ -270,7 +256,6 @@
2435 :
2436 function(sig, kind)
2437 {
2438-
2439 }
2440
2441 CODEGEN_DECL();
2442
2443=== modified file 'src/functions/pregenerated/func_ic_ddl.h'
2444--- src/functions/pregenerated/func_ic_ddl.h 2013-03-05 23:11:50 +0000
2445+++ src/functions/pregenerated/func_ic_ddl.h 2013-09-11 19:02:46 +0000
2446@@ -46,7 +46,6 @@
2447 :
2448 function(sig, kind)
2449 {
2450-
2451 }
2452
2453 unsigned short getScriptingKind() const { return UPDATING_EXPR; }
2454@@ -65,7 +64,6 @@
2455 :
2456 function(sig, kind)
2457 {
2458-
2459 }
2460
2461 unsigned short getScriptingKind() const { return UPDATING_EXPR; }
2462@@ -84,7 +82,6 @@
2463 :
2464 function(sig, kind)
2465 {
2466-
2467 }
2468
2469 bool accessesDynCtx() const { return true; }
2470
2471=== modified file 'src/functions/pregenerated/func_index_func.h'
2472--- src/functions/pregenerated/func_index_func.h 2013-03-05 23:11:50 +0000
2473+++ src/functions/pregenerated/func_index_func.h 2013-09-11 19:02:46 +0000
2474@@ -46,7 +46,6 @@
2475 :
2476 function(sig, kind)
2477 {
2478-
2479 }
2480
2481 bool accessesDynCtx() const { return true; }
2482
2483=== modified file 'src/functions/pregenerated/func_item.h'
2484--- src/functions/pregenerated/func_item.h 2013-03-05 23:11:50 +0000
2485+++ src/functions/pregenerated/func_item.h 2013-09-11 19:02:46 +0000
2486@@ -46,7 +46,6 @@
2487 :
2488 function(sig, kind)
2489 {
2490-
2491 }
2492
2493 CODEGEN_DECL();
2494
2495=== modified file 'src/functions/pregenerated/func_json.h'
2496--- src/functions/pregenerated/func_json.h 2013-07-26 05:36:22 +0000
2497+++ src/functions/pregenerated/func_json.h 2013-09-11 19:02:46 +0000
2498@@ -46,7 +46,6 @@
2499 :
2500 function(sig, kind)
2501 {
2502-
2503 }
2504
2505 CODEGEN_DECL();
2506@@ -61,7 +60,6 @@
2507 :
2508 function(sig, kind)
2509 {
2510-
2511 }
2512
2513 CODEGEN_DECL();
2514
2515=== modified file 'src/functions/pregenerated/func_jsoniq_functions.h'
2516--- src/functions/pregenerated/func_jsoniq_functions.h 2013-08-16 13:00:06 +0000
2517+++ src/functions/pregenerated/func_jsoniq_functions.h 2013-09-11 19:02:46 +0000
2518@@ -46,7 +46,6 @@
2519 :
2520 function(sig, kind)
2521 {
2522-
2523 }
2524
2525 bool propagatesInputNodes(expr* fo, csize producer) const { return false; }
2526@@ -65,7 +64,7 @@
2527 :
2528 function(sig, kind)
2529 {
2530-
2531+ addAnnotation(AnnotationInternal::zann_explores_json);
2532 }
2533
2534 bool propagatesInputNodes(expr* fo, csize producer) const { return false; }
2535@@ -84,7 +83,6 @@
2536 :
2537 function(sig, kind)
2538 {
2539-
2540 }
2541
2542 bool accessesDynCtx() const { return true; }
2543@@ -103,7 +101,7 @@
2544 :
2545 function(sig, kind)
2546 {
2547-
2548+ addAnnotation(AnnotationInternal::zann_explores_json);
2549 }
2550
2551 bool propagatesInputNodes(expr* fo, csize producer) const { return false; }
2552@@ -124,7 +122,6 @@
2553 :
2554 function(sig, kind)
2555 {
2556-
2557 }
2558
2559 bool propagatesInputNodes(expr* fo, csize producer) const { return false; }
2560@@ -143,7 +140,6 @@
2561 :
2562 function(sig, kind)
2563 {
2564-
2565 }
2566
2567 xqtref_t getReturnType(const fo_expr* caller) const;
2568@@ -164,7 +160,6 @@
2569 :
2570 function(sig, kind)
2571 {
2572-
2573 }
2574
2575 xqtref_t getReturnType(const fo_expr* caller) const;
2576@@ -185,7 +180,7 @@
2577 :
2578 function(sig, kind)
2579 {
2580-
2581+ addAnnotation(AnnotationInternal::zann_explores_json);
2582 }
2583
2584 xqtref_t getReturnType(const fo_expr* caller) const;
2585@@ -208,7 +203,6 @@
2586 :
2587 function(sig, kind)
2588 {
2589-
2590 }
2591
2592 xqtref_t getReturnType(const fo_expr* caller) const;
2593@@ -231,7 +225,6 @@
2594 :
2595 function(sig, kind)
2596 {
2597-
2598 }
2599
2600 bool propagatesInputNodes(expr* fo, csize producer) const { return producer == 0; }
2601@@ -252,7 +245,6 @@
2602 :
2603 function(sig, kind)
2604 {
2605-
2606 }
2607
2608 bool propagatesInputNodes(expr* fo, csize producer) const { return producer == 0; }
2609@@ -271,7 +263,6 @@
2610 :
2611 function(sig, kind)
2612 {
2613-
2614 }
2615
2616 xqtref_t getReturnType(const fo_expr* caller) const;
2617@@ -294,7 +285,6 @@
2618 :
2619 function(sig, kind)
2620 {
2621-
2622 }
2623
2624 xqtref_t getReturnType(const fo_expr* caller) const;
2625@@ -315,7 +305,7 @@
2626 :
2627 function(sig, kind)
2628 {
2629-
2630+ addAnnotation(AnnotationInternal::zann_explores_json);
2631 }
2632
2633 xqtref_t getReturnType(const fo_expr* caller) const;
2634@@ -336,7 +326,6 @@
2635 :
2636 function(sig, kind)
2637 {
2638-
2639 }
2640
2641 bool propagatesInputNodes(expr* fo, csize producer) const { return true; }
2642@@ -357,7 +346,6 @@
2643 :
2644 function(sig, kind)
2645 {
2646-
2647 }
2648
2649 CODEGEN_DECL();
2650@@ -372,7 +360,6 @@
2651 :
2652 function(sig, kind)
2653 {
2654-
2655 }
2656
2657 unsigned short getScriptingKind() const { return UPDATING_EXPR; }
2658@@ -393,7 +380,6 @@
2659 :
2660 function(sig, kind)
2661 {
2662-
2663 }
2664
2665 unsigned short getScriptingKind() const { return UPDATING_EXPR; }
2666@@ -414,7 +400,6 @@
2667 :
2668 function(sig, kind)
2669 {
2670-
2671 }
2672
2673 unsigned short getScriptingKind() const { return UPDATING_EXPR; }
2674@@ -433,7 +418,6 @@
2675 :
2676 function(sig, kind)
2677 {
2678-
2679 }
2680
2681 unsigned short getScriptingKind() const { return UPDATING_EXPR; }
2682@@ -454,7 +438,6 @@
2683 :
2684 function(sig, kind)
2685 {
2686-
2687 }
2688
2689 unsigned short getScriptingKind() const { return UPDATING_EXPR; }
2690@@ -473,7 +456,6 @@
2691 :
2692 function(sig, kind)
2693 {
2694-
2695 }
2696
2697 unsigned short getScriptingKind() const { return UPDATING_EXPR; }
2698@@ -494,7 +476,6 @@
2699 :
2700 function(sig, kind)
2701 {
2702-
2703 }
2704
2705 xqtref_t getReturnType(const fo_expr* caller) const;
2706
2707=== modified file 'src/functions/pregenerated/func_maps.h'
2708--- src/functions/pregenerated/func_maps.h 2013-08-24 23:38:45 +0000
2709+++ src/functions/pregenerated/func_maps.h 2013-09-11 19:02:46 +0000
2710@@ -46,7 +46,6 @@
2711 :
2712 function(sig, kind)
2713 {
2714-
2715 }
2716
2717 unsigned short getScriptingKind() const { return SEQUENTIAL_FUNC_EXPR; }
2718@@ -65,7 +64,6 @@
2719 :
2720 function(sig, kind)
2721 {
2722-
2723 }
2724
2725 unsigned short getScriptingKind() const { return SEQUENTIAL_FUNC_EXPR; }
2726@@ -84,7 +82,6 @@
2727 :
2728 function(sig, kind)
2729 {
2730-
2731 }
2732
2733 bool accessesDynCtx() const { return true; }
2734@@ -101,7 +98,6 @@
2735 :
2736 function(sig, kind)
2737 {
2738-
2739 }
2740
2741 unsigned short getScriptingKind() const { return SEQUENTIAL_FUNC_EXPR; }
2742@@ -122,7 +118,6 @@
2743 :
2744 function(sig, kind)
2745 {
2746-
2747 }
2748
2749 unsigned short getScriptingKind() const { return SEQUENTIAL_FUNC_EXPR; }
2750@@ -141,7 +136,6 @@
2751 :
2752 function(sig, kind)
2753 {
2754-
2755 }
2756
2757 bool accessesDynCtx() const { return true; }
2758@@ -158,7 +152,6 @@
2759 :
2760 function(sig, kind)
2761 {
2762-
2763 }
2764
2765 bool accessesDynCtx() const { return true; }
2766@@ -175,7 +168,6 @@
2767 :
2768 function(sig, kind)
2769 {
2770-
2771 }
2772
2773 bool accessesDynCtx() const { return true; }
2774@@ -192,7 +184,6 @@
2775 :
2776 function(sig, kind)
2777 {
2778-
2779 }
2780
2781 bool accessesDynCtx() const { return true; }
2782
2783=== modified file 'src/functions/pregenerated/func_maths.h'
2784--- src/functions/pregenerated/func_maths.h 2013-03-05 23:11:50 +0000
2785+++ src/functions/pregenerated/func_maths.h 2013-09-11 19:02:46 +0000
2786@@ -46,7 +46,6 @@
2787 :
2788 function(sig, kind)
2789 {
2790-
2791 }
2792
2793 CODEGEN_DECL();
2794@@ -61,7 +60,6 @@
2795 :
2796 function(sig, kind)
2797 {
2798-
2799 }
2800
2801 CODEGEN_DECL();
2802@@ -76,7 +74,6 @@
2803 :
2804 function(sig, kind)
2805 {
2806-
2807 }
2808
2809 CODEGEN_DECL();
2810@@ -91,7 +88,6 @@
2811 :
2812 function(sig, kind)
2813 {
2814-
2815 }
2816
2817 CODEGEN_DECL();
2818@@ -106,7 +102,6 @@
2819 :
2820 function(sig, kind)
2821 {
2822-
2823 }
2824
2825 CODEGEN_DECL();
2826@@ -121,7 +116,6 @@
2827 :
2828 function(sig, kind)
2829 {
2830-
2831 }
2832
2833 CODEGEN_DECL();
2834@@ -136,7 +130,6 @@
2835 :
2836 function(sig, kind)
2837 {
2838-
2839 }
2840
2841 CODEGEN_DECL();
2842@@ -151,7 +144,6 @@
2843 :
2844 function(sig, kind)
2845 {
2846-
2847 }
2848
2849 CODEGEN_DECL();
2850@@ -166,7 +158,6 @@
2851 :
2852 function(sig, kind)
2853 {
2854-
2855 }
2856
2857 CODEGEN_DECL();
2858@@ -181,7 +172,6 @@
2859 :
2860 function(sig, kind)
2861 {
2862-
2863 }
2864
2865 CODEGEN_DECL();
2866@@ -196,7 +186,6 @@
2867 :
2868 function(sig, kind)
2869 {
2870-
2871 }
2872
2873 CODEGEN_DECL();
2874@@ -211,7 +200,6 @@
2875 :
2876 function(sig, kind)
2877 {
2878-
2879 }
2880
2881 CODEGEN_DECL();
2882@@ -226,7 +214,6 @@
2883 :
2884 function(sig, kind)
2885 {
2886-
2887 }
2888
2889 CODEGEN_DECL();
2890@@ -241,7 +228,6 @@
2891 :
2892 function(sig, kind)
2893 {
2894-
2895 }
2896
2897 CODEGEN_DECL();
2898@@ -256,7 +242,6 @@
2899 :
2900 function(sig, kind)
2901 {
2902-
2903 }
2904
2905 CODEGEN_DECL();
2906@@ -271,7 +256,6 @@
2907 :
2908 function(sig, kind)
2909 {
2910-
2911 }
2912
2913 CODEGEN_DECL();
2914@@ -286,7 +270,6 @@
2915 :
2916 function(sig, kind)
2917 {
2918-
2919 }
2920
2921 CODEGEN_DECL();
2922@@ -301,7 +284,6 @@
2923 :
2924 function(sig, kind)
2925 {
2926-
2927 }
2928
2929 CODEGEN_DECL();
2930@@ -316,7 +298,6 @@
2931 :
2932 function(sig, kind)
2933 {
2934-
2935 }
2936
2937 CODEGEN_DECL();
2938@@ -331,7 +312,6 @@
2939 :
2940 function(sig, kind)
2941 {
2942-
2943 }
2944
2945 CODEGEN_DECL();
2946@@ -346,7 +326,6 @@
2947 :
2948 function(sig, kind)
2949 {
2950-
2951 }
2952
2953 CODEGEN_DECL();
2954@@ -361,7 +340,6 @@
2955 :
2956 function(sig, kind)
2957 {
2958-
2959 }
2960
2961 CODEGEN_DECL();
2962@@ -376,7 +354,6 @@
2963 :
2964 function(sig, kind)
2965 {
2966-
2967 }
2968
2969 CODEGEN_DECL();
2970@@ -391,7 +368,6 @@
2971 :
2972 function(sig, kind)
2973 {
2974-
2975 }
2976
2977 CODEGEN_DECL();
2978@@ -406,7 +382,6 @@
2979 :
2980 function(sig, kind)
2981 {
2982-
2983 }
2984
2985 CODEGEN_DECL();
2986@@ -421,7 +396,6 @@
2987 :
2988 function(sig, kind)
2989 {
2990-
2991 }
2992
2993 CODEGEN_DECL();
2994
2995=== modified file 'src/functions/pregenerated/func_node_position.h'
2996--- src/functions/pregenerated/func_node_position.h 2013-03-05 23:11:50 +0000
2997+++ src/functions/pregenerated/func_node_position.h 2013-09-11 19:02:46 +0000
2998@@ -46,7 +46,6 @@
2999 :
3000 function(sig, kind)
3001 {
3002-
3003 }
3004
3005 CODEGEN_DECL();
3006@@ -61,7 +60,6 @@
3007 :
3008 function(sig, kind)
3009 {
3010-
3011 }
3012
3013 CODEGEN_DECL();
3014@@ -76,7 +74,6 @@
3015 :
3016 function(sig, kind)
3017 {
3018-
3019 }
3020
3021 CODEGEN_DECL();
3022@@ -91,7 +88,6 @@
3023 :
3024 function(sig, kind)
3025 {
3026-
3027 }
3028
3029 CODEGEN_DECL();
3030@@ -106,7 +102,6 @@
3031 :
3032 function(sig, kind)
3033 {
3034-
3035 }
3036
3037 CODEGEN_DECL();
3038@@ -121,7 +116,6 @@
3039 :
3040 function(sig, kind)
3041 {
3042-
3043 }
3044
3045 CODEGEN_DECL();
3046@@ -136,7 +130,6 @@
3047 :
3048 function(sig, kind)
3049 {
3050-
3051 }
3052
3053 CODEGEN_DECL();
3054@@ -151,7 +144,6 @@
3055 :
3056 function(sig, kind)
3057 {
3058-
3059 }
3060
3061 CODEGEN_DECL();
3062@@ -166,7 +158,6 @@
3063 :
3064 function(sig, kind)
3065 {
3066-
3067 }
3068
3069 CODEGEN_DECL();
3070@@ -181,7 +172,6 @@
3071 :
3072 function(sig, kind)
3073 {
3074-
3075 }
3076
3077 CODEGEN_DECL();
3078@@ -196,7 +186,6 @@
3079 :
3080 function(sig, kind)
3081 {
3082-
3083 }
3084
3085 CODEGEN_DECL();
3086@@ -211,7 +200,6 @@
3087 :
3088 function(sig, kind)
3089 {
3090-
3091 }
3092
3093 CODEGEN_DECL();
3094@@ -226,7 +214,6 @@
3095 :
3096 function(sig, kind)
3097 {
3098-
3099 }
3100
3101 CODEGEN_DECL();
3102@@ -241,7 +228,6 @@
3103 :
3104 function(sig, kind)
3105 {
3106-
3107 }
3108
3109 CODEGEN_DECL();
3110@@ -256,7 +242,6 @@
3111 :
3112 function(sig, kind)
3113 {
3114-
3115 }
3116
3117 CODEGEN_DECL();
3118@@ -271,7 +256,6 @@
3119 :
3120 function(sig, kind)
3121 {
3122-
3123 }
3124
3125 CODEGEN_DECL();
3126@@ -286,7 +270,6 @@
3127 :
3128 function(sig, kind)
3129 {
3130-
3131 }
3132
3133 CODEGEN_DECL();
3134@@ -301,7 +284,6 @@
3135 :
3136 function(sig, kind)
3137 {
3138-
3139 }
3140
3141 CODEGEN_DECL();
3142@@ -316,7 +298,6 @@
3143 :
3144 function(sig, kind)
3145 {
3146-
3147 }
3148
3149 CODEGEN_DECL();
3150@@ -331,7 +312,6 @@
3151 :
3152 function(sig, kind)
3153 {
3154-
3155 }
3156
3157 CODEGEN_DECL();
3158@@ -346,7 +326,6 @@
3159 :
3160 function(sig, kind)
3161 {
3162-
3163 }
3164
3165 CODEGEN_DECL();
3166@@ -361,7 +340,6 @@
3167 :
3168 function(sig, kind)
3169 {
3170-
3171 }
3172
3173 CODEGEN_DECL();
3174@@ -376,7 +354,6 @@
3175 :
3176 function(sig, kind)
3177 {
3178-
3179 }
3180
3181 CODEGEN_DECL();
3182@@ -391,7 +368,6 @@
3183 :
3184 function(sig, kind)
3185 {
3186-
3187 }
3188
3189 CODEGEN_DECL();
3190
3191=== modified file 'src/functions/pregenerated/func_nodes.h'
3192--- src/functions/pregenerated/func_nodes.h 2013-07-24 08:12:12 +0000
3193+++ src/functions/pregenerated/func_nodes.h 2013-09-11 19:02:46 +0000
3194@@ -46,7 +46,6 @@
3195 :
3196 function(sig, kind)
3197 {
3198-
3199 }
3200
3201 bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
3202@@ -63,7 +62,6 @@
3203 :
3204 function(sig, kind)
3205 {
3206-
3207 }
3208
3209 bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
3210@@ -80,7 +78,6 @@
3211 :
3212 function(sig, kind)
3213 {
3214-
3215 }
3216
3217 bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
3218@@ -97,7 +94,6 @@
3219 :
3220 function(sig, kind)
3221 {
3222-
3223 }
3224
3225 CODEGEN_DECL();
3226@@ -112,7 +108,7 @@
3227 :
3228 function(sig, kind)
3229 {
3230-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
3231+ theXQueryVersion = StaticContextConsts::xquery_version_3_0;
3232 }
3233
3234 bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
3235@@ -129,7 +125,7 @@
3236 :
3237 function(sig, kind)
3238 {
3239-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
3240+ theXQueryVersion = StaticContextConsts::xquery_version_3_0;
3241 }
3242
3243 bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
3244@@ -146,7 +142,7 @@
3245 :
3246 function(sig, kind)
3247 {
3248-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
3249+ theXQueryVersion = StaticContextConsts::xquery_version_3_0;
3250 }
3251
3252 bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
3253@@ -163,7 +159,7 @@
3254 :
3255 function(sig, kind)
3256 {
3257-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
3258+ theXQueryVersion = StaticContextConsts::xquery_version_3_0;
3259 }
3260
3261 bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
3262@@ -180,7 +176,6 @@
3263 :
3264 function(sig, kind)
3265 {
3266-
3267 }
3268
3269 bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
3270@@ -197,7 +192,6 @@
3271 :
3272 function(sig, kind)
3273 {
3274-
3275 }
3276
3277 bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
3278@@ -214,7 +208,6 @@
3279 :
3280 function(sig, kind)
3281 {
3282-
3283 }
3284
3285 bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
3286@@ -231,7 +224,6 @@
3287 :
3288 function(sig, kind)
3289 {
3290-
3291 }
3292
3293 bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
3294@@ -248,7 +240,6 @@
3295 :
3296 function(sig, kind)
3297 {
3298-
3299 }
3300
3301 bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
3302@@ -265,7 +256,6 @@
3303 :
3304 function(sig, kind)
3305 {
3306-
3307 }
3308
3309 bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
3310@@ -282,7 +272,6 @@
3311 :
3312 function(sig, kind)
3313 {
3314-
3315 }
3316
3317 bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
3318@@ -299,7 +288,6 @@
3319 :
3320 function(sig, kind)
3321 {
3322-
3323 }
3324
3325 bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
3326@@ -316,7 +304,6 @@
3327 :
3328 function(sig, kind)
3329 {
3330-
3331 }
3332
3333 bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
3334@@ -333,7 +320,6 @@
3335 :
3336 function(sig, kind)
3337 {
3338-
3339 }
3340
3341 bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
3342@@ -350,7 +336,7 @@
3343 :
3344 function(sig, kind)
3345 {
3346-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
3347+ theXQueryVersion = StaticContextConsts::xquery_version_3_0;
3348 }
3349
3350 CODEGEN_DECL();
3351@@ -365,7 +351,6 @@
3352 :
3353 function(sig, kind)
3354 {
3355-
3356 }
3357
3358 bool mustCopyInputNodes(expr* fo, csize producer) const;
3359
3360=== modified file 'src/functions/pregenerated/func_numerics.h'
3361--- src/functions/pregenerated/func_numerics.h 2013-03-05 23:11:50 +0000
3362+++ src/functions/pregenerated/func_numerics.h 2013-09-11 19:02:46 +0000
3363@@ -46,7 +46,6 @@
3364 :
3365 function(sig, kind)
3366 {
3367-
3368 }
3369
3370 CODEGEN_DECL();
3371@@ -61,7 +60,6 @@
3372 :
3373 function(sig, kind)
3374 {
3375-
3376 }
3377
3378 CODEGEN_DECL();
3379@@ -76,7 +74,6 @@
3380 :
3381 function(sig, kind)
3382 {
3383-
3384 }
3385
3386 xqtref_t getReturnType(const fo_expr* caller) const;
3387@@ -93,7 +90,7 @@
3388 :
3389 function(sig, kind)
3390 {
3391-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
3392+ theXQueryVersion = StaticContextConsts::xquery_version_3_0;
3393 }
3394
3395 CODEGEN_DECL();
3396@@ -107,7 +104,6 @@
3397 :
3398 function(sig, kind)
3399 {
3400-
3401 }
3402
3403 CODEGEN_DECL();
3404@@ -122,7 +118,6 @@
3405 :
3406 function(sig, kind)
3407 {
3408-
3409 }
3410
3411 CODEGEN_DECL();
3412@@ -137,7 +132,7 @@
3413 :
3414 function(sig, kind)
3415 {
3416-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
3417+ theXQueryVersion = StaticContextConsts::xquery_version_3_0;
3418 }
3419
3420 CODEGEN_DECL();
3421@@ -152,7 +147,7 @@
3422 :
3423 function(sig, kind)
3424 {
3425-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
3426+ theXQueryVersion = StaticContextConsts::xquery_version_3_0;
3427 }
3428
3429 CODEGEN_DECL();
3430
3431=== modified file 'src/functions/pregenerated/func_other_diagnostics.h'
3432--- src/functions/pregenerated/func_other_diagnostics.h 2013-03-05 23:11:50 +0000
3433+++ src/functions/pregenerated/func_other_diagnostics.h 2013-09-11 19:02:46 +0000
3434@@ -46,7 +46,6 @@
3435 :
3436 function(sig, kind)
3437 {
3438-
3439 }
3440
3441 bool accessesDynCtx() const { return true; }
3442@@ -63,7 +62,6 @@
3443 :
3444 function(sig, kind)
3445 {
3446-
3447 }
3448
3449 bool accessesDynCtx() const { return true; }
3450
3451=== modified file 'src/functions/pregenerated/func_parse_fragment.h'
3452--- src/functions/pregenerated/func_parse_fragment.h 2013-03-06 07:39:18 +0000
3453+++ src/functions/pregenerated/func_parse_fragment.h 2013-09-11 19:02:46 +0000
3454@@ -46,7 +46,6 @@
3455 :
3456 function(sig, kind)
3457 {
3458-
3459 }
3460
3461 bool accessesDynCtx() const { return true; }
3462@@ -63,7 +62,6 @@
3463 :
3464 function(sig, kind)
3465 {
3466-
3467 }
3468
3469 CODEGEN_DECL();
3470@@ -78,7 +76,7 @@
3471 :
3472 function(sig, kind)
3473 {
3474-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
3475+ theXQueryVersion = StaticContextConsts::xquery_version_3_0;
3476 }
3477
3478 bool accessesDynCtx() const { return true; }
3479
3480=== modified file 'src/functions/pregenerated/func_parsing_and_serializing.h'
3481--- src/functions/pregenerated/func_parsing_and_serializing.h 2013-03-05 23:11:50 +0000
3482+++ src/functions/pregenerated/func_parsing_and_serializing.h 2013-09-11 19:02:46 +0000
3483@@ -46,7 +46,7 @@
3484 :
3485 function(sig, kind)
3486 {
3487-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
3488+ theXQueryVersion = StaticContextConsts::xquery_version_3_0;
3489 }
3490
3491 bool accessesDynCtx() const { return true; }
3492@@ -65,7 +65,8 @@
3493 :
3494 function(sig, kind)
3495 {
3496-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
3497+ theXQueryVersion = StaticContextConsts::xquery_version_3_0;
3498+ addAnnotation(AnnotationInternal::zann_explores_json);
3499 }
3500
3501 bool accessesDynCtx() const { return true; }
3502
3503=== modified file 'src/functions/pregenerated/func_qnames.h'
3504--- src/functions/pregenerated/func_qnames.h 2013-03-05 23:11:50 +0000
3505+++ src/functions/pregenerated/func_qnames.h 2013-09-11 19:02:46 +0000
3506@@ -46,7 +46,6 @@
3507 :
3508 function(sig, kind)
3509 {
3510-
3511 }
3512
3513 bool mustCopyInputNodes(expr* fo, csize producer) const { return producer == 1; }
3514@@ -63,7 +62,6 @@
3515 :
3516 function(sig, kind)
3517 {
3518-
3519 }
3520
3521 CODEGEN_DECL();
3522@@ -78,7 +76,6 @@
3523 :
3524 function(sig, kind)
3525 {
3526-
3527 }
3528
3529 CODEGEN_DECL();
3530@@ -93,7 +90,6 @@
3531 :
3532 function(sig, kind)
3533 {
3534-
3535 }
3536
3537 CODEGEN_DECL();
3538@@ -108,7 +104,6 @@
3539 :
3540 function(sig, kind)
3541 {
3542-
3543 }
3544
3545 CODEGEN_DECL();
3546@@ -123,7 +118,6 @@
3547 :
3548 function(sig, kind)
3549 {
3550-
3551 }
3552
3553 CODEGEN_DECL();
3554@@ -138,7 +132,6 @@
3555 :
3556 function(sig, kind)
3557 {
3558-
3559 }
3560
3561 bool mustCopyInputNodes(expr* fo, csize producer) const { return producer == 1; }
3562@@ -155,7 +148,6 @@
3563 :
3564 function(sig, kind)
3565 {
3566-
3567 }
3568
3569 bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
3570
3571=== modified file 'src/functions/pregenerated/func_random.h'
3572--- src/functions/pregenerated/func_random.h 2013-03-05 23:11:50 +0000
3573+++ src/functions/pregenerated/func_random.h 2013-09-11 19:02:46 +0000
3574@@ -46,7 +46,6 @@
3575 :
3576 function(sig, kind)
3577 {
3578-
3579 }
3580
3581 CODEGEN_DECL();
3582@@ -61,7 +60,6 @@
3583 :
3584 function(sig, kind)
3585 {
3586-
3587 }
3588
3589 CODEGEN_DECL();
3590@@ -77,7 +75,6 @@
3591 function(sig, kind)
3592 {
3593 setDeterministic(false);
3594-
3595 }
3596
3597 CODEGEN_DECL();
3598
3599=== modified file 'src/functions/pregenerated/func_reference.h'
3600--- src/functions/pregenerated/func_reference.h 2013-03-05 23:11:50 +0000
3601+++ src/functions/pregenerated/func_reference.h 2013-09-11 19:02:46 +0000
3602@@ -46,7 +46,6 @@
3603 :
3604 function(sig, kind)
3605 {
3606-
3607 }
3608
3609 bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
3610@@ -63,7 +62,6 @@
3611 :
3612 function(sig, kind)
3613 {
3614-
3615 }
3616
3617 CODEGEN_DECL();
3618@@ -78,7 +76,6 @@
3619 :
3620 function(sig, kind)
3621 {
3622-
3623 }
3624
3625 unsigned short getScriptingKind() const { return SEQUENTIAL_FUNC_EXPR; }
3626@@ -95,7 +92,6 @@
3627 :
3628 function(sig, kind)
3629 {
3630-
3631 }
3632
3633 CODEGEN_DECL();
3634
3635=== modified file 'src/functions/pregenerated/func_schema.h'
3636--- src/functions/pregenerated/func_schema.h 2013-03-05 23:11:50 +0000
3637+++ src/functions/pregenerated/func_schema.h 2013-09-11 19:02:46 +0000
3638@@ -46,7 +46,6 @@
3639 :
3640 function(sig, kind)
3641 {
3642-
3643 }
3644
3645 unsigned short getScriptingKind() const { return UPDATING_EXPR; }
3646@@ -67,7 +66,6 @@
3647 :
3648 function(sig, kind)
3649 {
3650-
3651 }
3652
3653 bool mustCopyInputNodes(expr* fo, csize producer) const;
3654@@ -84,7 +82,6 @@
3655 :
3656 function(sig, kind)
3657 {
3658-
3659 }
3660
3661 bool mustCopyInputNodes(expr* fo, csize producer) const;
3662
3663=== modified file 'src/functions/pregenerated/func_sctx.h'
3664--- src/functions/pregenerated/func_sctx.h 2013-03-05 23:11:50 +0000
3665+++ src/functions/pregenerated/func_sctx.h 2013-09-11 19:02:46 +0000
3666@@ -46,7 +46,6 @@
3667 :
3668 function(sig, kind)
3669 {
3670-
3671 }
3672
3673 CODEGEN_DECL();
3674@@ -61,7 +60,6 @@
3675 :
3676 function(sig, kind)
3677 {
3678-
3679 }
3680
3681 CODEGEN_DECL();
3682@@ -76,7 +74,6 @@
3683 :
3684 function(sig, kind)
3685 {
3686-
3687 }
3688
3689 CODEGEN_DECL();
3690@@ -91,7 +88,6 @@
3691 :
3692 function(sig, kind)
3693 {
3694-
3695 }
3696
3697 CODEGEN_DECL();
3698@@ -106,7 +102,6 @@
3699 :
3700 function(sig, kind)
3701 {
3702-
3703 }
3704
3705 CODEGEN_DECL();
3706@@ -121,7 +116,6 @@
3707 :
3708 function(sig, kind)
3709 {
3710-
3711 }
3712
3713 CODEGEN_DECL();
3714@@ -136,7 +130,6 @@
3715 :
3716 function(sig, kind)
3717 {
3718-
3719 }
3720
3721 CODEGEN_DECL();
3722@@ -151,7 +144,6 @@
3723 :
3724 function(sig, kind)
3725 {
3726-
3727 }
3728
3729 CODEGEN_DECL();
3730@@ -166,7 +158,6 @@
3731 :
3732 function(sig, kind)
3733 {
3734-
3735 }
3736
3737 CODEGEN_DECL();
3738@@ -181,7 +172,6 @@
3739 :
3740 function(sig, kind)
3741 {
3742-
3743 }
3744
3745 CODEGEN_DECL();
3746@@ -196,7 +186,6 @@
3747 :
3748 function(sig, kind)
3749 {
3750-
3751 }
3752
3753 CODEGEN_DECL();
3754@@ -211,7 +200,6 @@
3755 :
3756 function(sig, kind)
3757 {
3758-
3759 }
3760
3761 CODEGEN_DECL();
3762@@ -226,7 +214,6 @@
3763 :
3764 function(sig, kind)
3765 {
3766-
3767 }
3768
3769 CODEGEN_DECL();
3770@@ -241,7 +228,6 @@
3771 :
3772 function(sig, kind)
3773 {
3774-
3775 }
3776
3777 CODEGEN_DECL();
3778@@ -256,7 +242,6 @@
3779 :
3780 function(sig, kind)
3781 {
3782-
3783 }
3784
3785 CODEGEN_DECL();
3786@@ -271,7 +256,6 @@
3787 :
3788 function(sig, kind)
3789 {
3790-
3791 }
3792
3793 CODEGEN_DECL();
3794@@ -286,7 +270,6 @@
3795 :
3796 function(sig, kind)
3797 {
3798-
3799 }
3800
3801 CODEGEN_DECL();
3802@@ -301,7 +284,6 @@
3803 :
3804 function(sig, kind)
3805 {
3806-
3807 }
3808
3809 CODEGEN_DECL();
3810@@ -316,7 +298,6 @@
3811 :
3812 function(sig, kind)
3813 {
3814-
3815 }
3816
3817 CODEGEN_DECL();
3818@@ -331,7 +312,6 @@
3819 :
3820 function(sig, kind)
3821 {
3822-
3823 }
3824
3825 CODEGEN_DECL();
3826@@ -346,7 +326,6 @@
3827 :
3828 function(sig, kind)
3829 {
3830-
3831 }
3832
3833 CODEGEN_DECL();
3834@@ -361,7 +340,6 @@
3835 :
3836 function(sig, kind)
3837 {
3838-
3839 }
3840
3841 CODEGEN_DECL();
3842@@ -376,7 +354,6 @@
3843 :
3844 function(sig, kind)
3845 {
3846-
3847 }
3848
3849 CODEGEN_DECL();
3850@@ -391,7 +368,6 @@
3851 :
3852 function(sig, kind)
3853 {
3854-
3855 }
3856
3857 CODEGEN_DECL();
3858@@ -406,7 +382,6 @@
3859 :
3860 function(sig, kind)
3861 {
3862-
3863 }
3864
3865 CODEGEN_DECL();
3866
3867=== modified file 'src/functions/pregenerated/func_sequences.h'
3868--- src/functions/pregenerated/func_sequences.h 2013-03-05 23:11:50 +0000
3869+++ src/functions/pregenerated/func_sequences.h 2013-09-11 19:02:46 +0000
3870@@ -46,7 +46,6 @@
3871 :
3872 function(sig, kind)
3873 {
3874-
3875 }
3876
3877 xqtref_t getReturnType(const fo_expr* caller) const;
3878@@ -69,7 +68,6 @@
3879 :
3880 function(sig, kind)
3881 {
3882-
3883 }
3884
3885 CODEGEN_DECL();
3886@@ -84,7 +82,6 @@
3887 :
3888 function(sig, kind)
3889 {
3890-
3891 }
3892
3893 BoolAnnotationValue ignoresSortedNodes(expr* fo, csize producer) const;
3894@@ -105,7 +102,6 @@
3895 :
3896 function(sig, kind)
3897 {
3898-
3899 }
3900
3901 BoolAnnotationValue ignoresSortedNodes(expr* fo, csize producer) const;
3902@@ -126,7 +122,6 @@
3903 :
3904 function(sig, kind)
3905 {
3906-
3907 }
3908
3909 xqtref_t getReturnType(const fo_expr* caller) const;
3910@@ -147,7 +142,6 @@
3911 :
3912 function(sig, kind)
3913 {
3914-
3915 }
3916
3917 xqtref_t getReturnType(const fo_expr* caller) const;
3918@@ -170,7 +164,6 @@
3919 :
3920 function(sig, kind)
3921 {
3922-
3923 }
3924
3925 xqtref_t getReturnType(const fo_expr* caller) const;
3926@@ -197,7 +190,6 @@
3927 :
3928 function(sig, kind)
3929 {
3930-
3931 }
3932
3933 xqtref_t getReturnType(const fo_expr* caller) const;
3934@@ -222,7 +214,6 @@
3935 :
3936 function(sig, kind)
3937 {
3938-
3939 }
3940
3941 xqtref_t getReturnType(const fo_expr* caller) const;
3942@@ -247,7 +238,6 @@
3943 :
3944 function(sig, kind)
3945 {
3946-
3947 }
3948
3949 xqtref_t getReturnType(const fo_expr* caller) const;
3950@@ -270,7 +260,6 @@
3951 :
3952 function(sig, kind)
3953 {
3954-
3955 }
3956
3957 xqtref_t getReturnType(const fo_expr* caller) const;
3958@@ -293,7 +282,6 @@
3959 :
3960 function(sig, kind)
3961 {
3962-
3963 }
3964
3965 xqtref_t getReturnType(const fo_expr* caller) const;
3966@@ -314,7 +302,6 @@
3967 :
3968 function(sig, kind)
3969 {
3970-
3971 }
3972
3973 xqtref_t getReturnType(const fo_expr* caller) const;
3974@@ -343,7 +330,6 @@
3975 :
3976 function(sig, kind)
3977 {
3978-
3979 }
3980
3981 bool accessesDynCtx() const { return true; }
3982@@ -362,7 +348,6 @@
3983 :
3984 function(sig, kind)
3985 {
3986-
3987 }
3988
3989 BoolAnnotationValue ignoresSortedNodes(expr* fo, csize producer) const;
3990@@ -381,7 +366,6 @@
3991 :
3992 function(sig, kind)
3993 {
3994-
3995 }
3996
3997 BoolAnnotationValue ignoresSortedNodes(expr* fo, csize producer) const;
3998@@ -398,7 +382,6 @@
3999 :
4000 function(sig, kind)
4001 {
4002-
4003 }
4004
4005 bool specializable() const { return true; }
4006@@ -420,7 +403,6 @@
4007 :
4008 function(sig, kind)
4009 {
4010-
4011 }
4012
4013 BoolAnnotationValue ignoresSortedNodes(expr* fo, csize producer) const;
4014@@ -437,7 +419,6 @@
4015 :
4016 function(sig, kind)
4017 {
4018-
4019 }
4020
4021 BoolAnnotationValue ignoresSortedNodes(expr* fo, csize producer) const;
4022@@ -454,7 +435,6 @@
4023 :
4024 function(sig, kind)
4025 {
4026-
4027 }
4028
4029 BoolAnnotationValue ignoresSortedNodes(expr* fo, csize producer) const;
4030@@ -471,7 +451,6 @@
4031 :
4032 function(sig, kind)
4033 {
4034-
4035 }
4036
4037 BoolAnnotationValue ignoresSortedNodes(expr* fo, csize producer) const;
4038@@ -488,7 +467,6 @@
4039 :
4040 function(sig, kind)
4041 {
4042-
4043 }
4044
4045 CODEGEN_DECL();
4046@@ -503,7 +481,6 @@
4047 :
4048 function(sig, kind)
4049 {
4050-
4051 }
4052
4053 FunctionConsts::AnnotationValue producesDistinctNodes() const
4054@@ -534,7 +511,6 @@
4055 :
4056 function(sig, kind)
4057 {
4058-
4059 }
4060
4061 FunctionConsts::AnnotationValue producesDistinctNodes() const
4062@@ -565,7 +541,6 @@
4063 :
4064 function(sig, kind)
4065 {
4066-
4067 }
4068
4069 FunctionConsts::AnnotationValue producesDistinctNodes() const
4070@@ -596,7 +571,6 @@
4071 :
4072 function(sig, kind)
4073 {
4074-
4075 }
4076
4077 bool accessesDynCtx() const { return true; }
4078@@ -615,7 +589,6 @@
4079 :
4080 function(sig, kind)
4081 {
4082-
4083 }
4084
4085 CODEGEN_DECL();
4086@@ -630,7 +603,7 @@
4087 :
4088 function(sig, kind)
4089 {
4090-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
4091+ theXQueryVersion = StaticContextConsts::xquery_version_3_0;
4092 }
4093
4094 CODEGEN_DECL();
4095@@ -645,7 +618,7 @@
4096 :
4097 function(sig, kind)
4098 {
4099-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
4100+ theXQueryVersion = StaticContextConsts::xquery_version_3_0;
4101 }
4102
4103 CODEGEN_DECL();
4104@@ -660,7 +633,7 @@
4105 :
4106 function(sig, kind)
4107 {
4108-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
4109+ theXQueryVersion = StaticContextConsts::xquery_version_3_0;
4110 }
4111
4112 CODEGEN_DECL();
4113@@ -675,7 +648,7 @@
4114 :
4115 function(sig, kind)
4116 {
4117-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
4118+ theXQueryVersion = StaticContextConsts::xquery_version_3_0;
4119 }
4120
4121 CODEGEN_DECL();
4122@@ -690,7 +663,7 @@
4123 :
4124 function(sig, kind)
4125 {
4126-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
4127+ theXQueryVersion = StaticContextConsts::xquery_version_3_0;
4128 }
4129
4130 CODEGEN_DECL();
4131
4132=== modified file 'src/functions/pregenerated/func_strings.h'
4133--- src/functions/pregenerated/func_strings.h 2013-07-11 22:08:29 +0000
4134+++ src/functions/pregenerated/func_strings.h 2013-09-11 19:02:46 +0000
4135@@ -46,7 +46,6 @@
4136 :
4137 function(sig, kind)
4138 {
4139-
4140 }
4141
4142 CODEGEN_DECL();
4143@@ -61,7 +60,6 @@
4144 :
4145 function(sig, kind)
4146 {
4147-
4148 }
4149
4150 CODEGEN_DECL();
4151@@ -76,7 +74,6 @@
4152 :
4153 function(sig, kind)
4154 {
4155-
4156 }
4157
4158 CODEGEN_DECL();
4159@@ -91,7 +88,6 @@
4160 :
4161 function(sig, kind)
4162 {
4163-
4164 }
4165
4166 CODEGEN_DECL();
4167@@ -106,7 +102,6 @@
4168 :
4169 function(sig, kind)
4170 {
4171-
4172 }
4173
4174 BoolAnnotationValue ignoresSortedNodes(expr* fo, csize producer) const;
4175@@ -125,7 +120,7 @@
4176 :
4177 function(sig, kind)
4178 {
4179-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
4180+ theXQueryVersion = StaticContextConsts::xquery_version_3_0;
4181 }
4182
4183 CODEGEN_DECL();
4184@@ -139,7 +134,6 @@
4185 :
4186 function(sig, kind)
4187 {
4188-
4189 }
4190
4191 CODEGEN_DECL();
4192@@ -154,7 +148,6 @@
4193 :
4194 function(sig, kind)
4195 {
4196-
4197 }
4198
4199 bool specializable() const { return true; }
4200@@ -174,7 +167,6 @@
4201 :
4202 function(sig, kind)
4203 {
4204-
4205 }
4206
4207 CODEGEN_DECL();
4208@@ -189,7 +181,6 @@
4209 :
4210 function(sig, kind)
4211 {
4212-
4213 }
4214
4215 CODEGEN_DECL();
4216@@ -204,7 +195,6 @@
4217 :
4218 function(sig, kind)
4219 {
4220-
4221 }
4222
4223 CODEGEN_DECL();
4224@@ -219,7 +209,6 @@
4225 :
4226 function(sig, kind)
4227 {
4228-
4229 }
4230
4231 CODEGEN_DECL();
4232@@ -234,7 +223,6 @@
4233 :
4234 function(sig, kind)
4235 {
4236-
4237 }
4238
4239 CODEGEN_DECL();
4240@@ -249,7 +237,6 @@
4241 :
4242 function(sig, kind)
4243 {
4244-
4245 }
4246
4247 CODEGEN_DECL();
4248@@ -264,7 +251,6 @@
4249 :
4250 function(sig, kind)
4251 {
4252-
4253 }
4254
4255 CODEGEN_DECL();
4256@@ -279,7 +265,6 @@
4257 :
4258 function(sig, kind)
4259 {
4260-
4261 }
4262
4263 CODEGEN_DECL();
4264@@ -294,7 +279,6 @@
4265 :
4266 function(sig, kind)
4267 {
4268-
4269 }
4270
4271 CODEGEN_DECL();
4272@@ -309,7 +293,6 @@
4273 :
4274 function(sig, kind)
4275 {
4276-
4277 }
4278
4279 CODEGEN_DECL();
4280@@ -324,7 +307,6 @@
4281 :
4282 function(sig, kind)
4283 {
4284-
4285 }
4286
4287 CODEGEN_DECL();
4288@@ -339,7 +321,6 @@
4289 :
4290 function(sig, kind)
4291 {
4292-
4293 }
4294
4295 CODEGEN_DECL();
4296@@ -354,7 +335,6 @@
4297 :
4298 function(sig, kind)
4299 {
4300-
4301 }
4302
4303 CODEGEN_DECL();
4304@@ -369,7 +349,6 @@
4305 :
4306 function(sig, kind)
4307 {
4308-
4309 }
4310
4311 CODEGEN_DECL();
4312@@ -384,7 +363,6 @@
4313 :
4314 function(sig, kind)
4315 {
4316-
4317 }
4318
4319 CODEGEN_DECL();
4320@@ -399,7 +377,6 @@
4321 :
4322 function(sig, kind)
4323 {
4324-
4325 }
4326
4327 CODEGEN_DECL();
4328@@ -414,7 +391,6 @@
4329 :
4330 function(sig, kind)
4331 {
4332-
4333 }
4334
4335 CODEGEN_DECL();
4336@@ -429,7 +405,6 @@
4337 :
4338 function(sig, kind)
4339 {
4340-
4341 }
4342
4343 CODEGEN_DECL();
4344@@ -444,7 +419,7 @@
4345 :
4346 function(sig, kind)
4347 {
4348-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
4349+ theXQueryVersion = StaticContextConsts::xquery_version_3_0;
4350 }
4351
4352 CODEGEN_DECL();
4353@@ -459,7 +434,6 @@
4354 :
4355 function(sig, kind)
4356 {
4357-
4358 }
4359
4360 CODEGEN_DECL();
4361@@ -474,7 +448,6 @@
4362 :
4363 function(sig, kind)
4364 {
4365-
4366 }
4367
4368 CODEGEN_DECL();
4369@@ -489,7 +462,6 @@
4370 :
4371 function(sig, kind)
4372 {
4373-
4374 }
4375
4376 CODEGEN_DECL();
4377@@ -504,7 +476,6 @@
4378 :
4379 function(sig, kind)
4380 {
4381-
4382 }
4383
4384 CODEGEN_DECL();
4385
4386=== modified file 'src/functions/pregenerated/func_uris.h'
4387--- src/functions/pregenerated/func_uris.h 2013-04-12 21:25:35 +0000
4388+++ src/functions/pregenerated/func_uris.h 2013-09-11 19:02:46 +0000
4389@@ -46,7 +46,6 @@
4390 :
4391 function(sig, kind)
4392 {
4393-
4394 }
4395
4396 CODEGEN_DECL();
4397@@ -61,7 +60,6 @@
4398 :
4399 function(sig, kind)
4400 {
4401-
4402 }
4403
4404 CODEGEN_DECL();
4405@@ -76,7 +74,6 @@
4406 :
4407 function(sig, kind)
4408 {
4409-
4410 }
4411
4412 CODEGEN_DECL();
4413
4414=== modified file 'src/functions/pregenerated/func_xqdoc.h'
4415--- src/functions/pregenerated/func_xqdoc.h 2013-03-05 23:11:50 +0000
4416+++ src/functions/pregenerated/func_xqdoc.h 2013-09-11 19:02:46 +0000
4417@@ -46,7 +46,6 @@
4418 :
4419 function(sig, kind)
4420 {
4421-
4422 }
4423
4424 CODEGEN_DECL();
4425@@ -61,7 +60,6 @@
4426 :
4427 function(sig, kind)
4428 {
4429-
4430 }
4431
4432 CODEGEN_DECL();
4433
4434=== modified file 'src/runtime/collections/collections_impl.cpp'
4435--- src/runtime/collections/collections_impl.cpp 2013-07-25 14:09:47 +0000
4436+++ src/runtime/collections/collections_impl.cpp 2013-09-11 19:02:46 +0000
4437@@ -61,8 +61,9 @@
4438 const static_context* sctx,
4439 const store::Item_t& name,
4440 const QueryLoc& loc,
4441- bool dynamic,
4442- store::Collection_t& coll)
4443+ bool dynamic,
4444+ store::Collection_t& coll,
4445+ store::Item_t dataguide = NULL)
4446 {
4447 const StaticallyKnownCollection* collectionDecl = sctx->lookup_collection(name);
4448
4449@@ -72,7 +73,7 @@
4450 ERROR_PARAMS(name->getStringValue()));
4451 }
4452
4453- coll = GENV_STORE.getCollection(name, dynamic);
4454+ coll = GENV_STORE.getCollection(name, dynamic, dataguide);
4455
4456 if (coll == NULL)
4457 {
4458@@ -287,7 +288,7 @@
4459
4460 consumeNext(name, theChildren[0].getp(), planState);
4461
4462- (void)getCollection(theSctx, name, loc, theIsDynamic, collection);
4463+ (void)getCollection(theSctx, name, loc, theIsDynamic, collection, theDataguide);
4464
4465 if (theChildren.size() == 1)
4466 {
4467
4468=== modified file 'src/runtime/collections/pregenerated/collections.cpp'
4469--- src/runtime/collections/pregenerated/collections.cpp 2013-03-05 23:11:50 +0000
4470+++ src/runtime/collections/pregenerated/collections.cpp 2013-09-11 19:02:46 +0000
4471@@ -194,6 +194,7 @@
4472 (NaryBaseIterator<ZorbaCollectionIterator, ZorbaCollectionIteratorState>*)this);
4473
4474 ar & theIsDynamic;
4475+ ar & theDataguide;
4476 }
4477
4478
4479
4480=== modified file 'src/runtime/collections/pregenerated/collections.h'
4481--- src/runtime/collections/pregenerated/collections.h 2013-07-15 10:32:25 +0000
4482+++ src/runtime/collections/pregenerated/collections.h 2013-09-11 19:02:46 +0000
4483@@ -266,6 +266,7 @@
4484 {
4485 protected:
4486 bool theIsDynamic; //
4487+ store::Item_t theDataguide; //
4488 public:
4489 SERIALIZABLE_CLASS(ZorbaCollectionIterator);
4490
4491@@ -281,13 +282,16 @@
4492 bool isDynamic)
4493 :
4494 NaryBaseIterator<ZorbaCollectionIterator, ZorbaCollectionIteratorState>(sctx, loc, children),
4495- theIsDynamic(isDynamic)
4496+ theIsDynamic(isDynamic),
4497+ theDataguide()
4498 {}
4499
4500 virtual ~ZorbaCollectionIterator();
4501
4502 bool isDynamic() const { return theIsDynamic; }
4503
4504+ void setDataguide(store::Item_t aValue) { theDataguide= aValue; }
4505+
4506 public:
4507 bool isCountOptimizable() const;
4508 bool count(store::Item_t& result, PlanState& planState) const;
4509
4510=== modified file 'src/runtime/json/json_loader.cpp'
4511--- src/runtime/json/json_loader.cpp 2013-06-19 15:35:24 +0000
4512+++ src/runtime/json/json_loader.cpp 2013-09-11 19:02:46 +0000
4513@@ -20,6 +20,7 @@
4514 // Zorba
4515 #include <store/api/item.h>
4516 #include <store/api/store.h>
4517+#include <store/api/iterator.h>
4518 #include <zorba/store_consts.h>
4519
4520 #include "context/static_context.h"
4521@@ -40,9 +41,13 @@
4522 namespace zorba {
4523 namespace json {
4524
4525+
4526 ///////////////////////////////////////////////////////////////////////////////
4527
4528-loader::stack_element::stack_element( type t ) : type_( t ) {
4529+loader::stack_element::stack_element( type t )
4530+ :
4531+ type_( t ), dataguide_( nullptr )
4532+{
4533 switch ( type_ ) {
4534 case array_type:
4535 array_ = new json_array_type;
4536@@ -80,17 +85,47 @@
4537
4538 ///////////////////////////////////////////////////////////////////////////////
4539
4540-loader::loader( istream &is, bool allow_multiple, bool strip_top_level_array ) :
4541+loader::loader( istream &is, bool allow_multiple, bool strip_top_level_array, const store::Item *aDataguide) :
4542 parser_( is, allow_multiple ),
4543 strip_top_level_array_( strip_top_level_array ),
4544- stripped_top_level_array_( false )
4545+ stripped_top_level_array_( false ),
4546+ dataguide_(aDataguide),
4547+ skip_next_level_(0)
4548 {
4549+ if (aDataguide)
4550+ {
4551+ zstring s = "*";
4552+ GENV_ITEMFACTORY->createString( dataguide_star_, s );
4553+ }
4554 }
4555
4556 loader::~loader() {
4557 clear_stack();
4558 }
4559
4560+
4561+///////////////////////////////////////////////////////////////////////////////
4562+// Dataguide manipulation
4563+///////////////////////////////////////////////////////////////////////////////
4564+bool loader::contains(const store::Item* dataguide, store::Item_t const& a_key)
4565+{
4566+ if (dataguide == nullptr || (dataguide->isAtomic() && dataguide_star_->equals(dataguide)))
4567+ return true;
4568+
4569+ assert(dataguide->isObject());
4570+
4571+ store::Iterator_t it = dataguide->getObjectKeys();
4572+ it->open();
4573+
4574+ store::Item_t key;
4575+ while (it->next(key))
4576+ if (key->equals(a_key))
4577+ return true;
4578+
4579+ return false;
4580+}
4581+
4582+
4583 void loader::add_value( store::Item_t const &value ) {
4584 stack_element top( stack_.top() );
4585 switch ( top.type_ ) {
4586@@ -102,8 +137,20 @@
4587 // value must be a string that's the name of the object's next key/value
4588 // pair.
4589 //
4590- push( stack_element::key_type ).key_ = value.getp();
4591- value->addReference();
4592+ if (!value->isAtomic() || contains(top.dataguide_, value))
4593+ {
4594+ push( stack_element::key_type ).key_ = value.getp();
4595+ value->addReference();
4596+
4597+ if (top.dataguide_ && top.dataguide_->equals(dataguide_star_))
4598+ stack_.top().dataguide_ = dataguide_star_;
4599+ else if (value->isAtomic() && top.dataguide_)
4600+ stack_.top().dataguide_ = top.dataguide_->getObjectValue(value);
4601+ }
4602+ else
4603+ {
4604+ skip_next_level_ = 1;
4605+ }
4606 break;
4607 case stack_element::key_type: {
4608 //
4609@@ -116,7 +163,7 @@
4610 assert( top2.type_ == stack_element::object_type );
4611 top2.object_->keys_.push_back( top.key_ );
4612 top2.object_->values_.push_back( value );
4613- top.destroy();
4614+ top.destroy();
4615 break;
4616 }
4617 default:
4618@@ -128,6 +175,8 @@
4619 parser_.clear();
4620 clear_stack();
4621 stripped_top_level_array_ = false;
4622+ dataguide_ = nullptr;
4623+ skip_next_level_ = 0;
4624 }
4625
4626 void loader::clear_stack() {
4627@@ -141,25 +190,48 @@
4628 store::Item_t item;
4629 zstring s;
4630 json::token t;
4631+ const store::Item* top_dg;
4632
4633 try {
4634 while ( parser_.next( &t ) ) {
4635 switch( t.get_type() ) {
4636 case '[':
4637+ if (skip_next_level_)
4638+ {
4639+ skip_next_level_++;
4640+ continue;
4641+ }
4642 if ( strip_top_level_array_ && !stripped_top_level_array_ )
4643 stripped_top_level_array_ = true;
4644 else
4645 push( stack_element::array_type );
4646 continue;
4647 case '{':
4648+ if (skip_next_level_)
4649+ {
4650+ skip_next_level_++;
4651+ continue;
4652+ }
4653+ top_dg = ( stack_.size() > 0 ? stack_.top().dataguide_ : nullptr );
4654 push( stack_element::object_type );
4655+ stack_.top().dataguide_ = (stack_.size() == 1 ? dataguide_ : top_dg);
4656 continue;
4657 case ']':
4658+ if (skip_next_level_)
4659+ {
4660+ if (skip_next_level_-- > 1)
4661+ continue;
4662+ }
4663 if ( stack_.empty() && strip_top_level_array_ ) {
4664 stripped_top_level_array_ = false;
4665 continue;
4666 }
4667 case '}': {
4668+ if (skip_next_level_)
4669+ {
4670+ if (skip_next_level_-- > 1)
4671+ continue;
4672+ }
4673 stack_element top( stack_.top() );
4674 stack_.pop();
4675 switch ( top.type_ ) {
4676@@ -178,9 +250,14 @@
4677 break;
4678 }
4679 case ':':
4680+ continue;
4681 case ',':
4682+ if (skip_next_level_ == 1)
4683+ skip_next_level_ = 0;
4684 continue;
4685 case token::number:
4686+ if (skip_next_level_)
4687+ continue;
4688 switch ( t.get_numeric_type() ) {
4689 case token::integer:
4690 GENV_ITEMFACTORY->createInteger(
4691@@ -202,14 +279,20 @@
4692 }
4693 break;
4694 case token::string:
4695+ if (skip_next_level_)
4696+ continue;
4697 s = t.get_value();
4698 GENV_ITEMFACTORY->createString( item, s );
4699 break;
4700 case 'F':
4701 case 'T':
4702+ if (skip_next_level_)
4703+ continue;
4704 GENV_ITEMFACTORY->createBoolean( item, t.get_type() == 'T' );
4705 break;
4706 case token::json_null:
4707+ if (skip_next_level_)
4708+ continue;
4709 GENV_ITEMFACTORY->createJSONNull( item );
4710 break;
4711 default:
4712
4713=== modified file 'src/runtime/json/json_loader.h'
4714--- src/runtime/json/json_loader.h 2012-12-03 18:29:05 +0000
4715+++ src/runtime/json/json_loader.h 2013-09-11 19:02:46 +0000
4716@@ -47,8 +47,10 @@
4717 * @param strip_top_level_array If \c true, strips the top-level array, if
4718 * any.
4719 */
4720- loader( std::istream &is, bool allow_multiple = false,
4721- bool strip_top_level_array = false );
4722+ loader( std::istream &is,
4723+ bool allow_multiple = false,
4724+ bool strip_top_level_array = false,
4725+ const store::Item* aDataguide = nullptr);
4726
4727 /**
4728 * Destroys this %loader.
4729@@ -101,6 +103,8 @@
4730 store::Item *key_;
4731 };
4732
4733+ const store::Item* dataguide_;
4734+
4735 stack_element( type = no_type );
4736 void destroy();
4737 };
4738@@ -120,9 +124,16 @@
4739 return *new( &stack_.top() ) stack_element( t );
4740 }
4741
4742+ bool contains(const store::Item* dataguide, store::Item_t const& a_key);
4743+
4744+
4745+private:
4746 parser parser_;
4747 bool const strip_top_level_array_;
4748 bool stripped_top_level_array_;
4749+ const store::Item* dataguide_;
4750+ store::Item_t dataguide_star_;
4751+ int skip_next_level_;
4752 };
4753
4754 ///////////////////////////////////////////////////////////////////////////////
4755
4756=== modified file 'src/runtime/json/jsoniq_functions_impl.cpp'
4757--- src/runtime/json/jsoniq_functions_impl.cpp 2013-08-21 10:25:42 +0000
4758+++ src/runtime/json/jsoniq_functions_impl.cpp 2013-09-11 19:02:46 +0000
4759@@ -863,7 +863,7 @@
4760 }
4761
4762 state->loader_ = new json::loader(
4763- *state->theInputStream, true, lStripTopLevelArray
4764+ *state->theInputStream, true, lStripTopLevelArray, theDataguide
4765 );
4766
4767 if ( state->theInput == NULL && theRelativeLocation )
4768
4769=== modified file 'src/runtime/json/pregenerated/jsoniq_functions.cpp'
4770--- src/runtime/json/pregenerated/jsoniq_functions.cpp 2013-08-19 13:00:41 +0000
4771+++ src/runtime/json/pregenerated/jsoniq_functions.cpp 2013-09-11 19:02:46 +0000
4772@@ -121,6 +121,7 @@
4773 (NaryBaseIterator<JSONParseIterator, JSONParseIteratorState>*)this);
4774
4775 ar & theRelativeLocation;
4776+ ar & theDataguide;
4777 }
4778
4779
4780
4781=== modified file 'src/runtime/json/pregenerated/jsoniq_functions.h'
4782--- src/runtime/json/pregenerated/jsoniq_functions.h 2013-08-19 13:00:41 +0000
4783+++ src/runtime/json/pregenerated/jsoniq_functions.h 2013-09-11 19:02:46 +0000
4784@@ -163,6 +163,7 @@
4785 {
4786 protected:
4787 QueryLoc theRelativeLocation; //
4788+ store::Item_t theDataguide; //
4789 public:
4790 SERIALIZABLE_CLASS(JSONParseIterator);
4791
4792@@ -178,11 +179,14 @@
4793 QueryLoc aRelativeLocation)
4794 :
4795 NaryBaseIterator<JSONParseIterator, JSONParseIteratorState>(sctx, loc, children),
4796- theRelativeLocation(aRelativeLocation)
4797+ theRelativeLocation(aRelativeLocation),
4798+ theDataguide()
4799 {}
4800
4801 virtual ~JSONParseIterator();
4802
4803+ void setDataguide(store::Item_t aValue) { theDataguide= aValue; }
4804+
4805 public:
4806 bool processBooleanOption(const store::Item_t& options, char const* option_name, bool* option_value) const;
4807 void accept(PlanIterVisitor& v) const;
4808
4809=== modified file 'src/runtime/spec/codegen-h.xq'
4810--- src/runtime/spec/codegen-h.xq 2013-02-07 17:24:36 +0000
4811+++ src/runtime/spec/codegen-h.xq 2013-09-11 19:02:46 +0000
4812@@ -89,6 +89,12 @@
4813 then
4814 "setDeterministic(false);&#xA;"
4815 else ""
4816+ let $annotations := string-join(
4817+ for $a in $function//zorba:annotation
4818+ return concat($gen:indent, $gen:indent, "addAnnotation(AnnotationInternal::", $a, ");", $gen:newline),
4819+ '')
4820+ let $funcVersionStr := if ($funcVersion eq "") then ""
4821+ else concat($gen:indent, $gen:indent, $funcVersion, $gen:newline)
4822 return
4823 concat($name, '(const signature&amp; sig, FunctionConsts::FunctionKind kind)',
4824 $gen:newline, $gen:indent,
4825@@ -96,8 +102,12 @@
4826 $gen:newline, $gen:indent, $gen:indent,
4827 local:base-class($function),
4828 '(sig, kind)',
4829- $gen:newline, $gen:indent,
4830- '{&#xA;', $setNoneDeterministic, $funcVersion, '&#xA;', $gen:indent, '}'),
4831+ $gen:newline,
4832+ $gen:indent, '{', $gen:newline,
4833+ $setNoneDeterministic,
4834+ $funcVersionStr,
4835+ $annotations,
4836+ $gen:indent, '}'),
4837
4838 $gen:newline,
4839
4840
4841=== modified file 'src/runtime/spec/collections/collections.xml'
4842--- src/runtime/spec/collections/collections.xml 2013-07-15 10:32:25 +0000
4843+++ src/runtime/spec/collections/collections.xml 2013-09-11 19:02:46 +0000
4844@@ -12,7 +12,7 @@
4845 xsi:schemaLocation="http://www.zorba-xquery.com ../runtime.xsd">
4846
4847 <zorba:source>
4848- <zorba:include form="Quoted">store/api/iterator.h</zorba:include>
4849+ <zorba:include form="Quoted">store/api/iterator.h</zorba:include>
4850 </zorba:source>
4851
4852 <zorba:header>
4853@@ -306,6 +306,7 @@
4854 </zorba:constructor>
4855
4856 <zorba:member type="bool" name="theIsDynamic" getterName="isDynamic"/>
4857+ <zorba:member type="store::Item_t" name="theDataguide" setterName="setDataguide"/>
4858
4859 <zorba:method const="true" name="isCountOptimizable" return="bool" />
4860
4861@@ -415,6 +416,7 @@
4862 </zorba:description>
4863
4864 <zorba:function generateCodegen="false">
4865+ <zorba:annotation>zann_explores_json</zorba:annotation>
4866
4867 <zorba:signature localname="insert-nodes" prefix="static-collections-dml">
4868 <zorba:param>xs:QName</zorba:param>
4869@@ -471,7 +473,8 @@
4870 </zorba:description>
4871
4872 <zorba:function generateCodegen="false">
4873-
4874+ <zorba:annotation>zann_explores_json</zorba:annotation>
4875+
4876 <zorba:signature localname="insert-nodes-first" prefix="static-collections-dml">
4877 <zorba:param>xs:QName</zorba:param>
4878 <zorba:param>node()*</zorba:param>
4879@@ -532,6 +535,7 @@
4880 </zorba:description>
4881
4882 <zorba:function generateCodegen="false">
4883+ <zorba:annotation>zann_explores_json</zorba:annotation>
4884
4885 <zorba:signature localname="insert-nodes-last" prefix="static-collections-dml">
4886 <zorba:param>xs:QName</zorba:param>
4887@@ -592,6 +596,7 @@
4888 </zorba:description>
4889
4890 <zorba:function generateCodegen="false">
4891+ <zorba:annotation>zann_explores_json</zorba:annotation>
4892
4893 <zorba:signature localname="insert-nodes-before" prefix="static-collections-dml">
4894 <zorba:param>xs:QName</zorba:param>
4895@@ -656,7 +661,8 @@
4896 </zorba:description>
4897
4898 <zorba:function generateCodegen="false">
4899-
4900+ <zorba:annotation>zann_explores_json</zorba:annotation>
4901+
4902 <zorba:signature localname="insert-nodes-after" prefix="static-collections-dml">
4903 <zorba:param>xs:QName</zorba:param>
4904 <zorba:param>node()</zorba:param>
4905@@ -722,6 +728,7 @@
4906 </zorba:description>
4907
4908 <zorba:function generateCodegen="false">
4909+ <zorba:annotation>zann_explores_json</zorba:annotation>
4910
4911 <zorba:signature localname="apply-insert-nodes" prefix="static-collections-dml">
4912 <zorba:param>xs:QName</zorba:param>
4913@@ -786,6 +793,7 @@
4914 </zorba:description>
4915
4916 <zorba:function generateCodegen="false">
4917+ <zorba:annotation>zann_explores_json</zorba:annotation>
4918
4919 <zorba:signature localname="apply-insert-nodes-first"
4920 prefix="static-collections-dml">
4921@@ -856,6 +864,7 @@
4922 </zorba:description>
4923
4924 <zorba:function generateCodegen="false">
4925+ <zorba:annotation>zann_explores_json</zorba:annotation>
4926
4927 <zorba:signature localname="apply-insert-nodes-last"
4928 prefix="static-collections-dml">
4929@@ -926,6 +935,7 @@
4930 </zorba:description>
4931
4932 <zorba:function generateCodegen="false">
4933+ <zorba:annotation>zann_explores_json</zorba:annotation>
4934
4935 <zorba:signature localname="apply-insert-nodes-before"
4936 prefix="static-collections-dml">
4937@@ -1000,6 +1010,7 @@
4938 </zorba:description>
4939
4940 <zorba:function generateCodegen="false">
4941+ <zorba:annotation>zann_explores_json</zorba:annotation>
4942
4943 <zorba:signature localname="apply-insert-nodes-after"
4944 prefix="static-collections-dml">
4945@@ -1281,6 +1292,7 @@
4946 </zorba:description>
4947
4948 <zorba:function generateCodegen="false">
4949+ <zorba:annotation>zann_explores_json</zorba:annotation>
4950
4951 <zorba:signature localname="edit" prefix="static-collections-dml">
4952 <zorba:param>structured-item()</zorba:param>
4953
4954=== modified file 'src/runtime/spec/json/jsoniq_functions.xml'
4955--- src/runtime/spec/json/jsoniq_functions.xml 2013-08-21 10:25:42 +0000
4956+++ src/runtime/spec/json/jsoniq_functions.xml 2013-09-11 19:02:46 +0000
4957@@ -92,6 +92,7 @@
4958 <zorba:iterator name="JSONEncodeForRoundtripIterator">
4959
4960 <zorba:function isDeterministic="true">
4961+ <zorba:annotation>zann_explores_json</zorba:annotation>
4962
4963 <zorba:signature localname="encode-for-roundtrip" prefix="fn-jsoniq">
4964 <zorba:param>item()*</zorba:param>
4965@@ -188,6 +189,7 @@
4966 </zorba:constructor>
4967
4968 <zorba:member type="QueryLoc" name="theRelativeLocation" />
4969+ <zorba:member type="store::Item_t" name="theDataguide" setterName="setDataguide"/>
4970
4971 <zorba:method return="bool" name="processBooleanOption" const="true">
4972 <zorba:param type="const store::Item_t&amp;" name="options"/>
4973@@ -206,6 +208,8 @@
4974
4975 <zorba:function isDeterministic="true"
4976 generateCodegen="false">
4977+
4978+ <zorba:annotation>zann_explores_json</zorba:annotation>
4979
4980 <zorba:signature localname="keys" prefix="fn-jsoniq">
4981 <zorba:param>item()*</zorba:param>
4982@@ -327,6 +331,10 @@
4983 <zorba:iterator name="JSONObjectProjectIterator" arity="binary">
4984
4985 <zorba:function isDeterministic="true">
4986+ <!-- TODO: project() could be used for document projection if the second
4987+ parameter is all consts. If this is done, this annotation should be
4988+ removed -->
4989+ <zorba:annotation>zann_explores_json</zorba:annotation>
4990
4991 <zorba:signature localname="project" prefix="fn-jsoniq">
4992 <zorba:param>item()*</zorba:param>
4993@@ -509,6 +517,8 @@
4994 <zorba:iterator name="JSONArraySizeIterator" arity="unary">
4995
4996 <zorba:function isDeterministic="true">
4997+ <zorba:annotation>zann_explores_json</zorba:annotation>
4998+
4999 <zorba:signature localname="size" prefix="fn-jsoniq">
5000 <zorba:param>array()?</zorba:param>
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches