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

Proposed by Matthias Brantner on 2012-01-18
Status: Superseded
Proposed branch: lp:~zorba-coders/zorba/bug900677
Merge into: lp:zorba
Diff against target: 1250 lines (+905/-16)
31 files modified
ChangeLog (+2/-0)
doc/zorba/xqddf.dox (+21/-0)
modules/com/zorba-xquery/www/modules/store/static/indexes/dml.xq (+24/-0)
src/diagnostics/diagnostic_en.xml (+1/-1)
src/diagnostics/pregenerated/dict_en.cpp (+1/-1)
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 (+105/-0)
src/runtime/indexing/index_util.h (+114/-0)
src/runtime/indexing/pregenerated/index_func.cpp (+81/-0)
src/runtime/indexing/pregenerated/index_func.h (+91/-0)
src/runtime/pregenerated/iterator_enum.h (+1/-0)
src/runtime/spec/indexing/index_func.xml (+55/-0)
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_general.cpp (+51/-7)
src/store/naive/simple_index_general.h (+11/-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/keys1g.xml.res (+32/-0)
test/rbkt/ExpQueryResults/zorba/index/keys2.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/index/keys3.xml.res (+1/-0)
test/rbkt/Queries/zorba/index/keys1.xq (+22/-0)
test/rbkt/Queries/zorba/index/keys1g.xq (+26/-0)
test/rbkt/Queries/zorba/index/keys2.xq (+22/-0)
test/rbkt/Queries/zorba/index/keys3.xq (+21/-0)
test/rbkt/Queries/zorba/index/keys_mod.xqlib (+40/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/bug900677
Reviewer Review Type Date Requested Status
Markos Zaharioudakis 2012-01-18 Needs Fixing on 2012-07-13
Matthias Brantner Needs Information on 2012-01-18
William Candillon 2012-01-18 Needs Information on 2012-01-18
Review via email: mp+88973@code.launchpad.net

This proposal supersedes 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.
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

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

Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug900677-2012-01-18T01-16-57.605Z is finished. The final status was:

All tests succeeded!

Zorba Build Bot (zorba-buildbot) wrote :

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

William Candillon (wcandillon) wrote :

It looks very good.

Should the actual atomic type be present in the attribute element?
If you have "by @id" where @id can be 1 or "1", you might want to create two index keys?
If a key returns (), you might want to distinguish with empty string for probing later?

By using keys(), I got the following output:
<key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="hello"></attribute><attribute value="4"></attribute></key>

Is the namespace useful or does it just make the life of the user harder?
Why isn't it:
<keys><key value="hello" /><key value="4" /></keys>
Again, could you explain me how I'm supposed to probe from such XDM if one of the actual key returned empty sequence? Should the keys have a position attribute or something?

The doc/zorba/xqddf.dox doesn't seem to mention the function, it should no?

The xqdoc seems to have a formatting problem: the output example for keys() goes out of its box.

review: Needs Information

> Should the actual atomic type be present in the attribute element?
What's the use case for this? The type is declared in the index which should be know by the user. It could be done but it's not clear how this would look like. Do you want the QName of the atomic type of the sequence type?

> If you have "by @id" where @id can be 1 or "1", you might want to create two
> index keys?
I don't understand this.

> If a key returns (), you might want to distinguish with empty string for
> probing later?
I have made a fix such that the value attribute is only present if the entry is not the empty sequence.

> By using keys(), I got the following output:
> <key xmlns="http://www.zorba-
> xquery.com/modules/store/static/indexes/dml"><attribute
> value="hello"></attribute><attribute value="4"></attribute></key>
>
> Is the namespace useful or does it just make the life of the user harder?
It's consistent with the keys function of the maps module. We can remove it but should remove it for both then (which is a backwards incompatible change).

> Why isn't it:
> <keys><key value="hello" /><key value="4" /></keys>
> Again, could you explain me how I'm supposed to probe from such XDM if one of
> the actual key returned empty sequence?
Is there a way to probe for entries where one of the keys is the empty sequence? I don't think there
is. We should have a separate bug for this.

> Should the keys have a position attribute or something?
The index of the attribute elements determines the position. Is an additional attribute really needed?

> The doc/zorba/xqddf.dox doesn't seem to mention the function, it should no?
Yes, that's done.

> > The xqdoc seems to have a formatting problem: the output example for keys()
> goes out of its box.
Fixed.

review: Needs Information
lp:~zorba-coders/zorba/bug900677 updated on 2012-01-18
10622. By Matthias Brantner on 2012-01-18

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

William Candillon (wcandillon) wrote :

> > Should the actual atomic type be present in the attribute element?
> What's the use case for this? The type is declared in the index which should
> be know by the user. It could be done but it's not clear how this would look
> like. Do you want the QName of the atomic type of the sequence type?
>
> > If you have "by @id" where @id can be 1 or "1", you might want to create two
> > index keys?
> I don't understand this.
Is it possible to have an index key as xs:anyAtomicType?
If yes, you might have an index key of value xs:string("1") and another key of value xs:integer(1).
Is this use case possible?

>
> > If a key returns (), you might want to distinguish with empty string for
> > probing later?
> I have made a fix such that the value attribute is only present if the entry
> is not the empty sequence.
Cool.
Consider the following index key declaration:
by xs:string(@team) as xs:string,
   xs:string(@country) as xs:string?,
   xs:string(@league) as xs:string?;

If keys() returns:
<keys>
  <key value="Foo" />
  <key value="Bar" />
</keys>
It's not good because I cannot probe the index with this info.
Does it makes sense?

>
>
> > By using keys(), I got the following output:
> > <key xmlns="http://www.zorba-
> > xquery.com/modules/store/static/indexes/dml"><attribute
> > value="hello"></attribute><attribute value="4"></attribute></key>
> >
> > Is the namespace useful or does it just make the life of the user harder?
> It's consistent with the keys function of the maps module. We can remove it
> but should remove it for both then (which is a backwards incompatible change).
I would fix it here and fix it for map() in 3.0.
Except if the local name attribute means something.

>
> > Why isn't it:
> > <keys><key value="hello" /><key value="4" /></keys>
> > Again, could you explain me how I'm supposed to probe from such XDM if one
> of
> > the actual key returned empty sequence?
> Is there a way to probe for entries where one of the keys is the empty
> sequence? I don't think there
> is. We should have a separate bug for this.
In Sausalito it's possible.
It was the only way to replace a particular query with an index.
How do we go forward on this?

>
> > Should the keys have a position attribute or something?
> The index of the attribute elements determines the position. Is an additional
> attribute really needed?
>
> > The doc/zorba/xqddf.dox doesn't seem to mention the function, it should no?
> Yes, that's done.
>
> > > The xqdoc seems to have a formatting problem: the output example for
> keys()
> > goes out of its box.
> Fixed.

William Candillon (wcandillon) wrote :

I hope that these comments are a little bit more clear.
I'm just trying to make sure of a single thing which is:
- Anything that is returned by keys() must be easily fed back in probe-index-point()

Therefore I'm wondering about index key types and index keys with empty sequence.

Markos Zaharioudakis (markos-za) wrote :

Matthias, the function is not implemented for general indexes, right? If yes, you should say this in the documentation and raise appropriate error in the code, unless you plan to extend it to general indexes before the next release.

Markos Zaharioudakis (markos-za) wrote :

> > > Should the actual atomic type be present in the attribute element?
> > What's the use case for this? The type is declared in the index which should
> > be know by the user. It could be done but it's not clear how this would look
> > like. Do you want the QName of the atomic type of the sequence type?
> >
> > > If you have "by @id" where @id can be 1 or "1", you might want to create
> two
> > > index keys?
> > I don't understand this.
> Is it possible to have an index key as xs:anyAtomicType?
> If yes, you might have an index key of value xs:string("1") and another key of
> value xs:integer(1).
> Is this use case possible?
>

It is not for value indexes, but it is for general indexes. Currently, the keys() function is not implemented for general indexes. If it is implemented for general indexes, then the type info should be included.

> >
> > > If a key returns (), you might want to distinguish with empty string for
> > > probing later?
> > I have made a fix such that the value attribute is only present if the entry
> > is not the empty sequence.
> Cool.
> Consider the following index key declaration:
> by xs:string(@team) as xs:string,
> xs:string(@country) as xs:string?,
> xs:string(@league) as xs:string?;
>
> If keys() returns:
> <keys>
> <key value="Foo" />
> <key value="Bar" />
> </keys>
> It's not good because I cannot probe the index with this info.
> Does it makes sense?
>
Yes, William is right. I think we need an extra attribute per key item. The attribute name would be something like "is_empty", and its value "true" or "false". The is_empty attribute could be optional; if it is not there, "false" is implied.

By the way, I really dislike "attribute" as the tag name of an element. Something like "key_item" would have been much better.

> >
> >
> > > By using keys(), I got the following output:
> > > <key xmlns="http://www.zorba-
> > > xquery.com/modules/store/static/indexes/dml"><attribute
> > > value="hello"></attribute><attribute value="4"></attribute></key>
> > >
> > > Is the namespace useful or does it just make the life of the user harder?
> > It's consistent with the keys function of the maps module. We can remove it
> > but should remove it for both then (which is a backwards incompatible
> change).
> I would fix it here and fix it for map() in 3.0.
> Except if the local name attribute means something.
>

I don't have a strong preference for this. Either way looks ok to me.

William Candillon (wcandillon) wrote :

> > > > Should the actual atomic type be present in the attribute element?
> > > What's the use case for this? The type is declared in the index which
> should
> > > be know by the user. It could be done but it's not clear how this would
> look
> > > like. Do you want the QName of the atomic type of the sequence type?
> > >
> > > > If you have "by @id" where @id can be 1 or "1", you might want to create
> > two
> > > > index keys?
> > > I don't understand this.
> > Is it possible to have an index key as xs:anyAtomicType?
> > If yes, you might have an index key of value xs:string("1") and another key
> of
> > value xs:integer(1).
> > Is this use case possible?
> >
>
> It is not for value indexes, but it is for general indexes. Currently, the
> keys() function is not implemented for general indexes. If it is implemented
> for general indexes, then the type info should be included.
>
>
> > >
> > > > If a key returns (), you might want to distinguish with empty string for
> > > > probing later?
> > > I have made a fix such that the value attribute is only present if the
> entry
> > > is not the empty sequence.
> > Cool.
> > Consider the following index key declaration:
> > by xs:string(@team) as xs:string,
> > xs:string(@country) as xs:string?,
> > xs:string(@league) as xs:string?;
> >
> > If keys() returns:
> > <keys>
> > <key value="Foo" />
> > <key value="Bar" />
> > </keys>
> > It's not good because I cannot probe the index with this info.
> > Does it makes sense?
> >
> Yes, William is right. I think we need an extra attribute per key item. The
> attribute name would be something like "is_empty", and its value "true" or
> "false". The is_empty attribute could be optional; if it is not there, "false"
> is implied.
>
> By the way, I really dislike "attribute" as the tag name of an element.
> Something like "key_item" would have been much better.
>
> > >
> > >
> > > > By using keys(), I got the following output:
> > > > <key xmlns="http://www.zorba-
> > > > xquery.com/modules/store/static/indexes/dml"><attribute
> > > > value="hello"></attribute><attribute value="4"></attribute></key>
> > > >
> > > > Is the namespace useful or does it just make the life of the user
> harder?
> > > It's consistent with the keys function of the maps module. We can remove
> it
> > > but should remove it for both then (which is a backwards incompatible
> > change).
> > I would fix it here and fix it for map() in 3.0.
> > Except if the local name attribute means something.
> >
>
> I don't have a strong preference for this. Either way looks ok to me.
So sorry it's a mistake from me, I meant to write about the local-name attribute, I'm fine with the namespace.

lp:~zorba-coders/zorba/bug900677 updated on 2012-07-12
10623. By Matthias Brantner on 2012-05-11

merge

10624. By David Graf on 2012-07-12

merged trunk

10625. By David Graf on 2012-07-12

regenerated stuff

10626. By David Graf on 2012-07-12

fixed merge bug

Markos Zaharioudakis (markos-za) wrote :

1. The function::producesDistinctNodes() and function::producesSortedNodes() methods must be redefined for the keys function.

2. Why not use element()* as the return type of keys?

3. IndexKeysIterator::nextImpl() create a new QName (lKeyNodeName) every time it is called, and the same QName is created again (!) in createIndexKeyElement(). The QName must be created only once, in the IndexKeysIterator constructor and stored as a data member. Same for the other constant qnames used in the constructed XML tree.

4. No need for a new file and class to implement function createIndexKeyElement(). You can just add it as a static function in index_func_impl.cpp

5. The type of the value attribute should be xs:untypedAtomic, not xs:untyped

review: Needs Fixing
Markos Zaharioudakis (markos-za) wrote :

Also, the documentation should say that the function is not yet implemented for general indexes, and the implementation should throw an error in this case.

lp:~zorba-coders/zorba/bug900677 updated on 2012-08-03
10627. By David Graf on 2012-07-13

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

10628. By David Graf on 2012-07-13

index-keys function test for general index

10629. By David Graf on 2012-07-16

added some comments

10630. By Matthias Brantner on 2012-07-20

merge with trunk

10631. By Matthias Brantner on 2012-07-20

minor cleanup

10632. By David Graf on 2012-08-02

merged trunk

10633. By David Graf on 2012-08-02

merged trunk

10634. By David Graf on 2012-08-03

merged trunk

10635. By David Graf on 2012-08-03

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-07-20 02:54:05 +0000
+++ ChangeLog 2012-07-20 23:53:19 +0000
@@ -17,6 +17,8 @@
17 http://www.zorba-xquery.com/modules/store/data-structures/unordered-map module.17 http://www.zorba-xquery.com/modules/store/data-structures/unordered-map module.
18 * Added support for fragments to fn:path18 * Added support for fragments to fn:path
19 * Positional pagination support for collections19 * Positional pagination support for collections
20 * Added a function to the http://www.zorba-xquery.com/modules/store/static/indexes/dml module which returns
21 the value of all keys contained in an index.
20 * Incremental maintenance for general indexes.22 * Incremental maintenance for general indexes.
21 23
22Optimizations:24Optimizations:
2325
=== modified file 'doc/zorba/xqddf.dox'
--- doc/zorba/xqddf.dox 2012-07-12 17:29:55 +0000
+++ doc/zorba/xqddf.dox 2012-07-20 23:53:19 +0000
@@ -1984,6 +1984,27 @@
1984</li>1984</li>
1985</ul>1985</ul>
19861986
1987\subsection index_keys Retrieving Index Keys
1988In addition to probing an index, the <tt>idml</tt> module also provides a function that allows listing all the keys contained in an index.
1989
1990\code
1991 idml:keys($indexName as xs:QName) as item()*
1992\endcode
1993
1994This function returns a sequence of element nodes.
1995Each node in the sequence represents one key contained in the index and has the following structure:
1996
1997\code
1998 <key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml">
1999 <attribute value="key_1"/>
2000 ...
2001 <attribute value="key_n"/>
2002 </key>
2003\endcode
2004
2005The order of the attribute elements reflects the order of the key specifications in the declaration of the index.
2006Also, the types of the values of the attributes are the types of the keys as they are declared.
2007If a value attribute is not present, this means that the value of the corresponding key in the index is the empty sequence.
19872008
1988\subsection index_maintenance Index Maintenance2009\subsection index_maintenance Index Maintenance
19892010
19902011
=== modified file 'modules/com/zorba-xquery/www/modules/store/static/indexes/dml.xq'
--- modules/com/zorba-xquery/www/modules/store/static/indexes/dml.xq 2012-07-12 17:29:55 +0000
+++ modules/com/zorba-xquery/www/modules/store/static/indexes/dml.xq 2012-07-20 23:53:19 +0000
@@ -268,3 +268,27 @@
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. Each element has the following structure:
274 : <pre class="brush: xml;">
275 : &lt;key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"&gt;
276 : &lt;attribute value="key1_value"/&gt;
277 : &lt;attribute value="key2_value"/&gt;
278 : &lt;attribute value="key3_value"/&gt;
279 : &lt;/key&gt;
280 : </pre>
281 :
282 : @param $name The QName of the index
283 : @return The result of the function is sequence of elements each representing
284 : one key contained in the index.
285 :
286 : Note that the order of the attribute elements reflects the order of
287 : the keys in the index specification. Also note that the values in
288 : these attributes have the type that is declared in the corresponding
289 : index specification.
290 :
291 : @error zerr:ZDDY0021 if the index with name $name is not declared.
292 : @error zerr:ZDDY0023 if the index with name $name does not exist.
293 :)
294declare function idml:keys($name as xs:QName) as node()* external;
271295
=== modified file 'src/diagnostics/diagnostic_en.xml'
--- src/diagnostics/diagnostic_en.xml 2012-07-17 13:37:41 +0000
+++ src/diagnostics/diagnostic_en.xml 2012-07-20 23:53:19 +0000
@@ -2254,7 +2254,7 @@
2254 </diagnostic>2254 </diagnostic>
22552255
2256 <diagnostic code="ZDST0035" name="INDEX_GENERAL_MULTIKEY">2256 <diagnostic code="ZDST0035" name="INDEX_GENERAL_MULTIKEY">
2257 <value>"$1": index general multikey</value>2257 <value>"$1": number of key expressions for general indexes is restricted to one expression</value>
2258 </diagnostic>2258 </diagnostic>
22592259
2260 <diagnostic code="ZDST0036" name="INDEX_DECL_IN_FOREIGN_MODULE">2260 <diagnostic code="ZDST0036" name="INDEX_DECL_IN_FOREIGN_MODULE">
22612261
=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
--- src/diagnostics/pregenerated/dict_en.cpp 2012-07-17 13:37:41 +0000
+++ src/diagnostics/pregenerated/dict_en.cpp 2012-07-20 23:53:19 +0000
@@ -380,7 +380,7 @@
380 { "ZDST0032", "\"$1\": index references context item" },380 { "ZDST0032", "\"$1\": index references context item" },
381 { "ZDST0033", "\"$1\": index non-simple expression" },381 { "ZDST0033", "\"$1\": index non-simple expression" },
382 { "ZDST0034", "\"$1\": index can not do automatic maintenance" },382 { "ZDST0034", "\"$1\": index can not do automatic maintenance" },
383 { "ZDST0035", "\"$1\": index general multikey" },383 { "ZDST0035", "\"$1\": number of key expressions for general indexes is restricted one expression" },
384 { "ZDST0036", "\"$1\": index declaration in foreign module" },384 { "ZDST0036", "\"$1\": index declaration in foreign module" },
385 { "ZDST0041", "\"$1\": integrity constraint already declared" },385 { "ZDST0041", "\"$1\": integrity constraint already declared" },
386 { "ZDST0044", "\"$1\": integrity constraint declaration not allowed in main module" },386 { "ZDST0044", "\"$1\": integrity constraint declaration not allowed in main module" },
387387
=== modified file 'src/functions/library.cpp'
--- src/functions/library.cpp 2012-07-12 17:29:55 +0000
+++ src/functions/library.cpp 2012-07-20 23:53:19 +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"
@@ -122,6 +123,7 @@
122 populate_context_errors_and_diagnostics(sctx);123 populate_context_errors_and_diagnostics(sctx);
123 populate_context_fnput(sctx);124 populate_context_fnput(sctx);
124 populate_context_index_ddl(sctx);125 populate_context_index_ddl(sctx);
126 populate_context_index_func(sctx);
125 populate_context_ic_ddl(sctx);127 populate_context_ic_ddl(sctx);
126 populate_context_json(sctx);128 populate_context_json(sctx);
127 populate_context_maths(sctx);129 populate_context_maths(sctx);
128130
=== 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-07-20 23:53:19 +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 expr& 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-07-20 23:53:19 +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-07-12 17:29:55 +0000
+++ src/functions/pregenerated/function_enum.h 2012-07-20 23:53:19 +0000
@@ -197,6 +197,7 @@
197 ZORBA_STORE_INTEGRITY_CONSTRAINTS_STATIC_DDL_ACTIVATE_1,197 ZORBA_STORE_INTEGRITY_CONSTRAINTS_STATIC_DDL_ACTIVATE_1,
198 ZORBA_STORE_INTEGRITY_CONSTRAINTS_STATIC_DDL_DEACTIVATE_1,198 ZORBA_STORE_INTEGRITY_CONSTRAINTS_STATIC_DDL_DEACTIVATE_1,
199 ZORBA_STORE_INTEGRITY_CONSTRAINTS_STATIC_DML_CHECK_INTEGRITY_CONSTRAINT_1,199 ZORBA_STORE_INTEGRITY_CONSTRAINTS_STATIC_DML_CHECK_INTEGRITY_CONSTRAINT_1,
200 ZORBA_STORE_INDEXES_STATIC_DML_KEYS_1,
200 FN_ZORBA_INTROSPECT_SCTX_STATICALLY_KNOWN_NAMESPACES_0,201 FN_ZORBA_INTROSPECT_SCTX_STATICALLY_KNOWN_NAMESPACES_0,
201 FN_ZORBA_INTROSPECT_SCTX_DEFAULT_FUNCTION_NAMESPACE_0,202 FN_ZORBA_INTROSPECT_SCTX_DEFAULT_FUNCTION_NAMESPACE_0,
202 FN_ZORBA_INTROSPECT_SCTX_BASE_URI_0,203 FN_ZORBA_INTROSPECT_SCTX_BASE_URI_0,
203204
=== 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-07-20 23:53:19 +0000
@@ -0,0 +1,105 @@
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 std::cout << "hallo " << lIndex->getSpecification().theIsGeneral << std::endl;
93 IndexUtil::createIndexKeyElement(
94 lIndex->getSpecification().theIsGeneral,
95 result, lKey, static_context::ZORBA_STORE_STATIC_INDEXES_DML_FN_NS
96 );
97 STACK_PUSH(true, state);
98 }
99
100 STACK_END(state);
101}
102
103} // namespace zorba
104/* vim:set et sw=2 ts=2: */
105
0106
=== 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-07-20 23:53:19 +0000
@@ -0,0 +1,114 @@
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 bool aIsGeneralIndex,
50 store::Item_t& result,
51 store::IndexKey& aKey,
52 const zstring& aBase)
53 {
54 store::Item_t lKeyNodeName;
55 GENV_ITEMFACTORY->createQName(lKeyNodeName,
56 aBase, "", "key");
57
58 zstring lBase = aBase;
59
60 store::Item_t lTypeName = GENV_TYPESYSTEM.XS_UNTYPED_QNAME;
61
62 const store::NsBindings lBindings;
63
64 GENV_ITEMFACTORY->createElementNode(
65 result, NULL, lKeyNodeName, lTypeName,
66 true, false, lBindings, lBase);
67
68 for (store::ItemVector::iterator lIter = aKey.begin();
69 lIter != aKey.end();
70 ++lIter)
71 {
72 store::Item_t lAttrElem, lAttrNodeName;
73 store::Item_t lNameAttr, lValueAttr, lValueAttrName;
74 store::Item_t lTypeAttr, lTypeAttrName;
75
76 GENV_ITEMFACTORY->createQName(lAttrNodeName,
77 lBase, "", "attribute");
78
79 lTypeName = GENV_TYPESYSTEM.XS_UNTYPED_QNAME;
80 GENV_ITEMFACTORY->createElementNode(
81 lAttrElem, result, lAttrNodeName, lTypeName,
82 true, false, lBindings, lBase);
83
84 if (*lIter != NULL)
85 {
86
87 if (aIsGeneralIndex)
88 {
89 // for general indices, the type of index key values
90 // is returned too
91 GENV_ITEMFACTORY->createQName(lTypeAttrName,
92 "", "", "type");
93
94 store::Item_t lType = (*lIter)->getType();
95 GENV_ITEMFACTORY->createAttributeNode(
96 lValueAttr, lAttrElem.getp(), lTypeAttrName,
97 lTypeName, lType);
98 }
99
100 GENV_ITEMFACTORY->createQName(lValueAttrName,
101 "", "", "value");
102
103 lTypeName = GENV_TYPESYSTEM.XS_UNTYPED_QNAME;
104 GENV_ITEMFACTORY->createAttributeNode(
105 lValueAttr, lAttrElem.getp(), lValueAttrName, lTypeName, (*lIter));
106
107 }
108 }
109 }
110}; /* class IndexUtil */
111
112} // namespace zorba
113/* vim:set et sw=2 ts=2: */
114#endif
0115
=== 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-07-20 23:53:19 +0000
@@ -0,0 +1,81 @@
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>
37SERIALIZABLE_CLASS_VERSIONS(IndexKeysIterator)
38
39void IndexKeysIterator::serialize(::zorba::serialization::Archiver& ar)
40{
41 serialize_baseclass(ar,
42 (NaryBaseIterator<IndexKeysIterator, IndexKeysIteratorState>*)this);
43
44 ar & theNSBindings;
45}
46
47
48void IndexKeysIterator::accept(PlanIterVisitor& v) const
49{
50 v.beginVisit(*this);
51
52 std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
53 std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
54 for ( ; lIter != lEnd; ++lIter ){
55 (*lIter)->accept(v);
56 }
57
58 v.endVisit(*this);
59}
60
61IndexKeysIterator::~IndexKeysIterator() {}
62
63IndexKeysIteratorState::IndexKeysIteratorState() {}
64
65IndexKeysIteratorState::~IndexKeysIteratorState() {}
66
67
68void IndexKeysIteratorState::init(PlanState& planState) {
69 PlanIteratorState::init(planState);
70}
71
72void IndexKeysIteratorState::reset(PlanState& planState) {
73 PlanIteratorState::reset(planState);
74}
75// </IndexKeysIterator>
76
77
78
79}
80
81
082
=== 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-07-20 23:53:19 +0000
@@ -0,0 +1,91 @@
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 IndexKeysIterator(
69 static_context* sctx,
70 const QueryLoc& loc,
71 std::vector<PlanIter_t>& children)
72 :
73 NaryBaseIterator<IndexKeysIterator, IndexKeysIteratorState>(sctx, loc, children),
74 theNSBindings()
75 {}
76
77 virtual ~IndexKeysIterator();
78
79 void accept(PlanIterVisitor& v) const;
80
81 bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
82};
83
84
85}
86#endif
87/*
88 * Local variables:
89 * mode: c++
90 * End:
91 */
092
=== modified file 'src/runtime/pregenerated/iterator_enum.h'
--- src/runtime/pregenerated/iterator_enum.h 2012-07-11 15:38:39 +0000
+++ src/runtime/pregenerated/iterator_enum.h 2012-07-20 23:53:19 +0000
@@ -123,6 +123,7 @@
123 TYPE_ActivateICIterator,123 TYPE_ActivateICIterator,
124 TYPE_DeactivateICIterator,124 TYPE_DeactivateICIterator,
125 TYPE_CheckICIterator,125 TYPE_CheckICIterator,
126 TYPE_IndexKeysIterator,
126 TYPE_StaticNamespacesIterator,127 TYPE_StaticNamespacesIterator,
127 TYPE_DefaultFunctionNamespaceIterator,128 TYPE_DefaultFunctionNamespaceIterator,
128 TYPE_SctxBaseUriIterator,129 TYPE_SctxBaseUriIterator,
129130
=== 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-07-20 23:53:19 +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/visitors/pregenerated/planiter_visitor.h'
--- src/runtime/visitors/pregenerated/planiter_visitor.h 2012-07-12 17:29:55 +0000
+++ src/runtime/visitors/pregenerated/planiter_visitor.h 2012-07-20 23:53:19 +0000
@@ -252,6 +252,8 @@
252252
253 class CheckICIterator;253 class CheckICIterator;
254254
255 class IndexKeysIterator;
256
255 class StaticNamespacesIterator;257 class StaticNamespacesIterator;
256258
257 class DefaultFunctionNamespaceIterator;259 class DefaultFunctionNamespaceIterator;
@@ -1047,6 +1049,9 @@
1047 virtual void beginVisit ( const CheckICIterator& ) = 0;1049 virtual void beginVisit ( const CheckICIterator& ) = 0;
1048 virtual void endVisit ( const CheckICIterator& ) = 0;1050 virtual void endVisit ( const CheckICIterator& ) = 0;
10491051
1052 virtual void beginVisit ( const IndexKeysIterator& ) = 0;
1053 virtual void endVisit ( const IndexKeysIterator& ) = 0;
1054
1050 virtual void beginVisit ( const StaticNamespacesIterator& ) = 0;1055 virtual void beginVisit ( const StaticNamespacesIterator& ) = 0;
1051 virtual void endVisit ( const StaticNamespacesIterator& ) = 0;1056 virtual void endVisit ( const StaticNamespacesIterator& ) = 0;
10521057
10531058
=== modified file 'src/runtime/visitors/pregenerated/printer_visitor.cpp'
--- src/runtime/visitors/pregenerated/printer_visitor.cpp 2012-07-12 17:29:55 +0000
+++ src/runtime/visitors/pregenerated/printer_visitor.cpp 2012-07-20 23:53:19 +0000
@@ -50,6 +50,7 @@
50#include "runtime/full_text/ft_module.h"50#include "runtime/full_text/ft_module.h"
51#include "runtime/function_item/function_item_iter.h"51#include "runtime/function_item/function_item_iter.h"
52#include "runtime/indexing/ic_ddl.h"52#include "runtime/indexing/ic_ddl.h"
53#include "runtime/indexing/index_func.h"
53#include "runtime/introspection/sctx.h"54#include "runtime/introspection/sctx.h"
54#include "runtime/json/json.h"55#include "runtime/json/json.h"
55#include "runtime/json/jsoniq_functions.h"56#include "runtime/json/jsoniq_functions.h"
@@ -1571,6 +1572,20 @@
1571// </CheckICIterator>1572// </CheckICIterator>
15721573
15731574
1575// <IndexKeysIterator>
1576void PrinterVisitor::beginVisit ( const IndexKeysIterator& a) {
1577 thePrinter.startBeginVisit("IndexKeysIterator", ++theId);
1578 printCommons( &a, theId );
1579 thePrinter.endBeginVisit( theId );
1580}
1581
1582void PrinterVisitor::endVisit ( const IndexKeysIterator& ) {
1583 thePrinter.startEndVisit();
1584 thePrinter.endEndVisit();
1585}
1586// </IndexKeysIterator>
1587
1588
1574// <StaticNamespacesIterator>1589// <StaticNamespacesIterator>
1575void PrinterVisitor::beginVisit ( const StaticNamespacesIterator& a) {1590void PrinterVisitor::beginVisit ( const StaticNamespacesIterator& a) {
1576 thePrinter.startBeginVisit("StaticNamespacesIterator", ++theId);1591 thePrinter.startBeginVisit("StaticNamespacesIterator", ++theId);
15771592
=== modified file 'src/runtime/visitors/pregenerated/printer_visitor.h'
--- src/runtime/visitors/pregenerated/printer_visitor.h 2012-07-12 17:29:55 +0000
+++ src/runtime/visitors/pregenerated/printer_visitor.h 2012-07-20 23:53:19 +0000
@@ -388,6 +388,9 @@
388 void beginVisit( const CheckICIterator& );388 void beginVisit( const CheckICIterator& );
389 void endVisit ( const CheckICIterator& );389 void endVisit ( const CheckICIterator& );
390390
391 void beginVisit( const IndexKeysIterator& );
392 void endVisit ( const IndexKeysIterator& );
393
391 void beginVisit( const StaticNamespacesIterator& );394 void beginVisit( const StaticNamespacesIterator& );
392 void endVisit ( const StaticNamespacesIterator& );395 void endVisit ( const StaticNamespacesIterator& );
393396
394397
=== modified file 'src/store/naive/simple_index_general.cpp'
--- src/store/naive/simple_index_general.cpp 2012-07-12 17:29:55 +0000
+++ src/store/naive/simple_index_general.cpp 2012-07-20 23:53:19 +0000
@@ -1151,8 +1151,7 @@
1151*******************************************************************************/1151*******************************************************************************/
1152store::Index::KeyIterator_t GeneralHashIndex::keys() const1152store::Index::KeyIterator_t GeneralHashIndex::keys() const
1153{1153{
1154 assert(false);1154 return new KeyIterator(theMaps);
1155 return 0;
1156}1155}
11571156
11581157
@@ -1255,6 +1254,14 @@
1255// //1254// //
1256/////////////////////////////////////////////////////////////////////////////////1255/////////////////////////////////////////////////////////////////////////////////
12571256
1257/*******************************************************************************
1258
1259********************************************************************************/
1260GeneralHashIndex::KeyIterator::KeyIterator(IndexMap* const* aMaps)
1261 :
1262 theMaps(aMaps)
1263{
1264}
12581265
1259/******************************************************************************1266/******************************************************************************
12601267
@@ -1263,23 +1270,60 @@
1263{1270{
1264}1271}
12651272
1273/******************************************************************************
1274 * moves theIterator to the next available iterator from theMaps
1275*******************************************************************************/
1276void GeneralHashIndex::KeyIterator::setNextIter()
1277{
1278 for ( ;
1279 theCurType < store::XS_LAST && theMaps[theCurType] == 0;
1280 ++theCurType)
1281 {}
1282
1283 if (theCurType != store::XS_LAST)
1284 theIterator = theMaps[theCurType]->begin();
1285}
12661286
1267/******************************************************************************1287/******************************************************************************
12681288
1269*******************************************************************************/1289*******************************************************************************/
1270void GeneralHashIndex::KeyIterator::open()1290void GeneralHashIndex::KeyIterator::open()
1271{1291{
1272 assert(false);1292 // start with first type from zorba::store::SchemaTypeCode enum
1293 theCurType = 0;
1294 // Index doesn't contain keys from all atomic types -> we need to skip the
1295 // empty ones.
1296 setNextIter();
1273}1297}
12741298
12751299
1276/******************************************************************************1300/******************************************************************************
12771301
1278*******************************************************************************/1302*******************************************************************************/
1279bool GeneralHashIndex::KeyIterator::next(store::IndexKey&)1303bool GeneralHashIndex::KeyIterator::next(store::IndexKey& aKey)
1280{1304{
1281 assert(false);1305 // XS_LAST marks the end of the type list -> we stop
1282 return false;1306 if (theCurType == store::XS_LAST)
1307 return false;
1308
1309 const store::Item* lKeyItem = (*theIterator).first;
1310 // the general index doesn't return an IndexKey object because
1311 // it doesn't support multi-value keys -> we push the key directly
1312 // into the passed IndexKey.
1313 aKey.empty();
1314 aKey.push_back(const_cast<zorba::store::Item*>(lKeyItem));
1315
1316 ++theIterator;
1317
1318 if (theIterator == theMaps[theCurType]->end())
1319 {
1320 // iteration of the keys of the current type is done.
1321 // increase type and search for the next valid iterator.
1322 ++theCurType;
1323 setNextIter();
1324 }
1325
1326 return true;
1283}1327}
12841328
12851329
@@ -1288,7 +1332,7 @@
1288*******************************************************************************/1332*******************************************************************************/
1289void GeneralHashIndex::KeyIterator::close()1333void GeneralHashIndex::KeyIterator::close()
1290{1334{
1291 assert(false);1335 theCurType = store::XS_LAST;
1292}1336}
12931337
12941338
12951339
=== modified file 'src/store/naive/simple_index_general.h'
--- src/store/naive/simple_index_general.h 2012-07-12 17:29:55 +0000
+++ src/store/naive/simple_index_general.h 2012-07-20 23:53:19 +0000
@@ -220,14 +220,25 @@
220220
221 typedef IndexMap::iterator EntryIterator;221 typedef IndexMap::iterator EntryIterator;
222222
223 /*
224 * This iterator iterates over all index keys from all types
225 */
223 class KeyIterator : public Index::KeyIterator226 class KeyIterator : public Index::KeyIterator
224 {227 {
228 protected:
229 IndexMap::iterator theIterator;
230 IndexMap* const* theMaps;
231 ulong theCurType;
225 public:232 public:
233 KeyIterator(IndexMap* const* aMaps);
226 ~KeyIterator();234 ~KeyIterator();
227235
228 void open();236 void open();
229 bool next(store::IndexKey&);237 bool next(store::IndexKey&);
230 void close();238 void close();
239
240 private:
241 void setNextIter();
231 };242 };
232243
233 typedef rchandle<KeyIterator> KeyIterator_t;244 typedef rchandle<KeyIterator> KeyIterator_t;
234245
=== modified file 'src/store/naive/simple_index_value.cpp'
--- src/store/naive/simple_index_value.cpp 2012-07-12 17:29:55 +0000
+++ src/store/naive/simple_index_value.cpp 2012-07-20 23:53:19 +0000
@@ -563,6 +563,13 @@
563/******************************************************************************563/******************************************************************************
564564
565********************************************************************************/565********************************************************************************/
566ValueTreeIndex::KeyIterator::KeyIterator(const IndexMap& aMap)
567 :
568 theMap(aMap)
569{
570}
571
572
566ValueTreeIndex::KeyIterator::~KeyIterator()573ValueTreeIndex::KeyIterator::~KeyIterator()
567{574{
568};575};
@@ -570,21 +577,29 @@
570577
571void ValueTreeIndex::KeyIterator::open()578void ValueTreeIndex::KeyIterator::open()
572{579{
573 assert(false);580 theIterator = theMap.begin();
574}581}
575582
576583
577bool ValueTreeIndex::KeyIterator::next(store::IndexKey&)584bool ValueTreeIndex::KeyIterator::next(store::IndexKey& aKey)
578{585{
579 assert(false);586 if (theIterator != theMap.end())
587 {
588 const store::IndexKey* lKey = (*theIterator).first;
589 aKey = *lKey;
590
591 ++theIterator;
592 return true;
593 }
580 return false;594 return false;
581}595}
582596
583597
584void ValueTreeIndex::KeyIterator::close()598void ValueTreeIndex::KeyIterator::close()
585{599{
586 assert(false);600 theIterator = theMap.end();
587}601};
602
588603
589604
590/******************************************************************************605/******************************************************************************
@@ -652,8 +667,7 @@
652********************************************************************************/667********************************************************************************/
653store::Index::KeyIterator_t ValueTreeIndex::keys() const668store::Index::KeyIterator_t ValueTreeIndex::keys() const
654{669{
655 assert(false);670 return new KeyIterator(theMap);
656 return 0;
657}671}
658672
659673
660674
=== modified file 'src/store/naive/simple_index_value.h'
--- src/store/naive/simple_index_value.h 2012-07-12 17:29:55 +0000
+++ src/store/naive/simple_index_value.h 2012-07-20 23:53:19 +0000
@@ -208,7 +208,12 @@
208208
209 class KeyIterator : public Index::KeyIterator209 class KeyIterator : public Index::KeyIterator
210 {210 {
211 protected:
212 IndexMap::const_iterator theIterator;
213 const IndexMap & theMap;
214
211 public:215 public:
216 KeyIterator(const IndexMap& aMap);
212 ~KeyIterator();217 ~KeyIterator();
213218
214 void open();219 void open();
215220
=== 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-07-20 23:53:19 +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/keys1g.xml.res'
--- test/rbkt/ExpQueryResults/zorba/index/keys1g.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/index/keys1g.xml.res 2012-07-20 23:53:19 +0000
@@ -0,0 +1,32 @@
1<keys>
2 <key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml">
3 <attribute type="xs:string" value="2"></attribute>
4 </key>
5 <key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml">
6 <attribute type="xs:string" value="6"></attribute>
7 </key>
8 <key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml">
9 <attribute type="xs:string" value="4"></attribute>
10 </key>
11 <key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml">
12 <attribute type="xs:string" value="10"></attribute>
13 </key>
14 <key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml">
15 <attribute type="xs:string" value="8"></attribute>
16 </key>
17 <key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml">
18 <attribute type="xs:long" value="0"></attribute>
19 </key>
20 <key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml">
21 <attribute type="xs:long" value="6"></attribute>
22 </key>
23 <key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml">
24 <attribute type="xs:long" value="2"></attribute>
25 </key>
26 <key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml">
27 <attribute type="xs:long" value="8"></attribute>
28 </key>
29 <key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml">
30 <attribute type="xs:long" value="4"></attribute>
31 </key>
32</keys>
033
=== 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-07-20 23:53:19 +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/ExpQueryResults/zorba/index/keys3.xml.res'
--- test/rbkt/ExpQueryResults/zorba/index/keys3.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/index/keys3.xml.res 2012-07-20 23:53:19 +0000
@@ -0,0 +1,1 @@
1<keys><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="1"/><attribute/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="10"/><attribute value="me"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="2"/><attribute/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="3"/><attribute/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="4"/><attribute/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="5"/><attribute value="me"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="6"/><attribute/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="7"/><attribute/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="8"/><attribute/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="9"/><attribute/></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-07-20 23:53:19 +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/keys1g.xq'
--- test/rbkt/Queries/zorba/index/keys1g.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/index/keys1g.xq 2012-07-20 23:53:19 +0000
@@ -0,0 +1,26 @@
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-general"));
10
11for $i in 1 to 10
12return
13 dml:insert-nodes(xs:QName("keys-lib:foo"),
14 if ($i mod 2 = 0) then
15 <foo id="{$i}"/>
16 else
17 <foo id="{$i - 1}" string="true"/>
18 );
19
20let $keys := index_dml:keys(xs:QName("keys-lib:FooIdx-general"))
21let $attr := $keys[1]/self::*:key/*:attribute/@*:value
22return
23 <keys>{
24 $keys
25 }</keys>
26
027
=== 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-07-20 23:53:19 +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/keys3.xq'
--- test/rbkt/Queries/zorba/index/keys3.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/index/keys3.xq 2012-07-20 23:53:19 +0000
@@ -0,0 +1,21 @@
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:FooIdx3"));
10
11for $i in 1 to 10
12return
13 dml:insert-nodes(xs:QName("keys-lib:foo"),
14 if ($i mod 5 eq 0) then <foo id="{$i}" name="me"/> else <foo id="{$i}"/>
15 );
16
17let $keys := index_dml:keys(xs:QName("keys-lib:FooIdx3"))
18return
19 <keys>{
20 $keys
21 }</keys>
022
=== 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-07-20 23:53:19 +0000
@@ -0,0 +1,40 @@
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;
16
17declare %ann:automatic %ann:value-range index keys-lib:FooIdx3
18 on nodes dml:collection(xs:QName("keys-lib:foo"))
19 by xs:string(./@id) as xs:string, (if (./@name) then xs:string(./@name) else ()) as xs:string?;
20
21declare %ann:automatic %ann:general-equality index keys-lib:FooIdx-general
22 on nodes dml:collection(xs:QName("keys-lib:foo"))
23 by
24 (
25 let $val := fn:data(./@id)
26 return
27 if (./@string) then
28 xs:long($val)
29 else
30 xs:string($val)
31 )
32 as xs:anyAtomicType;
33
34declare %ann:automatic %ann:general-range index keys-lib:FooIdx2-general
35 on nodes dml:collection(xs:QName("keys-lib:foo"))
36 by xs:integer(./@id) as xs:integer;
37
38declare %ann:automatic %ann:general-range index keys-lib:FooIdx3-general
39 on nodes dml:collection(xs:QName("keys-lib:foo"))
40 by (if (./@name) then xs:string(./@name) else ()) as xs:string?;

Subscribers

People subscribed via source and target branches