Merge lp:~zorba-coders/zorba/bug900677 into lp:zorba

Proposed by Matthias Brantner
Status: Superseded
Proposed branch: lp:~zorba-coders/zorba/bug900677
Merge into: lp:zorba
Diff against target: 970 lines (+702/-42)
22 files modified
ChangeLog (+2/-0)
modules/com/zorba-xquery/www/modules/store/static/indexes/dml.xq (+25/-0)
src/functions/library.cpp (+2/-0)
src/functions/pregenerated/func_index_func.cpp (+63/-0)
src/functions/pregenerated/func_index_func.h (+66/-0)
src/functions/pregenerated/function_enum.h (+1/-0)
src/runtime/indexing/index_func_impl.cpp (+103/-0)
src/runtime/indexing/index_util.h (+95/-0)
src/runtime/indexing/pregenerated/index_func.cpp (+79/-0)
src/runtime/indexing/pregenerated/index_func.h (+97/-0)
src/runtime/spec/indexing/index_func.xml (+55/-0)
src/runtime/store/maps_impl.cpp (+4/-35)
src/runtime/visitors/pregenerated/planiter_visitor.h (+5/-0)
src/runtime/visitors/pregenerated/printer_visitor.cpp (+15/-0)
src/runtime/visitors/pregenerated/printer_visitor.h (+3/-0)
src/store/naive/simple_index_value.cpp (+21/-7)
src/store/naive/simple_index_value.h (+5/-0)
test/rbkt/ExpQueryResults/zorba/index/keys1.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/index/keys2.xml.res (+1/-0)
test/rbkt/Queries/zorba/index/keys1.xq (+22/-0)
test/rbkt/Queries/zorba/index/keys2.xq (+22/-0)
test/rbkt/Queries/zorba/index/keys_mod.xqlib (+15/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/bug900677
Reviewer Review Type Date Requested Status
Markos Zaharioudakis Pending
William Candillon Pending
Review via email: mp+88972@code.launchpad.net

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

Commit message

Added a keys() function to the index dml module. This fixes bug #900677.

Description of the change

Added a keys() function to the index dml module. This fixes bug #900677.

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

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

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:273 (message):
  Validation queue job bug900677-2012-01-18T01-02-56.733Z is finished. The
  final status was:

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

  Not commiting changes.

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

lp:~zorba-coders/zorba/bug900677 updated
10622. By Matthias Brantner

Fixed a bug when a key attribute in an index is the empty sequence. Also, improved the
documentation for the idml:keys function.

10623. By Matthias Brantner

merge

10624. By David Graf

merged trunk

10625. By David Graf

regenerated stuff

10626. By David Graf

fixed merge bug

10627. By David Graf

commit of work in progress - keys function for general indices does work. Cleanup and more tests needed.

10628. By David Graf

index-keys function test for general index

10629. By David Graf

added some comments

10630. By Matthias Brantner

merge with trunk

10631. By Matthias Brantner

minor cleanup

10632. By David Graf

merged trunk

10633. By David Graf

merged trunk

10634. By David Graf

merged trunk

10635. By David Graf

fixed segfault

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ChangeLog'
--- ChangeLog 2012-01-11 17:30:25 +0000
+++ ChangeLog 2012-01-18 01:11:25 +0000
@@ -21,6 +21,8 @@
21 support.21 support.
22 * zerr is not predeclared anymore to be http://www.zorba-xquery.com/errors22 * zerr is not predeclared anymore to be http://www.zorba-xquery.com/errors
23 * Added API method Item::getNamespaceBindings().23 * Added API method Item::getNamespaceBindings().
24 * Added a function to the http://www.zorba-xquery.com/modules/store/static/indexes/dml module which returns
25 the value of all keys contained in an index.
2426
25version 2.127version 2.1
2628
2729
=== modified file 'modules/com/zorba-xquery/www/modules/store/static/indexes/dml.xq'
--- modules/com/zorba-xquery/www/modules/store/static/indexes/dml.xq 2011-11-01 15:59:24 +0000
+++ modules/com/zorba-xquery/www/modules/store/static/indexes/dml.xq 2012-01-18 01:11:25 +0000
@@ -268,3 +268,28 @@
268 :)268 :)
269declare updating function idml:refresh-index($name as xs:QName) external;269declare updating function idml:refresh-index($name as xs:QName) external;
270270
271(:~
272 : The keys function returns a sequence of all keys contained in the
273 : index with the given name.
274 :
275 : @param $name The QName of the index
276 : @return The result of the function is sequence of elements each representing
277 : one key contained in the index. Each element has the following
278 : structure:
279 : <pre>
280 : &lt;key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml">
281 : &lt;attribute value="key1_value"/>
282 : &lt;attribute value="key2_value"/>
283 : &lt;attribute value="key3_value"/>
284 : &lt;/key>
285 : </pre>
286 :
287 : Note that the order of the attribute elements reflects the order of
288 : the keys in the index specification. Also note that the values in
289 : these attributes have the type that is declared in the corresponding
290 : index specification.
291 :
292 : @error zerr:ZDDY0021 if the index with name $name is not declared.
293 : @error zerr:ZDDY0023 if the index with name $name does not exist.
294 :)
295declare function idml:keys($name as xs:QName) as node()* external;
271296
=== modified file 'src/functions/library.cpp'
--- src/functions/library.cpp 2011-10-14 07:35:51 +0000
+++ src/functions/library.cpp 2012-01-18 01:11:25 +0000
@@ -41,6 +41,7 @@
41#include "functions/func_fnput.h"41#include "functions/func_fnput.h"
42#include "functions/func_hoist.h"42#include "functions/func_hoist.h"
43#include "functions/func_index_ddl.h"43#include "functions/func_index_ddl.h"
44#include "functions/func_index_func.h"
44#include "functions/func_ic_ddl.h"45#include "functions/func_ic_ddl.h"
45#include "functions/func_maths.h"46#include "functions/func_maths.h"
46#include "functions/func_nodes.h"47#include "functions/func_nodes.h"
@@ -106,6 +107,7 @@
106 populate_context_errors_and_diagnostics(sctx);107 populate_context_errors_and_diagnostics(sctx);
107 populate_context_fnput(sctx);108 populate_context_fnput(sctx);
108 populate_context_index_ddl(sctx);109 populate_context_index_ddl(sctx);
110 populate_context_index_func(sctx);
109 populate_context_ic_ddl(sctx);111 populate_context_ic_ddl(sctx);
110 populate_context_maths(sctx);112 populate_context_maths(sctx);
111 populate_context_nodes(sctx);113 populate_context_nodes(sctx);
112114
=== added file 'src/functions/pregenerated/func_index_func.cpp'
--- src/functions/pregenerated/func_index_func.cpp 1970-01-01 00:00:00 +0000
+++ src/functions/pregenerated/func_index_func.cpp 2012-01-18 01:11:25 +0000
@@ -0,0 +1,63 @@
1/*
2 * Copyright 2006-2008 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17// ******************************************
18// * *
19// * THIS IS A GENERATED FILE. DO NOT EDIT! *
20// * SEE .xml FILE WITH SAME NAME *
21// * *
22// ******************************************
23
24
25#include "stdafx.h"
26#include "runtime/indexing/index_func.h"
27#include "functions/func_index_func.h"
28
29
30namespace zorba{
31
32
33
34PlanIter_t zorba_store_indexes_static_dml_keys::codegen(
35 CompilerCB*,
36 static_context* sctx,
37 const QueryLoc& loc,
38 std::vector<PlanIter_t>& argv,
39 AnnotationHolder& ann) const
40{
41 return new IndexKeysIterator(sctx, loc, argv);
42}
43
44void populate_context_index_func(static_context* sctx)
45{
46 {
47
48
49 DECL_WITH_KIND(sctx, zorba_store_indexes_static_dml_keys,
50 (createQName("http://www.zorba-xquery.com/modules/store/static/indexes/dml","","keys"),
51 GENV_TYPESYSTEM.QNAME_TYPE_ONE,
52 GENV_TYPESYSTEM.ANY_NODE_TYPE_STAR),
53 FunctionConsts::ZORBA_STORE_INDEXES_STATIC_DML_KEYS_1);
54
55 }
56
57}
58
59
60}
61
62
63
064
=== added file 'src/functions/pregenerated/func_index_func.h'
--- src/functions/pregenerated/func_index_func.h 1970-01-01 00:00:00 +0000
+++ src/functions/pregenerated/func_index_func.h 2012-01-18 01:11:25 +0000
@@ -0,0 +1,66 @@
1/*
2 * Copyright 2006-2008 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17// ******************************************
18// * *
19// * THIS IS A GENERATED FILE. DO NOT EDIT! *
20// * SEE .xml FILE WITH SAME NAME *
21// * *
22// ******************************************
23
24
25#ifndef ZORBA_FUNCTIONS_INDEX_FUNC_H
26#define ZORBA_FUNCTIONS_INDEX_FUNC_H
27
28
29#include "common/shared_types.h"
30#include "functions/function_impl.h"
31
32
33namespace zorba {
34
35
36void populate_context_index_func(static_context* sctx);
37
38
39
40
41//zorba-store-indexes-static-dml:keys
42class zorba_store_indexes_static_dml_keys : public function
43{
44public:
45 zorba_store_indexes_static_dml_keys(const signature& sig, FunctionConsts::FunctionKind kind)
46 :
47 function(sig, kind)
48 {
49
50 }
51
52 bool accessesDynCtx() const { return true; }
53
54 CODEGEN_DECL();
55};
56
57
58} //namespace zorba
59
60
61#endif
62/*
63 * Local variables:
64 * mode: c++
65 * End:
66 */
067
=== modified file 'src/functions/pregenerated/function_enum.h'
--- src/functions/pregenerated/function_enum.h 2012-01-11 17:30:25 +0000
+++ src/functions/pregenerated/function_enum.h 2012-01-18 01:11:25 +0000
@@ -141,6 +141,7 @@
141 ZORBA_STORE_INTEGRITY_CONSTRAINTS_STATIC_DDL_ACTIVATE_1,141 ZORBA_STORE_INTEGRITY_CONSTRAINTS_STATIC_DDL_ACTIVATE_1,
142 ZORBA_STORE_INTEGRITY_CONSTRAINTS_STATIC_DDL_DEACTIVATE_1,142 ZORBA_STORE_INTEGRITY_CONSTRAINTS_STATIC_DDL_DEACTIVATE_1,
143 ZORBA_STORE_INTEGRITY_CONSTRAINTS_STATIC_DML_CHECK_INTEGRITY_CONSTRAINT_1,143 ZORBA_STORE_INTEGRITY_CONSTRAINTS_STATIC_DML_CHECK_INTEGRITY_CONSTRAINT_1,
144 ZORBA_STORE_INDEXES_STATIC_DML_KEYS_1,
144 FN_ZORBA_INTROSPECT_SCTX_STATICALLY_KNOWN_NAMESPACES_0,145 FN_ZORBA_INTROSPECT_SCTX_STATICALLY_KNOWN_NAMESPACES_0,
145 FN_ZORBA_INTROSPECT_SCTX_DEFAULT_FUNCTION_NAMESPACE_0,146 FN_ZORBA_INTROSPECT_SCTX_DEFAULT_FUNCTION_NAMESPACE_0,
146 FN_ZORBA_INTROSPECT_SCTX_BASE_URI_0,147 FN_ZORBA_INTROSPECT_SCTX_BASE_URI_0,
147148
=== added file 'src/runtime/indexing/index_func_impl.cpp'
--- src/runtime/indexing/index_func_impl.cpp 1970-01-01 00:00:00 +0000
+++ src/runtime/indexing/index_func_impl.cpp 2012-01-18 01:11:25 +0000
@@ -0,0 +1,103 @@
1/*
2 * Copyright 2006-2012 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#include "stdafx.h"
17
18#include "diagnostics/assert.h"
19#include "diagnostics/xquery_diagnostics.h"
20
21#include "zorbatypes/URI.h"
22
23#include "system/globalenv.h"
24
25#include "runtime/indexing/index_func.h"
26#include "runtime/indexing/index_util.h"
27
28#include "context/namespace_context.h"
29#include "context/static_context.h"
30
31#include "store/api/item.h"
32#include "store/api/index.h"
33
34#include "compiler/xqddf/value_index.h"
35
36namespace zorba {
37
38/*******************************************************************************
39********************************************************************************/
40bool
41IndexKeysIterator::nextImpl(
42 store::Item_t& result,
43 PlanState& aPlanState) const
44{
45 store::Item_t lQName;
46 IndexDecl_t indexDecl;
47 store::Index* lIndex;
48 store::IndexKey lKey;
49
50 store::Item_t lKeyNodeName;
51 GENV_ITEMFACTORY->createQName(lKeyNodeName,
52 static_context::ZORBA_STORE_DYNAMIC_UNORDERED_MAP_FN_NS,
53 "", "key");
54
55 IndexKeysIteratorState* state;
56 DEFAULT_STACK_INIT(IndexKeysIteratorState, state, aPlanState);
57
58 consumeNext(lQName, theChildren[0].getp(), aPlanState);
59
60 if ((indexDecl = theSctx->lookup_index(lQName)) == NULL)
61 {
62 throw XQUERY_EXCEPTION(
63 zerr::ZDDY0021_INDEX_NOT_DECLARED,
64 ERROR_PARAMS( lQName->getStringValue() ),
65 ERROR_LOC( loc )
66 );
67 }
68
69 lIndex = GENV_STORE.getIndex(lQName);
70
71 if (!lIndex)
72 {
73 throw XQUERY_EXCEPTION(
74 zerr::ZDDY0023_INDEX_DOES_NOT_EXIST,
75 ERROR_PARAMS( lQName->getStringValue() ),
76 ERROR_LOC( loc )
77 );
78 }
79
80 state->theIter = lIndex->keys();
81
82 state->theIter->open();
83
84 // generate result elements of the form
85 // <key>
86 // <attribute value="key1_value"/>
87 // <attribute value="key2_value"/>
88 // <attribute value="key3_value"/>
89 // </key>
90 while (state->theIter->next(lKey))
91 {
92 IndexUtil::createIndexKeyElement(
93 result, lKey, static_context::ZORBA_STORE_STATIC_INDEXES_DML_FN_NS
94 );
95 STACK_PUSH(true, state);
96 }
97
98 STACK_END(state);
99}
100
101} // namespace zorba
102/* vim:set et sw=2 ts=2: */
103
0104
=== added file 'src/runtime/indexing/index_util.h'
--- src/runtime/indexing/index_util.h 1970-01-01 00:00:00 +0000
+++ src/runtime/indexing/index_util.h 2012-01-18 01:11:25 +0000
@@ -0,0 +1,95 @@
1/*
2 * Copyright 2006-2012 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef ZORBA_INDEX_UTIL_H
17#define ZORBA_INDEX_UTIL_H
18
19#include "stdafx.h"
20
21#include "context/namespace_context.h"
22
23#include "store/api/pul.h"
24#include "store/api/store.h"
25#include "store/api/item.h"
26#include "store/api/item_factory.h"
27#include "store/api/iterator.h"
28#include "store/api/index.h"
29
30#include "types/typeimpl.h"
31#include "types/typeops.h"
32#include "types/casting.h"
33
34namespace zorba {
35
36class IndexUtil
37{
38public:
39 /*******************************************************************************
40 generate result elements of the form
41 <aBase:key>
42 <aBase:attribute aBase:value="key1_value"/>
43 <aBase:attribute aBase:value="key2_value"/>
44 <aBase:attribute aBase:value="key3_value"/>
45 </aBase:key>
46 ********************************************************************************/
47 static void
48 createIndexKeyElement(
49 store::Item_t& result,
50 store::IndexKey& aKey,
51 const zstring& aBase)
52 {
53 store::Item_t lKeyNodeName;
54 GENV_ITEMFACTORY->createQName(lKeyNodeName,
55 aBase, "", "key");
56
57 zstring lBase = aBase;
58
59 store::Item_t lTypeName = GENV_TYPESYSTEM.XS_UNTYPED_QNAME;
60
61 const store::NsBindings lBindings;
62
63 GENV_ITEMFACTORY->createElementNode(
64 result, NULL, lKeyNodeName, lTypeName,
65 true, false, lBindings, lBase);
66
67 for (store::ItemVector::iterator lIter = aKey.begin();
68 lIter != aKey.end();
69 ++lIter)
70 {
71 store::Item_t lAttrElem, lAttrNodeName;
72 store::Item_t lNameAttr, lValueAttr, lValueAttrName;
73
74 GENV_ITEMFACTORY->createQName(lAttrNodeName,
75 lBase, "", "attribute");
76
77 GENV_ITEMFACTORY->createQName(lValueAttrName,
78 "", "", "value");
79
80 lTypeName = GENV_TYPESYSTEM.XS_UNTYPED_QNAME;
81
82 GENV_ITEMFACTORY->createElementNode(
83 lAttrElem, result, lAttrNodeName, lTypeName,
84 true, false, lBindings, lBase);
85
86 lTypeName = GENV_TYPESYSTEM.XS_UNTYPED_QNAME;
87 GENV_ITEMFACTORY->createAttributeNode(
88 lValueAttr, lAttrElem.getp(), lValueAttrName, lTypeName, (*lIter));
89 }
90 }
91}; /* class IndexUtil */
92
93} // namespace zorba
94/* vim:set et sw=2 ts=2: */
95#endif
096
=== added file 'src/runtime/indexing/pregenerated/index_func.cpp'
--- src/runtime/indexing/pregenerated/index_func.cpp 1970-01-01 00:00:00 +0000
+++ src/runtime/indexing/pregenerated/index_func.cpp 2012-01-18 01:11:25 +0000
@@ -0,0 +1,79 @@
1/*
2 * Copyright 2006-2008 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17// ******************************************
18// * *
19// * THIS IS A GENERATED FILE. DO NOT EDIT! *
20// * SEE .xml FILE WITH SAME NAME *
21// * *
22// ******************************************
23
24#include "stdafx.h"
25#include "zorbatypes/rchandle.h"
26#include "zorbatypes/zstring.h"
27#include "runtime/visitors/planiter_visitor.h"
28#include "runtime/indexing/index_func.h"
29#include "system/globalenv.h"
30
31
32#include "store/api/iterator.h"
33
34namespace zorba {
35
36// <IndexKeysIterator>
37const char* IndexKeysIterator::class_name_str = "IndexKeysIterator";
38IndexKeysIterator::class_factory<IndexKeysIterator>
39IndexKeysIterator::g_class_factory;
40
41const serialization::ClassVersion
42IndexKeysIterator::class_versions[] ={{ 1, 0x000905, false}};
43
44const int IndexKeysIterator::class_versions_count =
45sizeof(IndexKeysIterator::class_versions)/sizeof(struct serialization::ClassVersion);
46
47void IndexKeysIterator::accept(PlanIterVisitor& v) const {
48 v.beginVisit(*this);
49
50 std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
51 std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
52 for ( ; lIter != lEnd; ++lIter ){
53 (*lIter)->accept(v);
54 }
55
56 v.endVisit(*this);
57}
58
59IndexKeysIterator::~IndexKeysIterator() {}
60
61IndexKeysIteratorState::IndexKeysIteratorState() {}
62
63IndexKeysIteratorState::~IndexKeysIteratorState() {}
64
65
66void IndexKeysIteratorState::init(PlanState& planState) {
67 PlanIteratorState::init(planState);
68}
69
70void IndexKeysIteratorState::reset(PlanState& planState) {
71 PlanIteratorState::reset(planState);
72}
73// </IndexKeysIterator>
74
75
76
77}
78
79
080
=== added file 'src/runtime/indexing/pregenerated/index_func.h'
--- src/runtime/indexing/pregenerated/index_func.h 1970-01-01 00:00:00 +0000
+++ src/runtime/indexing/pregenerated/index_func.h 2012-01-18 01:11:25 +0000
@@ -0,0 +1,97 @@
1/*
2 * Copyright 2006-2008 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17// ******************************************
18// * *
19// * THIS IS A GENERATED FILE. DO NOT EDIT! *
20// * SEE .xml FILE WITH SAME NAME *
21// * *
22// ******************************************
23#ifndef ZORBA_RUNTIME_INDEXING_INDEX_FUNC_H
24#define ZORBA_RUNTIME_INDEXING_INDEX_FUNC_H
25
26
27#include "common/shared_types.h"
28
29
30
31#include "runtime/base/narybase.h"
32#include "store/api/index.h"
33
34
35namespace zorba {
36
37/**
38 *
39 * keys($iindexName as xs:QName) as ()
40 *
41 * Author: Zorba Team
42 */
43class IndexKeysIteratorState : public PlanIteratorState
44{
45public:
46 store::Index::KeyIterator_t theIter; //
47
48 IndexKeysIteratorState();
49
50 ~IndexKeysIteratorState();
51
52 void init(PlanState&);
53 void reset(PlanState&);
54};
55
56class IndexKeysIterator : public NaryBaseIterator<IndexKeysIterator, IndexKeysIteratorState>
57{
58protected:
59 store::NsBindings theNSBindings; //
60public:
61 SERIALIZABLE_CLASS(IndexKeysIterator);
62
63 SERIALIZABLE_CLASS_CONSTRUCTOR2T(IndexKeysIterator,
64 NaryBaseIterator<IndexKeysIterator, IndexKeysIteratorState>);
65
66 void serialize( ::zorba::serialization::Archiver& ar)
67 {
68 serialize_baseclass(ar,
69 (NaryBaseIterator<IndexKeysIterator, IndexKeysIteratorState>*)this);
70
71 ar & theNSBindings;
72 }
73
74 IndexKeysIterator(
75 static_context* sctx,
76 const QueryLoc& loc,
77 std::vector<PlanIter_t>& children)
78 :
79 NaryBaseIterator<IndexKeysIterator, IndexKeysIteratorState>(sctx, loc, children),
80 theNSBindings()
81 {}
82
83 virtual ~IndexKeysIterator();
84
85 void accept(PlanIterVisitor& v) const;
86
87 bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
88};
89
90
91}
92#endif
93/*
94 * Local variables:
95 * mode: c++
96 * End:
97 */
098
=== added file 'src/runtime/spec/indexing/index_func.xml'
--- src/runtime/spec/indexing/index_func.xml 1970-01-01 00:00:00 +0000
+++ src/runtime/spec/indexing/index_func.xml 2012-01-18 01:11:25 +0000
@@ -0,0 +1,55 @@
1<?xml version="1.0" encoding="UTF-8"?>
2
3<!--
4////////////////////////////////////////////////////////////////////////////////
5// //
6// //
7////////////////////////////////////////////////////////////////////////////////
8-->
9<zorba:iterators
10 xmlns:zorba="http://www.zorba-xquery.com"
11 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
12 xsi:schemaLocation="http://www.zorba-xquery.com ../runtime.xsd">
13
14<zorba:source>
15 <zorba:include form="Quoted">store/api/iterator.h</zorba:include>
16</zorba:source>
17
18<zorba:header>
19 <zorba:include form="Quoted">store/api/index.h</zorba:include>
20</zorba:header>
21
22<!--
23/*******************************************************************************
24*******************************************************************************/
25-->
26<zorba:iterator name="IndexKeysIterator" arity="nary">
27
28 <zorba:description author="Zorba Team">
29 keys($iindexName as xs:QName) as ()
30 </zorba:description>
31
32 <zorba:function>
33
34 <zorba:signature localname="keys"
35 prefix="zorba-store-indexes-static-dml">
36 <zorba:param>xs:QName</zorba:param>
37 <zorba:output>node()*</zorba:output>
38 </zorba:signature>
39
40 <zorba:methods>
41 <zorba:accessesDynCtx returnValue="true"/>
42 </zorba:methods>
43
44 </zorba:function>
45
46 <zorba:state>
47 <zorba:member type="store::Index::KeyIterator_t" name="theIter"/>
48 </zorba:state>
49
50 <zorba:member type="store::NsBindings" name="theNSBindings" brief=""/>
51
52</zorba:iterator>
53
54</zorba:iterators>
55
056
=== modified file 'src/runtime/store/maps_impl.cpp'
--- src/runtime/store/maps_impl.cpp 2011-10-26 21:13:53 +0000
+++ src/runtime/store/maps_impl.cpp 2012-01-18 01:11:25 +0000
@@ -23,6 +23,7 @@
23#include "system/globalenv.h"23#include "system/globalenv.h"
2424
25#include "runtime/store/maps.h"25#include "runtime/store/maps.h"
26#include "runtime/indexing/index_util.h"
2627
27#include "context/static_context.h"28#include "context/static_context.h"
28#include "context/namespace_context.h"29#include "context/namespace_context.h"
@@ -444,11 +445,6 @@
444 zstring lBaseURI =445 zstring lBaseURI =
445 static_context::ZORBA_STORE_DYNAMIC_UNORDERED_MAP_FN_NS;446 static_context::ZORBA_STORE_DYNAMIC_UNORDERED_MAP_FN_NS;
446447
447 store::Item_t lKeyNodeName;
448 GENV_ITEMFACTORY->createQName(lKeyNodeName,
449 static_context::ZORBA_STORE_DYNAMIC_UNORDERED_MAP_FN_NS,
450 "", "key");
451
452 MapKeysIteratorState* state;448 MapKeysIteratorState* state;
453 DEFAULT_STACK_INIT(MapKeysIteratorState, state, aPlanState);449 DEFAULT_STACK_INIT(MapKeysIteratorState, state, aPlanState);
454450
@@ -477,36 +473,9 @@
477 // </key>473 // </key>
478 while (state->theIter->next(lKey))474 while (state->theIter->next(lKey))
479 {475 {
480 lTypeName = GENV_TYPESYSTEM.XS_UNTYPED_QNAME;476 IndexUtil::createIndexKeyElement(result, lKey,
481477 static_context::ZORBA_STORE_DYNAMIC_UNORDERED_MAP_FN_NS
482 GENV_ITEMFACTORY->createElementNode(478 );
483 result, NULL, lKeyNodeName, lTypeName,
484 true, false, theNSBindings, lBaseURI);
485
486 for (store::ItemVector::iterator lIter = lKey.begin();
487 lIter != lKey.end();
488 ++lIter)
489 {
490 store::Item_t lAttrElem, lAttrNodeName;
491 store::Item_t lNameAttr, lValueAttr, lValueAttrName;
492
493 GENV_ITEMFACTORY->createQName(lAttrNodeName,
494 static_context::ZORBA_STORE_DYNAMIC_UNORDERED_MAP_FN_NS,
495 "", "attribute");
496
497 GENV_ITEMFACTORY->createQName(lValueAttrName,
498 "", "", "value");
499
500 lTypeName = GENV_TYPESYSTEM.XS_UNTYPED_QNAME;
501
502 GENV_ITEMFACTORY->createElementNode(
503 lAttrElem, result, lAttrNodeName, lTypeName,
504 true, false, theNSBindings, lBaseURI);
505
506 lTypeName = GENV_TYPESYSTEM.XS_UNTYPED_QNAME;
507 GENV_ITEMFACTORY->createAttributeNode(
508 lValueAttr, lAttrElem.getp(), lValueAttrName, lTypeName, (*lIter));
509 }
510 STACK_PUSH(true, state);479 STACK_PUSH(true, state);
511 }480 }
512481
513482
=== modified file 'src/runtime/visitors/pregenerated/planiter_visitor.h'
--- src/runtime/visitors/pregenerated/planiter_visitor.h 2012-01-11 17:30:25 +0000
+++ src/runtime/visitors/pregenerated/planiter_visitor.h 2012-01-18 01:11:25 +0000
@@ -201,6 +201,8 @@
201201
202 class CheckICIterator;202 class CheckICIterator;
203203
204 class IndexKeysIterator;
205
204 class StaticNamespacesIterator;206 class StaticNamespacesIterator;
205207
206 class DefaultFunctionNamespaceIterator;208 class DefaultFunctionNamespaceIterator;
@@ -854,6 +856,9 @@
854 virtual void beginVisit ( const CheckICIterator& ) = 0;856 virtual void beginVisit ( const CheckICIterator& ) = 0;
855 virtual void endVisit ( const CheckICIterator& ) = 0;857 virtual void endVisit ( const CheckICIterator& ) = 0;
856858
859 virtual void beginVisit ( const IndexKeysIterator& ) = 0;
860 virtual void endVisit ( const IndexKeysIterator& ) = 0;
861
857 virtual void beginVisit ( const StaticNamespacesIterator& ) = 0;862 virtual void beginVisit ( const StaticNamespacesIterator& ) = 0;
858 virtual void endVisit ( const StaticNamespacesIterator& ) = 0;863 virtual void endVisit ( const StaticNamespacesIterator& ) = 0;
859864
860865
=== modified file 'src/runtime/visitors/pregenerated/printer_visitor.cpp'
--- src/runtime/visitors/pregenerated/printer_visitor.cpp 2012-01-11 17:30:25 +0000
+++ src/runtime/visitors/pregenerated/printer_visitor.cpp 2012-01-18 01:11:25 +0000
@@ -49,6 +49,7 @@
49#include "runtime/fnput/fnput.h"49#include "runtime/fnput/fnput.h"
50#include "runtime/function_item/function_item_iter.h"50#include "runtime/function_item/function_item_iter.h"
51#include "runtime/indexing/ic_ddl.h"51#include "runtime/indexing/ic_ddl.h"
52#include "runtime/indexing/index_func.h"
52#include "runtime/introspection/sctx.h"53#include "runtime/introspection/sctx.h"
53#include "runtime/maths/maths.h"54#include "runtime/maths/maths.h"
54#include "runtime/nodes/node_position.h"55#include "runtime/nodes/node_position.h"
@@ -1300,6 +1301,20 @@
1300// </CheckICIterator>1301// </CheckICIterator>
13011302
13021303
1304// <IndexKeysIterator>
1305void PrinterVisitor::beginVisit ( const IndexKeysIterator& a) {
1306 thePrinter.startBeginVisit("IndexKeysIterator", ++theId);
1307 printCommons( &a, theId );
1308 thePrinter.endBeginVisit( theId );
1309}
1310
1311void PrinterVisitor::endVisit ( const IndexKeysIterator& ) {
1312 thePrinter.startEndVisit();
1313 thePrinter.endEndVisit();
1314}
1315// </IndexKeysIterator>
1316
1317
1303// <StaticNamespacesIterator>1318// <StaticNamespacesIterator>
1304void PrinterVisitor::beginVisit ( const StaticNamespacesIterator& a) {1319void PrinterVisitor::beginVisit ( const StaticNamespacesIterator& a) {
1305 thePrinter.startBeginVisit("StaticNamespacesIterator", ++theId);1320 thePrinter.startBeginVisit("StaticNamespacesIterator", ++theId);
13061321
=== modified file 'src/runtime/visitors/pregenerated/printer_visitor.h'
--- src/runtime/visitors/pregenerated/printer_visitor.h 2012-01-11 17:30:25 +0000
+++ src/runtime/visitors/pregenerated/printer_visitor.h 2012-01-18 01:11:25 +0000
@@ -304,6 +304,9 @@
304 void beginVisit( const CheckICIterator& );304 void beginVisit( const CheckICIterator& );
305 void endVisit ( const CheckICIterator& );305 void endVisit ( const CheckICIterator& );
306306
307 void beginVisit( const IndexKeysIterator& );
308 void endVisit ( const IndexKeysIterator& );
309
307 void beginVisit( const StaticNamespacesIterator& );310 void beginVisit( const StaticNamespacesIterator& );
308 void endVisit ( const StaticNamespacesIterator& );311 void endVisit ( const StaticNamespacesIterator& );
309312
310313
=== modified file 'src/store/naive/simple_index_value.cpp'
--- src/store/naive/simple_index_value.cpp 2012-01-11 17:30:25 +0000
+++ src/store/naive/simple_index_value.cpp 2012-01-18 01:11:25 +0000
@@ -519,6 +519,13 @@
519/******************************************************************************519/******************************************************************************
520520
521********************************************************************************/521********************************************************************************/
522ValueTreeIndex::KeyIterator::KeyIterator(const IndexMap& aMap)
523 :
524 theMap(aMap)
525{
526}
527
528
522ValueTreeIndex::KeyIterator::~KeyIterator()529ValueTreeIndex::KeyIterator::~KeyIterator()
523{530{
524};531};
@@ -526,21 +533,29 @@
526533
527void ValueTreeIndex::KeyIterator::open()534void ValueTreeIndex::KeyIterator::open()
528{535{
529 assert(false);536 theIterator = theMap.begin();
530}537}
531538
532539
533bool ValueTreeIndex::KeyIterator::next(store::IndexKey&)540bool ValueTreeIndex::KeyIterator::next(store::IndexKey& aKey)
534{541{
535 assert(false);542 if (theIterator != theMap.end())
543 {
544 const store::IndexKey* lKey = (*theIterator).first;
545 aKey = *lKey;
546
547 ++theIterator;
548 return true;
549 }
536 return false;550 return false;
537}551}
538552
539553
540void ValueTreeIndex::KeyIterator::close()554void ValueTreeIndex::KeyIterator::close()
541{555{
542 assert(false);556 theIterator = theMap.end();
543}557};
558
544559
545560
546/******************************************************************************561/******************************************************************************
@@ -596,8 +611,7 @@
596********************************************************************************/611********************************************************************************/
597store::Index::KeyIterator_t ValueTreeIndex::keys() const612store::Index::KeyIterator_t ValueTreeIndex::keys() const
598{613{
599 assert(false);614 return new KeyIterator(theMap);
600 return 0;
601}615}
602616
603617
604618
=== modified file 'src/store/naive/simple_index_value.h'
--- src/store/naive/simple_index_value.h 2012-01-11 17:30:25 +0000
+++ src/store/naive/simple_index_value.h 2012-01-18 01:11:25 +0000
@@ -198,7 +198,12 @@
198198
199 class KeyIterator : public Index::KeyIterator199 class KeyIterator : public Index::KeyIterator
200 {200 {
201 protected:
202 IndexMap::const_iterator theIterator;
203 const IndexMap & theMap;
204
201 public:205 public:
206 KeyIterator(const IndexMap& aMap);
202 ~KeyIterator();207 ~KeyIterator();
203208
204 void open();209 void open();
205210
=== added file 'test/rbkt/ExpQueryResults/zorba/index/keys1.xml.res'
--- test/rbkt/ExpQueryResults/zorba/index/keys1.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/index/keys1.xml.res 2012-01-18 01:11:25 +0000
@@ -0,0 +1,1 @@
1<keys typeIsInteger="true"><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="10"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="5"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="6"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="1"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="7"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="2"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="8"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="3"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="9"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="4"/></key></keys>
02
=== added file 'test/rbkt/ExpQueryResults/zorba/index/keys2.xml.res'
--- test/rbkt/ExpQueryResults/zorba/index/keys2.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/index/keys2.xml.res 2012-01-18 01:11:25 +0000
@@ -0,0 +1,1 @@
1<keys><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="1"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="2"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="3"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="4"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="5"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="6"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="7"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="8"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="9"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="10"/></key></keys>
02
=== added file 'test/rbkt/Queries/zorba/index/keys1.xq'
--- test/rbkt/Queries/zorba/index/keys1.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/index/keys1.xq 2012-01-18 01:11:25 +0000
@@ -0,0 +1,22 @@
1import module namespace ddl = "http://www.zorba-xquery.com/modules/store/static/collections/ddl";
2import module namespace dml = "http://www.zorba-xquery.com/modules/store/static/collections/dml";
3import module namespace index_ddl = "http://www.zorba-xquery.com/modules/store/static/indexes/ddl";
4import module namespace index_dml = "http://www.zorba-xquery.com/modules/store/static/indexes/dml";
5
6import module namespace keys-lib = "http://www.example.com/" at "keys_mod.xqlib";
7
8ddl:create(xs:QName("keys-lib:foo"));
9index_ddl:create(xs:QName("keys-lib:FooIdx"));
10
11for $i in 1 to 10
12return
13 dml:insert-nodes(xs:QName("keys-lib:foo"),
14 <foo id="{$i}"/>
15 );
16
17let $keys := index_dml:keys(xs:QName("keys-lib:FooIdx"))
18let $attr := $keys[1]/self::*:key/*:attribute/@*:value
19return
20 <keys typeIsInteger="{data($attr) instance of xs:integer}">{
21 $keys
22 }</keys>
023
=== added file 'test/rbkt/Queries/zorba/index/keys2.xq'
--- test/rbkt/Queries/zorba/index/keys2.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/index/keys2.xq 2012-01-18 01:11:25 +0000
@@ -0,0 +1,22 @@
1import module namespace ddl = "http://www.zorba-xquery.com/modules/store/static/collections/ddl";
2import module namespace dml = "http://www.zorba-xquery.com/modules/store/static/collections/dml";
3import module namespace index_ddl = "http://www.zorba-xquery.com/modules/store/static/indexes/ddl";
4import module namespace index_dml = "http://www.zorba-xquery.com/modules/store/static/indexes/dml";
5
6import module namespace keys-lib = "http://www.example.com/" at "keys_mod.xqlib";
7
8ddl:create(xs:QName("keys-lib:foo"));
9index_ddl:create(xs:QName("keys-lib:FooIdx2"));
10
11for $i in 1 to 10
12return
13 dml:insert-nodes(xs:QName("keys-lib:foo"),
14 <foo id="{$i}"/>
15 );
16
17let $keys := index_dml:keys(xs:QName("keys-lib:FooIdx2"))
18return
19 <keys>{
20 $keys
21 }</keys>
22
023
=== added file 'test/rbkt/Queries/zorba/index/keys_mod.xqlib'
--- test/rbkt/Queries/zorba/index/keys_mod.xqlib 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/index/keys_mod.xqlib 2012-01-18 01:11:25 +0000
@@ -0,0 +1,15 @@
1module namespace keys-lib = "http://www.example.com/";
2
3import module namespace dml = "http://www.zorba-xquery.com/modules/store/static/collections/dml";
4
5declare namespace ann = "http://www.zorba-xquery.com/annotations";
6
7declare %ann:unordered collection keys-lib:foo as node()*;
8
9declare %ann:automatic %ann:value-equality index keys-lib:FooIdx
10 on nodes dml:collection(xs:QName("keys-lib:foo"))
11 by xs:integer(./@id) as xs:integer;
12
13declare %ann:automatic %ann:value-range index keys-lib:FooIdx2
14 on nodes dml:collection(xs:QName("keys-lib:foo"))
15 by xs:integer(./@id) as xs:integer;

Subscribers

People subscribed via source and target branches