Merge lp:~zorba-coders/zorba/bug900677 into lp:zorba
- bug900677
- Merge into trunk
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 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Markos Zaharioudakis | Needs Fixing | ||
Matthias Brantner | Needs Information | ||
William Candillon | Needs Information | ||
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.
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/
Validation queue job bug900677-2012-01-
final status was:
No tests were run - build or configure step must have failed.
Not commiting changes.
Error in read script: /home/ceej/
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job bug900677-2012-01-
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://
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.
Matthias Brantner (matthias-brantner) 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.
> 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://
> xquery.
> value="
>
> 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.
- 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.
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(
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://
> > xquery.
> > value="
> >
> > 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://
> > > xquery.
> > > value="
> > >
> > > 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://
> > > > xquery.
> > > > value="
> > > >
> > > > 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.
- 10623. By Matthias Brantner
-
merge
- 10624. By David Graf
-
merged trunk
- 10625. By David Graf
-
regenerated stuff
- 10626. By David Graf
-
fixed merge bug
Markos Zaharioudakis (markos-za) wrote : | # |
1. The function:
2. Why not use element()* as the return type of keys?
3. IndexKeysIterat
4. No need for a new file and class to implement function createIndexKeyE
5. The type of the value attribute should be xs:untypedAtomic, not xs:untyped
Markos Zaharioudakis (markos-za) : | # |
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.
- 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
1 | === modified file 'ChangeLog' | |||
2 | --- ChangeLog 2012-07-20 02:54:05 +0000 | |||
3 | +++ ChangeLog 2012-07-20 23:53:19 +0000 | |||
4 | @@ -17,6 +17,8 @@ | |||
5 | 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. |
6 | 18 | * Added support for fragments to fn:path | 18 | * Added support for fragments to fn:path |
7 | 19 | * Positional pagination support for collections | 19 | * Positional pagination support for collections |
8 | 20 | * Added a function to the http://www.zorba-xquery.com/modules/store/static/indexes/dml module which returns | ||
9 | 21 | the value of all keys contained in an index. | ||
10 | 20 | * Incremental maintenance for general indexes. | 22 | * Incremental maintenance for general indexes. |
11 | 21 | 23 | ||
12 | 22 | Optimizations: | 24 | Optimizations: |
13 | 23 | 25 | ||
14 | === modified file 'doc/zorba/xqddf.dox' | |||
15 | --- doc/zorba/xqddf.dox 2012-07-12 17:29:55 +0000 | |||
16 | +++ doc/zorba/xqddf.dox 2012-07-20 23:53:19 +0000 | |||
17 | @@ -1984,6 +1984,27 @@ | |||
18 | 1984 | </li> | 1984 | </li> |
19 | 1985 | </ul> | 1985 | </ul> |
20 | 1986 | 1986 | ||
21 | 1987 | \subsection index_keys Retrieving Index Keys | ||
22 | 1988 | In addition to probing an index, the <tt>idml</tt> module also provides a function that allows listing all the keys contained in an index. | ||
23 | 1989 | |||
24 | 1990 | \code | ||
25 | 1991 | idml:keys($indexName as xs:QName) as item()* | ||
26 | 1992 | \endcode | ||
27 | 1993 | |||
28 | 1994 | This function returns a sequence of element nodes. | ||
29 | 1995 | Each node in the sequence represents one key contained in the index and has the following structure: | ||
30 | 1996 | |||
31 | 1997 | \code | ||
32 | 1998 | <key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"> | ||
33 | 1999 | <attribute value="key_1"/> | ||
34 | 2000 | ... | ||
35 | 2001 | <attribute value="key_n"/> | ||
36 | 2002 | </key> | ||
37 | 2003 | \endcode | ||
38 | 2004 | |||
39 | 2005 | The order of the attribute elements reflects the order of the key specifications in the declaration of the index. | ||
40 | 2006 | Also, the types of the values of the attributes are the types of the keys as they are declared. | ||
41 | 2007 | If a value attribute is not present, this means that the value of the corresponding key in the index is the empty sequence. | ||
42 | 1987 | 2008 | ||
43 | 1988 | \subsection index_maintenance Index Maintenance | 2009 | \subsection index_maintenance Index Maintenance |
44 | 1989 | 2010 | ||
45 | 1990 | 2011 | ||
46 | === modified file 'modules/com/zorba-xquery/www/modules/store/static/indexes/dml.xq' | |||
47 | --- modules/com/zorba-xquery/www/modules/store/static/indexes/dml.xq 2012-07-12 17:29:55 +0000 | |||
48 | +++ modules/com/zorba-xquery/www/modules/store/static/indexes/dml.xq 2012-07-20 23:53:19 +0000 | |||
49 | @@ -268,3 +268,27 @@ | |||
50 | 268 | :) | 268 | :) |
51 | 269 | declare updating function idml:refresh-index($name as xs:QName) external; | 269 | declare updating function idml:refresh-index($name as xs:QName) external; |
52 | 270 | 270 | ||
53 | 271 | (:~ | ||
54 | 272 | : The keys function returns a sequence of all keys contained in the | ||
55 | 273 | : index with the given name. Each element has the following structure: | ||
56 | 274 | : <pre class="brush: xml;"> | ||
57 | 275 | : <key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"> | ||
58 | 276 | : <attribute value="key1_value"/> | ||
59 | 277 | : <attribute value="key2_value"/> | ||
60 | 278 | : <attribute value="key3_value"/> | ||
61 | 279 | : </key> | ||
62 | 280 | : </pre> | ||
63 | 281 | : | ||
64 | 282 | : @param $name The QName of the index | ||
65 | 283 | : @return The result of the function is sequence of elements each representing | ||
66 | 284 | : one key contained in the index. | ||
67 | 285 | : | ||
68 | 286 | : Note that the order of the attribute elements reflects the order of | ||
69 | 287 | : the keys in the index specification. Also note that the values in | ||
70 | 288 | : these attributes have the type that is declared in the corresponding | ||
71 | 289 | : index specification. | ||
72 | 290 | : | ||
73 | 291 | : @error zerr:ZDDY0021 if the index with name $name is not declared. | ||
74 | 292 | : @error zerr:ZDDY0023 if the index with name $name does not exist. | ||
75 | 293 | :) | ||
76 | 294 | declare function idml:keys($name as xs:QName) as node()* external; | ||
77 | 271 | 295 | ||
78 | === modified file 'src/diagnostics/diagnostic_en.xml' | |||
79 | --- src/diagnostics/diagnostic_en.xml 2012-07-17 13:37:41 +0000 | |||
80 | +++ src/diagnostics/diagnostic_en.xml 2012-07-20 23:53:19 +0000 | |||
81 | @@ -2254,7 +2254,7 @@ | |||
82 | 2254 | </diagnostic> | 2254 | </diagnostic> |
83 | 2255 | 2255 | ||
84 | 2256 | <diagnostic code="ZDST0035" name="INDEX_GENERAL_MULTIKEY"> | 2256 | <diagnostic code="ZDST0035" name="INDEX_GENERAL_MULTIKEY"> |
86 | 2257 | <value>"$1": index general multikey</value> | 2257 | <value>"$1": number of key expressions for general indexes is restricted to one expression</value> |
87 | 2258 | </diagnostic> | 2258 | </diagnostic> |
88 | 2259 | 2259 | ||
89 | 2260 | <diagnostic code="ZDST0036" name="INDEX_DECL_IN_FOREIGN_MODULE"> | 2260 | <diagnostic code="ZDST0036" name="INDEX_DECL_IN_FOREIGN_MODULE"> |
90 | 2261 | 2261 | ||
91 | === modified file 'src/diagnostics/pregenerated/dict_en.cpp' | |||
92 | --- src/diagnostics/pregenerated/dict_en.cpp 2012-07-17 13:37:41 +0000 | |||
93 | +++ src/diagnostics/pregenerated/dict_en.cpp 2012-07-20 23:53:19 +0000 | |||
94 | @@ -380,7 +380,7 @@ | |||
95 | 380 | { "ZDST0032", "\"$1\": index references context item" }, | 380 | { "ZDST0032", "\"$1\": index references context item" }, |
96 | 381 | { "ZDST0033", "\"$1\": index non-simple expression" }, | 381 | { "ZDST0033", "\"$1\": index non-simple expression" }, |
97 | 382 | { "ZDST0034", "\"$1\": index can not do automatic maintenance" }, | 382 | { "ZDST0034", "\"$1\": index can not do automatic maintenance" }, |
99 | 383 | { "ZDST0035", "\"$1\": index general multikey" }, | 383 | { "ZDST0035", "\"$1\": number of key expressions for general indexes is restricted one expression" }, |
100 | 384 | { "ZDST0036", "\"$1\": index declaration in foreign module" }, | 384 | { "ZDST0036", "\"$1\": index declaration in foreign module" }, |
101 | 385 | { "ZDST0041", "\"$1\": integrity constraint already declared" }, | 385 | { "ZDST0041", "\"$1\": integrity constraint already declared" }, |
102 | 386 | { "ZDST0044", "\"$1\": integrity constraint declaration not allowed in main module" }, | 386 | { "ZDST0044", "\"$1\": integrity constraint declaration not allowed in main module" }, |
103 | 387 | 387 | ||
104 | === modified file 'src/functions/library.cpp' | |||
105 | --- src/functions/library.cpp 2012-07-12 17:29:55 +0000 | |||
106 | +++ src/functions/library.cpp 2012-07-20 23:53:19 +0000 | |||
107 | @@ -41,6 +41,7 @@ | |||
108 | 41 | #include "functions/func_fnput.h" | 41 | #include "functions/func_fnput.h" |
109 | 42 | #include "functions/func_hoist.h" | 42 | #include "functions/func_hoist.h" |
110 | 43 | #include "functions/func_index_ddl.h" | 43 | #include "functions/func_index_ddl.h" |
111 | 44 | #include "functions/func_index_func.h" | ||
112 | 44 | #include "functions/func_ic_ddl.h" | 45 | #include "functions/func_ic_ddl.h" |
113 | 45 | #include "functions/func_maths.h" | 46 | #include "functions/func_maths.h" |
114 | 46 | #include "functions/func_nodes.h" | 47 | #include "functions/func_nodes.h" |
115 | @@ -122,6 +123,7 @@ | |||
116 | 122 | populate_context_errors_and_diagnostics(sctx); | 123 | populate_context_errors_and_diagnostics(sctx); |
117 | 123 | populate_context_fnput(sctx); | 124 | populate_context_fnput(sctx); |
118 | 124 | populate_context_index_ddl(sctx); | 125 | populate_context_index_ddl(sctx); |
119 | 126 | populate_context_index_func(sctx); | ||
120 | 125 | populate_context_ic_ddl(sctx); | 127 | populate_context_ic_ddl(sctx); |
121 | 126 | populate_context_json(sctx); | 128 | populate_context_json(sctx); |
122 | 127 | populate_context_maths(sctx); | 129 | populate_context_maths(sctx); |
123 | 128 | 130 | ||
124 | === added file 'src/functions/pregenerated/func_index_func.cpp' | |||
125 | --- src/functions/pregenerated/func_index_func.cpp 1970-01-01 00:00:00 +0000 | |||
126 | +++ src/functions/pregenerated/func_index_func.cpp 2012-07-20 23:53:19 +0000 | |||
127 | @@ -0,0 +1,63 @@ | |||
128 | 1 | /* | ||
129 | 2 | * Copyright 2006-2008 The FLWOR Foundation. | ||
130 | 3 | * | ||
131 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
132 | 5 | * you may not use this file except in compliance with the License. | ||
133 | 6 | * You may obtain a copy of the License at | ||
134 | 7 | * | ||
135 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
136 | 9 | * | ||
137 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
138 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
139 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
140 | 13 | * See the License for the specific language governing permissions and | ||
141 | 14 | * limitations under the License. | ||
142 | 15 | */ | ||
143 | 16 | |||
144 | 17 | // ****************************************** | ||
145 | 18 | // * * | ||
146 | 19 | // * THIS IS A GENERATED FILE. DO NOT EDIT! * | ||
147 | 20 | // * SEE .xml FILE WITH SAME NAME * | ||
148 | 21 | // * * | ||
149 | 22 | // ****************************************** | ||
150 | 23 | |||
151 | 24 | |||
152 | 25 | #include "stdafx.h" | ||
153 | 26 | #include "runtime/indexing/index_func.h" | ||
154 | 27 | #include "functions/func_index_func.h" | ||
155 | 28 | |||
156 | 29 | |||
157 | 30 | namespace zorba{ | ||
158 | 31 | |||
159 | 32 | |||
160 | 33 | |||
161 | 34 | PlanIter_t zorba_store_indexes_static_dml_keys::codegen( | ||
162 | 35 | CompilerCB*, | ||
163 | 36 | static_context* sctx, | ||
164 | 37 | const QueryLoc& loc, | ||
165 | 38 | std::vector<PlanIter_t>& argv, | ||
166 | 39 | expr& ann) const | ||
167 | 40 | { | ||
168 | 41 | return new IndexKeysIterator(sctx, loc, argv); | ||
169 | 42 | } | ||
170 | 43 | |||
171 | 44 | void populate_context_index_func(static_context* sctx) | ||
172 | 45 | { | ||
173 | 46 | |||
174 | 47 | |||
175 | 48 | { | ||
176 | 49 | DECL_WITH_KIND(sctx, zorba_store_indexes_static_dml_keys, | ||
177 | 50 | (createQName("http://www.zorba-xquery.com/modules/store/static/indexes/dml","","keys"), | ||
178 | 51 | GENV_TYPESYSTEM.QNAME_TYPE_ONE, | ||
179 | 52 | GENV_TYPESYSTEM.ANY_NODE_TYPE_STAR), | ||
180 | 53 | FunctionConsts::ZORBA_STORE_INDEXES_STATIC_DML_KEYS_1); | ||
181 | 54 | |||
182 | 55 | } | ||
183 | 56 | |||
184 | 57 | } | ||
185 | 58 | |||
186 | 59 | |||
187 | 60 | } | ||
188 | 61 | |||
189 | 62 | |||
190 | 63 | |||
191 | 0 | 64 | ||
192 | === added file 'src/functions/pregenerated/func_index_func.h' | |||
193 | --- src/functions/pregenerated/func_index_func.h 1970-01-01 00:00:00 +0000 | |||
194 | +++ src/functions/pregenerated/func_index_func.h 2012-07-20 23:53:19 +0000 | |||
195 | @@ -0,0 +1,66 @@ | |||
196 | 1 | /* | ||
197 | 2 | * Copyright 2006-2008 The FLWOR Foundation. | ||
198 | 3 | * | ||
199 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
200 | 5 | * you may not use this file except in compliance with the License. | ||
201 | 6 | * You may obtain a copy of the License at | ||
202 | 7 | * | ||
203 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
204 | 9 | * | ||
205 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
206 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
207 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
208 | 13 | * See the License for the specific language governing permissions and | ||
209 | 14 | * limitations under the License. | ||
210 | 15 | */ | ||
211 | 16 | |||
212 | 17 | // ****************************************** | ||
213 | 18 | // * * | ||
214 | 19 | // * THIS IS A GENERATED FILE. DO NOT EDIT! * | ||
215 | 20 | // * SEE .xml FILE WITH SAME NAME * | ||
216 | 21 | // * * | ||
217 | 22 | // ****************************************** | ||
218 | 23 | |||
219 | 24 | |||
220 | 25 | #ifndef ZORBA_FUNCTIONS_INDEX_FUNC_H | ||
221 | 26 | #define ZORBA_FUNCTIONS_INDEX_FUNC_H | ||
222 | 27 | |||
223 | 28 | |||
224 | 29 | #include "common/shared_types.h" | ||
225 | 30 | #include "functions/function_impl.h" | ||
226 | 31 | |||
227 | 32 | |||
228 | 33 | namespace zorba { | ||
229 | 34 | |||
230 | 35 | |||
231 | 36 | void populate_context_index_func(static_context* sctx); | ||
232 | 37 | |||
233 | 38 | |||
234 | 39 | |||
235 | 40 | |||
236 | 41 | //zorba-store-indexes-static-dml:keys | ||
237 | 42 | class zorba_store_indexes_static_dml_keys : public function | ||
238 | 43 | { | ||
239 | 44 | public: | ||
240 | 45 | zorba_store_indexes_static_dml_keys(const signature& sig, FunctionConsts::FunctionKind kind) | ||
241 | 46 | : | ||
242 | 47 | function(sig, kind) | ||
243 | 48 | { | ||
244 | 49 | |||
245 | 50 | } | ||
246 | 51 | |||
247 | 52 | bool accessesDynCtx() const { return true; } | ||
248 | 53 | |||
249 | 54 | CODEGEN_DECL(); | ||
250 | 55 | }; | ||
251 | 56 | |||
252 | 57 | |||
253 | 58 | } //namespace zorba | ||
254 | 59 | |||
255 | 60 | |||
256 | 61 | #endif | ||
257 | 62 | /* | ||
258 | 63 | * Local variables: | ||
259 | 64 | * mode: c++ | ||
260 | 65 | * End: | ||
261 | 66 | */ | ||
262 | 0 | 67 | ||
263 | === modified file 'src/functions/pregenerated/function_enum.h' | |||
264 | --- src/functions/pregenerated/function_enum.h 2012-07-12 17:29:55 +0000 | |||
265 | +++ src/functions/pregenerated/function_enum.h 2012-07-20 23:53:19 +0000 | |||
266 | @@ -197,6 +197,7 @@ | |||
267 | 197 | ZORBA_STORE_INTEGRITY_CONSTRAINTS_STATIC_DDL_ACTIVATE_1, | 197 | ZORBA_STORE_INTEGRITY_CONSTRAINTS_STATIC_DDL_ACTIVATE_1, |
268 | 198 | ZORBA_STORE_INTEGRITY_CONSTRAINTS_STATIC_DDL_DEACTIVATE_1, | 198 | ZORBA_STORE_INTEGRITY_CONSTRAINTS_STATIC_DDL_DEACTIVATE_1, |
269 | 199 | ZORBA_STORE_INTEGRITY_CONSTRAINTS_STATIC_DML_CHECK_INTEGRITY_CONSTRAINT_1, | 199 | ZORBA_STORE_INTEGRITY_CONSTRAINTS_STATIC_DML_CHECK_INTEGRITY_CONSTRAINT_1, |
270 | 200 | ZORBA_STORE_INDEXES_STATIC_DML_KEYS_1, | ||
271 | 200 | FN_ZORBA_INTROSPECT_SCTX_STATICALLY_KNOWN_NAMESPACES_0, | 201 | FN_ZORBA_INTROSPECT_SCTX_STATICALLY_KNOWN_NAMESPACES_0, |
272 | 201 | FN_ZORBA_INTROSPECT_SCTX_DEFAULT_FUNCTION_NAMESPACE_0, | 202 | FN_ZORBA_INTROSPECT_SCTX_DEFAULT_FUNCTION_NAMESPACE_0, |
273 | 202 | FN_ZORBA_INTROSPECT_SCTX_BASE_URI_0, | 203 | FN_ZORBA_INTROSPECT_SCTX_BASE_URI_0, |
274 | 203 | 204 | ||
275 | === added file 'src/runtime/indexing/index_func_impl.cpp' | |||
276 | --- src/runtime/indexing/index_func_impl.cpp 1970-01-01 00:00:00 +0000 | |||
277 | +++ src/runtime/indexing/index_func_impl.cpp 2012-07-20 23:53:19 +0000 | |||
278 | @@ -0,0 +1,105 @@ | |||
279 | 1 | /* | ||
280 | 2 | * Copyright 2006-2012 The FLWOR Foundation. | ||
281 | 3 | * | ||
282 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
283 | 5 | * you may not use this file except in compliance with the License. | ||
284 | 6 | * You may obtain a copy of the License at | ||
285 | 7 | * | ||
286 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
287 | 9 | * | ||
288 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
289 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
290 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
291 | 13 | * See the License for the specific language governing permissions and | ||
292 | 14 | * limitations under the License. | ||
293 | 15 | */ | ||
294 | 16 | #include "stdafx.h" | ||
295 | 17 | |||
296 | 18 | #include "diagnostics/assert.h" | ||
297 | 19 | #include "diagnostics/xquery_diagnostics.h" | ||
298 | 20 | |||
299 | 21 | #include "zorbatypes/URI.h" | ||
300 | 22 | |||
301 | 23 | #include "system/globalenv.h" | ||
302 | 24 | |||
303 | 25 | #include "runtime/indexing/index_func.h" | ||
304 | 26 | #include "runtime/indexing/index_util.h" | ||
305 | 27 | |||
306 | 28 | #include "context/namespace_context.h" | ||
307 | 29 | #include "context/static_context.h" | ||
308 | 30 | |||
309 | 31 | #include "store/api/item.h" | ||
310 | 32 | #include "store/api/index.h" | ||
311 | 33 | |||
312 | 34 | #include "compiler/xqddf/value_index.h" | ||
313 | 35 | |||
314 | 36 | namespace zorba { | ||
315 | 37 | |||
316 | 38 | /******************************************************************************* | ||
317 | 39 | ********************************************************************************/ | ||
318 | 40 | bool | ||
319 | 41 | IndexKeysIterator::nextImpl( | ||
320 | 42 | store::Item_t& result, | ||
321 | 43 | PlanState& aPlanState) const | ||
322 | 44 | { | ||
323 | 45 | store::Item_t lQName; | ||
324 | 46 | IndexDecl_t indexDecl; | ||
325 | 47 | store::Index* lIndex; | ||
326 | 48 | store::IndexKey lKey; | ||
327 | 49 | |||
328 | 50 | store::Item_t lKeyNodeName; | ||
329 | 51 | GENV_ITEMFACTORY->createQName(lKeyNodeName, | ||
330 | 52 | static_context::ZORBA_STORE_DYNAMIC_UNORDERED_MAP_FN_NS, | ||
331 | 53 | "", "key"); | ||
332 | 54 | |||
333 | 55 | IndexKeysIteratorState* state; | ||
334 | 56 | DEFAULT_STACK_INIT(IndexKeysIteratorState, state, aPlanState); | ||
335 | 57 | |||
336 | 58 | consumeNext(lQName, theChildren[0].getp(), aPlanState); | ||
337 | 59 | |||
338 | 60 | if ((indexDecl = theSctx->lookup_index(lQName)) == NULL) | ||
339 | 61 | { | ||
340 | 62 | throw XQUERY_EXCEPTION( | ||
341 | 63 | zerr::ZDDY0021_INDEX_NOT_DECLARED, | ||
342 | 64 | ERROR_PARAMS( lQName->getStringValue() ), | ||
343 | 65 | ERROR_LOC( loc ) | ||
344 | 66 | ); | ||
345 | 67 | } | ||
346 | 68 | |||
347 | 69 | lIndex = GENV_STORE.getIndex(lQName); | ||
348 | 70 | |||
349 | 71 | if (!lIndex) | ||
350 | 72 | { | ||
351 | 73 | throw XQUERY_EXCEPTION( | ||
352 | 74 | zerr::ZDDY0023_INDEX_DOES_NOT_EXIST, | ||
353 | 75 | ERROR_PARAMS( lQName->getStringValue() ), | ||
354 | 76 | ERROR_LOC( loc ) | ||
355 | 77 | ); | ||
356 | 78 | } | ||
357 | 79 | |||
358 | 80 | state->theIter = lIndex->keys(); | ||
359 | 81 | |||
360 | 82 | state->theIter->open(); | ||
361 | 83 | |||
362 | 84 | // generate result elements of the form | ||
363 | 85 | // <key> | ||
364 | 86 | // <attribute value="key1_value"/> | ||
365 | 87 | // <attribute value="key2_value"/> | ||
366 | 88 | // <attribute value="key3_value"/> | ||
367 | 89 | // </key> | ||
368 | 90 | while (state->theIter->next(lKey)) | ||
369 | 91 | { | ||
370 | 92 | std::cout << "hallo " << lIndex->getSpecification().theIsGeneral << std::endl; | ||
371 | 93 | IndexUtil::createIndexKeyElement( | ||
372 | 94 | lIndex->getSpecification().theIsGeneral, | ||
373 | 95 | result, lKey, static_context::ZORBA_STORE_STATIC_INDEXES_DML_FN_NS | ||
374 | 96 | ); | ||
375 | 97 | STACK_PUSH(true, state); | ||
376 | 98 | } | ||
377 | 99 | |||
378 | 100 | STACK_END(state); | ||
379 | 101 | } | ||
380 | 102 | |||
381 | 103 | } // namespace zorba | ||
382 | 104 | /* vim:set et sw=2 ts=2: */ | ||
383 | 105 | |||
384 | 0 | 106 | ||
385 | === added file 'src/runtime/indexing/index_util.h' | |||
386 | --- src/runtime/indexing/index_util.h 1970-01-01 00:00:00 +0000 | |||
387 | +++ src/runtime/indexing/index_util.h 2012-07-20 23:53:19 +0000 | |||
388 | @@ -0,0 +1,114 @@ | |||
389 | 1 | /* | ||
390 | 2 | * Copyright 2006-2012 The FLWOR Foundation. | ||
391 | 3 | * | ||
392 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
393 | 5 | * you may not use this file except in compliance with the License. | ||
394 | 6 | * You may obtain a copy of the License at | ||
395 | 7 | * | ||
396 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
397 | 9 | * | ||
398 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
399 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
400 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
401 | 13 | * See the License for the specific language governing permissions and | ||
402 | 14 | * limitations under the License. | ||
403 | 15 | */ | ||
404 | 16 | #ifndef ZORBA_INDEX_UTIL_H | ||
405 | 17 | #define ZORBA_INDEX_UTIL_H | ||
406 | 18 | |||
407 | 19 | #include "stdafx.h" | ||
408 | 20 | |||
409 | 21 | #include "context/namespace_context.h" | ||
410 | 22 | |||
411 | 23 | #include "store/api/pul.h" | ||
412 | 24 | #include "store/api/store.h" | ||
413 | 25 | #include "store/api/item.h" | ||
414 | 26 | #include "store/api/item_factory.h" | ||
415 | 27 | #include "store/api/iterator.h" | ||
416 | 28 | #include "store/api/index.h" | ||
417 | 29 | |||
418 | 30 | #include "types/typeimpl.h" | ||
419 | 31 | #include "types/typeops.h" | ||
420 | 32 | #include "types/casting.h" | ||
421 | 33 | |||
422 | 34 | namespace zorba { | ||
423 | 35 | |||
424 | 36 | class IndexUtil | ||
425 | 37 | { | ||
426 | 38 | public: | ||
427 | 39 | /******************************************************************************* | ||
428 | 40 | generate result elements of the form | ||
429 | 41 | <aBase:key> | ||
430 | 42 | <aBase:attribute aBase:value="key1_value"/> | ||
431 | 43 | <aBase:attribute aBase:value="key2_value"/> | ||
432 | 44 | <aBase:attribute aBase:value="key3_value"/> | ||
433 | 45 | </aBase:key> | ||
434 | 46 | ********************************************************************************/ | ||
435 | 47 | static void | ||
436 | 48 | createIndexKeyElement( | ||
437 | 49 | bool aIsGeneralIndex, | ||
438 | 50 | store::Item_t& result, | ||
439 | 51 | store::IndexKey& aKey, | ||
440 | 52 | const zstring& aBase) | ||
441 | 53 | { | ||
442 | 54 | store::Item_t lKeyNodeName; | ||
443 | 55 | GENV_ITEMFACTORY->createQName(lKeyNodeName, | ||
444 | 56 | aBase, "", "key"); | ||
445 | 57 | |||
446 | 58 | zstring lBase = aBase; | ||
447 | 59 | |||
448 | 60 | store::Item_t lTypeName = GENV_TYPESYSTEM.XS_UNTYPED_QNAME; | ||
449 | 61 | |||
450 | 62 | const store::NsBindings lBindings; | ||
451 | 63 | |||
452 | 64 | GENV_ITEMFACTORY->createElementNode( | ||
453 | 65 | result, NULL, lKeyNodeName, lTypeName, | ||
454 | 66 | true, false, lBindings, lBase); | ||
455 | 67 | |||
456 | 68 | for (store::ItemVector::iterator lIter = aKey.begin(); | ||
457 | 69 | lIter != aKey.end(); | ||
458 | 70 | ++lIter) | ||
459 | 71 | { | ||
460 | 72 | store::Item_t lAttrElem, lAttrNodeName; | ||
461 | 73 | store::Item_t lNameAttr, lValueAttr, lValueAttrName; | ||
462 | 74 | store::Item_t lTypeAttr, lTypeAttrName; | ||
463 | 75 | |||
464 | 76 | GENV_ITEMFACTORY->createQName(lAttrNodeName, | ||
465 | 77 | lBase, "", "attribute"); | ||
466 | 78 | |||
467 | 79 | lTypeName = GENV_TYPESYSTEM.XS_UNTYPED_QNAME; | ||
468 | 80 | GENV_ITEMFACTORY->createElementNode( | ||
469 | 81 | lAttrElem, result, lAttrNodeName, lTypeName, | ||
470 | 82 | true, false, lBindings, lBase); | ||
471 | 83 | |||
472 | 84 | if (*lIter != NULL) | ||
473 | 85 | { | ||
474 | 86 | |||
475 | 87 | if (aIsGeneralIndex) | ||
476 | 88 | { | ||
477 | 89 | // for general indices, the type of index key values | ||
478 | 90 | // is returned too | ||
479 | 91 | GENV_ITEMFACTORY->createQName(lTypeAttrName, | ||
480 | 92 | "", "", "type"); | ||
481 | 93 | |||
482 | 94 | store::Item_t lType = (*lIter)->getType(); | ||
483 | 95 | GENV_ITEMFACTORY->createAttributeNode( | ||
484 | 96 | lValueAttr, lAttrElem.getp(), lTypeAttrName, | ||
485 | 97 | lTypeName, lType); | ||
486 | 98 | } | ||
487 | 99 | |||
488 | 100 | GENV_ITEMFACTORY->createQName(lValueAttrName, | ||
489 | 101 | "", "", "value"); | ||
490 | 102 | |||
491 | 103 | lTypeName = GENV_TYPESYSTEM.XS_UNTYPED_QNAME; | ||
492 | 104 | GENV_ITEMFACTORY->createAttributeNode( | ||
493 | 105 | lValueAttr, lAttrElem.getp(), lValueAttrName, lTypeName, (*lIter)); | ||
494 | 106 | |||
495 | 107 | } | ||
496 | 108 | } | ||
497 | 109 | } | ||
498 | 110 | }; /* class IndexUtil */ | ||
499 | 111 | |||
500 | 112 | } // namespace zorba | ||
501 | 113 | /* vim:set et sw=2 ts=2: */ | ||
502 | 114 | #endif | ||
503 | 0 | 115 | ||
504 | === added file 'src/runtime/indexing/pregenerated/index_func.cpp' | |||
505 | --- src/runtime/indexing/pregenerated/index_func.cpp 1970-01-01 00:00:00 +0000 | |||
506 | +++ src/runtime/indexing/pregenerated/index_func.cpp 2012-07-20 23:53:19 +0000 | |||
507 | @@ -0,0 +1,81 @@ | |||
508 | 1 | /* | ||
509 | 2 | * Copyright 2006-2008 The FLWOR Foundation. | ||
510 | 3 | * | ||
511 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
512 | 5 | * you may not use this file except in compliance with the License. | ||
513 | 6 | * You may obtain a copy of the License at | ||
514 | 7 | * | ||
515 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
516 | 9 | * | ||
517 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
518 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
519 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
520 | 13 | * See the License for the specific language governing permissions and | ||
521 | 14 | * limitations under the License. | ||
522 | 15 | */ | ||
523 | 16 | |||
524 | 17 | // ****************************************** | ||
525 | 18 | // * * | ||
526 | 19 | // * THIS IS A GENERATED FILE. DO NOT EDIT! * | ||
527 | 20 | // * SEE .xml FILE WITH SAME NAME * | ||
528 | 21 | // * * | ||
529 | 22 | // ****************************************** | ||
530 | 23 | |||
531 | 24 | #include "stdafx.h" | ||
532 | 25 | #include "zorbatypes/rchandle.h" | ||
533 | 26 | #include "zorbatypes/zstring.h" | ||
534 | 27 | #include "runtime/visitors/planiter_visitor.h" | ||
535 | 28 | #include "runtime/indexing/index_func.h" | ||
536 | 29 | #include "system/globalenv.h" | ||
537 | 30 | |||
538 | 31 | |||
539 | 32 | #include "store/api/iterator.h" | ||
540 | 33 | |||
541 | 34 | namespace zorba { | ||
542 | 35 | |||
543 | 36 | // <IndexKeysIterator> | ||
544 | 37 | SERIALIZABLE_CLASS_VERSIONS(IndexKeysIterator) | ||
545 | 38 | |||
546 | 39 | void IndexKeysIterator::serialize(::zorba::serialization::Archiver& ar) | ||
547 | 40 | { | ||
548 | 41 | serialize_baseclass(ar, | ||
549 | 42 | (NaryBaseIterator<IndexKeysIterator, IndexKeysIteratorState>*)this); | ||
550 | 43 | |||
551 | 44 | ar & theNSBindings; | ||
552 | 45 | } | ||
553 | 46 | |||
554 | 47 | |||
555 | 48 | void IndexKeysIterator::accept(PlanIterVisitor& v) const | ||
556 | 49 | { | ||
557 | 50 | v.beginVisit(*this); | ||
558 | 51 | |||
559 | 52 | std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin(); | ||
560 | 53 | std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end(); | ||
561 | 54 | for ( ; lIter != lEnd; ++lIter ){ | ||
562 | 55 | (*lIter)->accept(v); | ||
563 | 56 | } | ||
564 | 57 | |||
565 | 58 | v.endVisit(*this); | ||
566 | 59 | } | ||
567 | 60 | |||
568 | 61 | IndexKeysIterator::~IndexKeysIterator() {} | ||
569 | 62 | |||
570 | 63 | IndexKeysIteratorState::IndexKeysIteratorState() {} | ||
571 | 64 | |||
572 | 65 | IndexKeysIteratorState::~IndexKeysIteratorState() {} | ||
573 | 66 | |||
574 | 67 | |||
575 | 68 | void IndexKeysIteratorState::init(PlanState& planState) { | ||
576 | 69 | PlanIteratorState::init(planState); | ||
577 | 70 | } | ||
578 | 71 | |||
579 | 72 | void IndexKeysIteratorState::reset(PlanState& planState) { | ||
580 | 73 | PlanIteratorState::reset(planState); | ||
581 | 74 | } | ||
582 | 75 | // </IndexKeysIterator> | ||
583 | 76 | |||
584 | 77 | |||
585 | 78 | |||
586 | 79 | } | ||
587 | 80 | |||
588 | 81 | |||
589 | 0 | 82 | ||
590 | === added file 'src/runtime/indexing/pregenerated/index_func.h' | |||
591 | --- src/runtime/indexing/pregenerated/index_func.h 1970-01-01 00:00:00 +0000 | |||
592 | +++ src/runtime/indexing/pregenerated/index_func.h 2012-07-20 23:53:19 +0000 | |||
593 | @@ -0,0 +1,91 @@ | |||
594 | 1 | /* | ||
595 | 2 | * Copyright 2006-2008 The FLWOR Foundation. | ||
596 | 3 | * | ||
597 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
598 | 5 | * you may not use this file except in compliance with the License. | ||
599 | 6 | * You may obtain a copy of the License at | ||
600 | 7 | * | ||
601 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
602 | 9 | * | ||
603 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
604 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
605 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
606 | 13 | * See the License for the specific language governing permissions and | ||
607 | 14 | * limitations under the License. | ||
608 | 15 | */ | ||
609 | 16 | |||
610 | 17 | // ****************************************** | ||
611 | 18 | // * * | ||
612 | 19 | // * THIS IS A GENERATED FILE. DO NOT EDIT! * | ||
613 | 20 | // * SEE .xml FILE WITH SAME NAME * | ||
614 | 21 | // * * | ||
615 | 22 | // ****************************************** | ||
616 | 23 | #ifndef ZORBA_RUNTIME_INDEXING_INDEX_FUNC_H | ||
617 | 24 | #define ZORBA_RUNTIME_INDEXING_INDEX_FUNC_H | ||
618 | 25 | |||
619 | 26 | |||
620 | 27 | #include "common/shared_types.h" | ||
621 | 28 | |||
622 | 29 | |||
623 | 30 | |||
624 | 31 | #include "runtime/base/narybase.h" | ||
625 | 32 | #include "store/api/index.h" | ||
626 | 33 | |||
627 | 34 | |||
628 | 35 | namespace zorba { | ||
629 | 36 | |||
630 | 37 | /** | ||
631 | 38 | * | ||
632 | 39 | * keys($iindexName as xs:QName) as () | ||
633 | 40 | * | ||
634 | 41 | * Author: Zorba Team | ||
635 | 42 | */ | ||
636 | 43 | class IndexKeysIteratorState : public PlanIteratorState | ||
637 | 44 | { | ||
638 | 45 | public: | ||
639 | 46 | store::Index::KeyIterator_t theIter; // | ||
640 | 47 | |||
641 | 48 | IndexKeysIteratorState(); | ||
642 | 49 | |||
643 | 50 | ~IndexKeysIteratorState(); | ||
644 | 51 | |||
645 | 52 | void init(PlanState&); | ||
646 | 53 | void reset(PlanState&); | ||
647 | 54 | }; | ||
648 | 55 | |||
649 | 56 | class IndexKeysIterator : public NaryBaseIterator<IndexKeysIterator, IndexKeysIteratorState> | ||
650 | 57 | { | ||
651 | 58 | protected: | ||
652 | 59 | store::NsBindings theNSBindings; // | ||
653 | 60 | public: | ||
654 | 61 | SERIALIZABLE_CLASS(IndexKeysIterator); | ||
655 | 62 | |||
656 | 63 | SERIALIZABLE_CLASS_CONSTRUCTOR2T(IndexKeysIterator, | ||
657 | 64 | NaryBaseIterator<IndexKeysIterator, IndexKeysIteratorState>); | ||
658 | 65 | |||
659 | 66 | void serialize( ::zorba::serialization::Archiver& ar); | ||
660 | 67 | |||
661 | 68 | IndexKeysIterator( | ||
662 | 69 | static_context* sctx, | ||
663 | 70 | const QueryLoc& loc, | ||
664 | 71 | std::vector<PlanIter_t>& children) | ||
665 | 72 | : | ||
666 | 73 | NaryBaseIterator<IndexKeysIterator, IndexKeysIteratorState>(sctx, loc, children), | ||
667 | 74 | theNSBindings() | ||
668 | 75 | {} | ||
669 | 76 | |||
670 | 77 | virtual ~IndexKeysIterator(); | ||
671 | 78 | |||
672 | 79 | void accept(PlanIterVisitor& v) const; | ||
673 | 80 | |||
674 | 81 | bool nextImpl(store::Item_t& result, PlanState& aPlanState) const; | ||
675 | 82 | }; | ||
676 | 83 | |||
677 | 84 | |||
678 | 85 | } | ||
679 | 86 | #endif | ||
680 | 87 | /* | ||
681 | 88 | * Local variables: | ||
682 | 89 | * mode: c++ | ||
683 | 90 | * End: | ||
684 | 91 | */ | ||
685 | 0 | 92 | ||
686 | === modified file 'src/runtime/pregenerated/iterator_enum.h' | |||
687 | --- src/runtime/pregenerated/iterator_enum.h 2012-07-11 15:38:39 +0000 | |||
688 | +++ src/runtime/pregenerated/iterator_enum.h 2012-07-20 23:53:19 +0000 | |||
689 | @@ -123,6 +123,7 @@ | |||
690 | 123 | TYPE_ActivateICIterator, | 123 | TYPE_ActivateICIterator, |
691 | 124 | TYPE_DeactivateICIterator, | 124 | TYPE_DeactivateICIterator, |
692 | 125 | TYPE_CheckICIterator, | 125 | TYPE_CheckICIterator, |
693 | 126 | TYPE_IndexKeysIterator, | ||
694 | 126 | TYPE_StaticNamespacesIterator, | 127 | TYPE_StaticNamespacesIterator, |
695 | 127 | TYPE_DefaultFunctionNamespaceIterator, | 128 | TYPE_DefaultFunctionNamespaceIterator, |
696 | 128 | TYPE_SctxBaseUriIterator, | 129 | TYPE_SctxBaseUriIterator, |
697 | 129 | 130 | ||
698 | === added file 'src/runtime/spec/indexing/index_func.xml' | |||
699 | --- src/runtime/spec/indexing/index_func.xml 1970-01-01 00:00:00 +0000 | |||
700 | +++ src/runtime/spec/indexing/index_func.xml 2012-07-20 23:53:19 +0000 | |||
701 | @@ -0,0 +1,55 @@ | |||
702 | 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
703 | 2 | |||
704 | 3 | <!-- | ||
705 | 4 | //////////////////////////////////////////////////////////////////////////////// | ||
706 | 5 | // // | ||
707 | 6 | // // | ||
708 | 7 | //////////////////////////////////////////////////////////////////////////////// | ||
709 | 8 | --> | ||
710 | 9 | <zorba:iterators | ||
711 | 10 | xmlns:zorba="http://www.zorba-xquery.com" | ||
712 | 11 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
713 | 12 | xsi:schemaLocation="http://www.zorba-xquery.com ../runtime.xsd"> | ||
714 | 13 | |||
715 | 14 | <zorba:source> | ||
716 | 15 | <zorba:include form="Quoted">store/api/iterator.h</zorba:include> | ||
717 | 16 | </zorba:source> | ||
718 | 17 | |||
719 | 18 | <zorba:header> | ||
720 | 19 | <zorba:include form="Quoted">store/api/index.h</zorba:include> | ||
721 | 20 | </zorba:header> | ||
722 | 21 | |||
723 | 22 | <!-- | ||
724 | 23 | /******************************************************************************* | ||
725 | 24 | *******************************************************************************/ | ||
726 | 25 | --> | ||
727 | 26 | <zorba:iterator name="IndexKeysIterator" arity="nary"> | ||
728 | 27 | |||
729 | 28 | <zorba:description author="Zorba Team"> | ||
730 | 29 | keys($iindexName as xs:QName) as () | ||
731 | 30 | </zorba:description> | ||
732 | 31 | |||
733 | 32 | <zorba:function> | ||
734 | 33 | |||
735 | 34 | <zorba:signature localname="keys" | ||
736 | 35 | prefix="zorba-store-indexes-static-dml"> | ||
737 | 36 | <zorba:param>xs:QName</zorba:param> | ||
738 | 37 | <zorba:output>node()*</zorba:output> | ||
739 | 38 | </zorba:signature> | ||
740 | 39 | |||
741 | 40 | <zorba:methods> | ||
742 | 41 | <zorba:accessesDynCtx returnValue="true"/> | ||
743 | 42 | </zorba:methods> | ||
744 | 43 | |||
745 | 44 | </zorba:function> | ||
746 | 45 | |||
747 | 46 | <zorba:state> | ||
748 | 47 | <zorba:member type="store::Index::KeyIterator_t" name="theIter"/> | ||
749 | 48 | </zorba:state> | ||
750 | 49 | |||
751 | 50 | <zorba:member type="store::NsBindings" name="theNSBindings" brief=""/> | ||
752 | 51 | |||
753 | 52 | </zorba:iterator> | ||
754 | 53 | |||
755 | 54 | </zorba:iterators> | ||
756 | 55 | |||
757 | 0 | 56 | ||
758 | === modified file 'src/runtime/visitors/pregenerated/planiter_visitor.h' | |||
759 | --- src/runtime/visitors/pregenerated/planiter_visitor.h 2012-07-12 17:29:55 +0000 | |||
760 | +++ src/runtime/visitors/pregenerated/planiter_visitor.h 2012-07-20 23:53:19 +0000 | |||
761 | @@ -252,6 +252,8 @@ | |||
762 | 252 | 252 | ||
763 | 253 | class CheckICIterator; | 253 | class CheckICIterator; |
764 | 254 | 254 | ||
765 | 255 | class IndexKeysIterator; | ||
766 | 256 | |||
767 | 255 | class StaticNamespacesIterator; | 257 | class StaticNamespacesIterator; |
768 | 256 | 258 | ||
769 | 257 | class DefaultFunctionNamespaceIterator; | 259 | class DefaultFunctionNamespaceIterator; |
770 | @@ -1047,6 +1049,9 @@ | |||
771 | 1047 | virtual void beginVisit ( const CheckICIterator& ) = 0; | 1049 | virtual void beginVisit ( const CheckICIterator& ) = 0; |
772 | 1048 | virtual void endVisit ( const CheckICIterator& ) = 0; | 1050 | virtual void endVisit ( const CheckICIterator& ) = 0; |
773 | 1049 | 1051 | ||
774 | 1052 | virtual void beginVisit ( const IndexKeysIterator& ) = 0; | ||
775 | 1053 | virtual void endVisit ( const IndexKeysIterator& ) = 0; | ||
776 | 1054 | |||
777 | 1050 | virtual void beginVisit ( const StaticNamespacesIterator& ) = 0; | 1055 | virtual void beginVisit ( const StaticNamespacesIterator& ) = 0; |
778 | 1051 | virtual void endVisit ( const StaticNamespacesIterator& ) = 0; | 1056 | virtual void endVisit ( const StaticNamespacesIterator& ) = 0; |
779 | 1052 | 1057 | ||
780 | 1053 | 1058 | ||
781 | === modified file 'src/runtime/visitors/pregenerated/printer_visitor.cpp' | |||
782 | --- src/runtime/visitors/pregenerated/printer_visitor.cpp 2012-07-12 17:29:55 +0000 | |||
783 | +++ src/runtime/visitors/pregenerated/printer_visitor.cpp 2012-07-20 23:53:19 +0000 | |||
784 | @@ -50,6 +50,7 @@ | |||
785 | 50 | #include "runtime/full_text/ft_module.h" | 50 | #include "runtime/full_text/ft_module.h" |
786 | 51 | #include "runtime/function_item/function_item_iter.h" | 51 | #include "runtime/function_item/function_item_iter.h" |
787 | 52 | #include "runtime/indexing/ic_ddl.h" | 52 | #include "runtime/indexing/ic_ddl.h" |
788 | 53 | #include "runtime/indexing/index_func.h" | ||
789 | 53 | #include "runtime/introspection/sctx.h" | 54 | #include "runtime/introspection/sctx.h" |
790 | 54 | #include "runtime/json/json.h" | 55 | #include "runtime/json/json.h" |
791 | 55 | #include "runtime/json/jsoniq_functions.h" | 56 | #include "runtime/json/jsoniq_functions.h" |
792 | @@ -1571,6 +1572,20 @@ | |||
793 | 1571 | // </CheckICIterator> | 1572 | // </CheckICIterator> |
794 | 1572 | 1573 | ||
795 | 1573 | 1574 | ||
796 | 1575 | // <IndexKeysIterator> | ||
797 | 1576 | void PrinterVisitor::beginVisit ( const IndexKeysIterator& a) { | ||
798 | 1577 | thePrinter.startBeginVisit("IndexKeysIterator", ++theId); | ||
799 | 1578 | printCommons( &a, theId ); | ||
800 | 1579 | thePrinter.endBeginVisit( theId ); | ||
801 | 1580 | } | ||
802 | 1581 | |||
803 | 1582 | void PrinterVisitor::endVisit ( const IndexKeysIterator& ) { | ||
804 | 1583 | thePrinter.startEndVisit(); | ||
805 | 1584 | thePrinter.endEndVisit(); | ||
806 | 1585 | } | ||
807 | 1586 | // </IndexKeysIterator> | ||
808 | 1587 | |||
809 | 1588 | |||
810 | 1574 | // <StaticNamespacesIterator> | 1589 | // <StaticNamespacesIterator> |
811 | 1575 | void PrinterVisitor::beginVisit ( const StaticNamespacesIterator& a) { | 1590 | void PrinterVisitor::beginVisit ( const StaticNamespacesIterator& a) { |
812 | 1576 | thePrinter.startBeginVisit("StaticNamespacesIterator", ++theId); | 1591 | thePrinter.startBeginVisit("StaticNamespacesIterator", ++theId); |
813 | 1577 | 1592 | ||
814 | === modified file 'src/runtime/visitors/pregenerated/printer_visitor.h' | |||
815 | --- src/runtime/visitors/pregenerated/printer_visitor.h 2012-07-12 17:29:55 +0000 | |||
816 | +++ src/runtime/visitors/pregenerated/printer_visitor.h 2012-07-20 23:53:19 +0000 | |||
817 | @@ -388,6 +388,9 @@ | |||
818 | 388 | void beginVisit( const CheckICIterator& ); | 388 | void beginVisit( const CheckICIterator& ); |
819 | 389 | void endVisit ( const CheckICIterator& ); | 389 | void endVisit ( const CheckICIterator& ); |
820 | 390 | 390 | ||
821 | 391 | void beginVisit( const IndexKeysIterator& ); | ||
822 | 392 | void endVisit ( const IndexKeysIterator& ); | ||
823 | 393 | |||
824 | 391 | void beginVisit( const StaticNamespacesIterator& ); | 394 | void beginVisit( const StaticNamespacesIterator& ); |
825 | 392 | void endVisit ( const StaticNamespacesIterator& ); | 395 | void endVisit ( const StaticNamespacesIterator& ); |
826 | 393 | 396 | ||
827 | 394 | 397 | ||
828 | === modified file 'src/store/naive/simple_index_general.cpp' | |||
829 | --- src/store/naive/simple_index_general.cpp 2012-07-12 17:29:55 +0000 | |||
830 | +++ src/store/naive/simple_index_general.cpp 2012-07-20 23:53:19 +0000 | |||
831 | @@ -1151,8 +1151,7 @@ | |||
832 | 1151 | *******************************************************************************/ | 1151 | *******************************************************************************/ |
833 | 1152 | store::Index::KeyIterator_t GeneralHashIndex::keys() const | 1152 | store::Index::KeyIterator_t GeneralHashIndex::keys() const |
834 | 1153 | { | 1153 | { |
837 | 1154 | assert(false); | 1154 | return new KeyIterator(theMaps); |
836 | 1155 | return 0; | ||
838 | 1156 | } | 1155 | } |
839 | 1157 | 1156 | ||
840 | 1158 | 1157 | ||
841 | @@ -1255,6 +1254,14 @@ | |||
842 | 1255 | // // | 1254 | // // |
843 | 1256 | ///////////////////////////////////////////////////////////////////////////////// | 1255 | ///////////////////////////////////////////////////////////////////////////////// |
844 | 1257 | 1256 | ||
845 | 1257 | /******************************************************************************* | ||
846 | 1258 | |||
847 | 1259 | ********************************************************************************/ | ||
848 | 1260 | GeneralHashIndex::KeyIterator::KeyIterator(IndexMap* const* aMaps) | ||
849 | 1261 | : | ||
850 | 1262 | theMaps(aMaps) | ||
851 | 1263 | { | ||
852 | 1264 | } | ||
853 | 1258 | 1265 | ||
854 | 1259 | /****************************************************************************** | 1266 | /****************************************************************************** |
855 | 1260 | 1267 | ||
856 | @@ -1263,23 +1270,60 @@ | |||
857 | 1263 | { | 1270 | { |
858 | 1264 | } | 1271 | } |
859 | 1265 | 1272 | ||
860 | 1273 | /****************************************************************************** | ||
861 | 1274 | * moves theIterator to the next available iterator from theMaps | ||
862 | 1275 | *******************************************************************************/ | ||
863 | 1276 | void GeneralHashIndex::KeyIterator::setNextIter() | ||
864 | 1277 | { | ||
865 | 1278 | for ( ; | ||
866 | 1279 | theCurType < store::XS_LAST && theMaps[theCurType] == 0; | ||
867 | 1280 | ++theCurType) | ||
868 | 1281 | {} | ||
869 | 1282 | |||
870 | 1283 | if (theCurType != store::XS_LAST) | ||
871 | 1284 | theIterator = theMaps[theCurType]->begin(); | ||
872 | 1285 | } | ||
873 | 1266 | 1286 | ||
874 | 1267 | /****************************************************************************** | 1287 | /****************************************************************************** |
875 | 1268 | 1288 | ||
876 | 1269 | *******************************************************************************/ | 1289 | *******************************************************************************/ |
877 | 1270 | void GeneralHashIndex::KeyIterator::open() | 1290 | void GeneralHashIndex::KeyIterator::open() |
878 | 1271 | { | 1291 | { |
880 | 1272 | assert(false); | 1292 | // start with first type from zorba::store::SchemaTypeCode enum |
881 | 1293 | theCurType = 0; | ||
882 | 1294 | // Index doesn't contain keys from all atomic types -> we need to skip the | ||
883 | 1295 | // empty ones. | ||
884 | 1296 | setNextIter(); | ||
885 | 1273 | } | 1297 | } |
886 | 1274 | 1298 | ||
887 | 1275 | 1299 | ||
888 | 1276 | /****************************************************************************** | 1300 | /****************************************************************************** |
889 | 1277 | 1301 | ||
890 | 1278 | *******************************************************************************/ | 1302 | *******************************************************************************/ |
892 | 1279 | bool GeneralHashIndex::KeyIterator::next(store::IndexKey&) | 1303 | bool GeneralHashIndex::KeyIterator::next(store::IndexKey& aKey) |
893 | 1280 | { | 1304 | { |
896 | 1281 | assert(false); | 1305 | // XS_LAST marks the end of the type list -> we stop |
897 | 1282 | return false; | 1306 | if (theCurType == store::XS_LAST) |
898 | 1307 | return false; | ||
899 | 1308 | |||
900 | 1309 | const store::Item* lKeyItem = (*theIterator).first; | ||
901 | 1310 | // the general index doesn't return an IndexKey object because | ||
902 | 1311 | // it doesn't support multi-value keys -> we push the key directly | ||
903 | 1312 | // into the passed IndexKey. | ||
904 | 1313 | aKey.empty(); | ||
905 | 1314 | aKey.push_back(const_cast<zorba::store::Item*>(lKeyItem)); | ||
906 | 1315 | |||
907 | 1316 | ++theIterator; | ||
908 | 1317 | |||
909 | 1318 | if (theIterator == theMaps[theCurType]->end()) | ||
910 | 1319 | { | ||
911 | 1320 | // iteration of the keys of the current type is done. | ||
912 | 1321 | // increase type and search for the next valid iterator. | ||
913 | 1322 | ++theCurType; | ||
914 | 1323 | setNextIter(); | ||
915 | 1324 | } | ||
916 | 1325 | |||
917 | 1326 | return true; | ||
918 | 1283 | } | 1327 | } |
919 | 1284 | 1328 | ||
920 | 1285 | 1329 | ||
921 | @@ -1288,7 +1332,7 @@ | |||
922 | 1288 | *******************************************************************************/ | 1332 | *******************************************************************************/ |
923 | 1289 | void GeneralHashIndex::KeyIterator::close() | 1333 | void GeneralHashIndex::KeyIterator::close() |
924 | 1290 | { | 1334 | { |
926 | 1291 | assert(false); | 1335 | theCurType = store::XS_LAST; |
927 | 1292 | } | 1336 | } |
928 | 1293 | 1337 | ||
929 | 1294 | 1338 | ||
930 | 1295 | 1339 | ||
931 | === modified file 'src/store/naive/simple_index_general.h' | |||
932 | --- src/store/naive/simple_index_general.h 2012-07-12 17:29:55 +0000 | |||
933 | +++ src/store/naive/simple_index_general.h 2012-07-20 23:53:19 +0000 | |||
934 | @@ -220,14 +220,25 @@ | |||
935 | 220 | 220 | ||
936 | 221 | typedef IndexMap::iterator EntryIterator; | 221 | typedef IndexMap::iterator EntryIterator; |
937 | 222 | 222 | ||
938 | 223 | /* | ||
939 | 224 | * This iterator iterates over all index keys from all types | ||
940 | 225 | */ | ||
941 | 223 | class KeyIterator : public Index::KeyIterator | 226 | class KeyIterator : public Index::KeyIterator |
942 | 224 | { | 227 | { |
943 | 228 | protected: | ||
944 | 229 | IndexMap::iterator theIterator; | ||
945 | 230 | IndexMap* const* theMaps; | ||
946 | 231 | ulong theCurType; | ||
947 | 225 | public: | 232 | public: |
948 | 233 | KeyIterator(IndexMap* const* aMaps); | ||
949 | 226 | ~KeyIterator(); | 234 | ~KeyIterator(); |
950 | 227 | 235 | ||
951 | 228 | void open(); | 236 | void open(); |
952 | 229 | bool next(store::IndexKey&); | 237 | bool next(store::IndexKey&); |
953 | 230 | void close(); | 238 | void close(); |
954 | 239 | |||
955 | 240 | private: | ||
956 | 241 | void setNextIter(); | ||
957 | 231 | }; | 242 | }; |
958 | 232 | 243 | ||
959 | 233 | typedef rchandle<KeyIterator> KeyIterator_t; | 244 | typedef rchandle<KeyIterator> KeyIterator_t; |
960 | 234 | 245 | ||
961 | === modified file 'src/store/naive/simple_index_value.cpp' | |||
962 | --- src/store/naive/simple_index_value.cpp 2012-07-12 17:29:55 +0000 | |||
963 | +++ src/store/naive/simple_index_value.cpp 2012-07-20 23:53:19 +0000 | |||
964 | @@ -563,6 +563,13 @@ | |||
965 | 563 | /****************************************************************************** | 563 | /****************************************************************************** |
966 | 564 | 564 | ||
967 | 565 | ********************************************************************************/ | 565 | ********************************************************************************/ |
968 | 566 | ValueTreeIndex::KeyIterator::KeyIterator(const IndexMap& aMap) | ||
969 | 567 | : | ||
970 | 568 | theMap(aMap) | ||
971 | 569 | { | ||
972 | 570 | } | ||
973 | 571 | |||
974 | 572 | |||
975 | 566 | ValueTreeIndex::KeyIterator::~KeyIterator() | 573 | ValueTreeIndex::KeyIterator::~KeyIterator() |
976 | 567 | { | 574 | { |
977 | 568 | }; | 575 | }; |
978 | @@ -570,21 +577,29 @@ | |||
979 | 570 | 577 | ||
980 | 571 | void ValueTreeIndex::KeyIterator::open() | 578 | void ValueTreeIndex::KeyIterator::open() |
981 | 572 | { | 579 | { |
983 | 573 | assert(false); | 580 | theIterator = theMap.begin(); |
984 | 574 | } | 581 | } |
985 | 575 | 582 | ||
986 | 576 | 583 | ||
988 | 577 | bool ValueTreeIndex::KeyIterator::next(store::IndexKey&) | 584 | bool ValueTreeIndex::KeyIterator::next(store::IndexKey& aKey) |
989 | 578 | { | 585 | { |
991 | 579 | assert(false); | 586 | if (theIterator != theMap.end()) |
992 | 587 | { | ||
993 | 588 | const store::IndexKey* lKey = (*theIterator).first; | ||
994 | 589 | aKey = *lKey; | ||
995 | 590 | |||
996 | 591 | ++theIterator; | ||
997 | 592 | return true; | ||
998 | 593 | } | ||
999 | 580 | return false; | 594 | return false; |
1000 | 581 | } | 595 | } |
1001 | 582 | 596 | ||
1002 | 583 | 597 | ||
1003 | 584 | void ValueTreeIndex::KeyIterator::close() | 598 | void ValueTreeIndex::KeyIterator::close() |
1004 | 585 | { | 599 | { |
1007 | 586 | assert(false); | 600 | theIterator = theMap.end(); |
1008 | 587 | } | 601 | }; |
1009 | 602 | |||
1010 | 588 | 603 | ||
1011 | 589 | 604 | ||
1012 | 590 | /****************************************************************************** | 605 | /****************************************************************************** |
1013 | @@ -652,8 +667,7 @@ | |||
1014 | 652 | ********************************************************************************/ | 667 | ********************************************************************************/ |
1015 | 653 | store::Index::KeyIterator_t ValueTreeIndex::keys() const | 668 | store::Index::KeyIterator_t ValueTreeIndex::keys() const |
1016 | 654 | { | 669 | { |
1019 | 655 | assert(false); | 670 | return new KeyIterator(theMap); |
1018 | 656 | return 0; | ||
1020 | 657 | } | 671 | } |
1021 | 658 | 672 | ||
1022 | 659 | 673 | ||
1023 | 660 | 674 | ||
1024 | === modified file 'src/store/naive/simple_index_value.h' | |||
1025 | --- src/store/naive/simple_index_value.h 2012-07-12 17:29:55 +0000 | |||
1026 | +++ src/store/naive/simple_index_value.h 2012-07-20 23:53:19 +0000 | |||
1027 | @@ -208,7 +208,12 @@ | |||
1028 | 208 | 208 | ||
1029 | 209 | class KeyIterator : public Index::KeyIterator | 209 | class KeyIterator : public Index::KeyIterator |
1030 | 210 | { | 210 | { |
1031 | 211 | protected: | ||
1032 | 212 | IndexMap::const_iterator theIterator; | ||
1033 | 213 | const IndexMap & theMap; | ||
1034 | 214 | |||
1035 | 211 | public: | 215 | public: |
1036 | 216 | KeyIterator(const IndexMap& aMap); | ||
1037 | 212 | ~KeyIterator(); | 217 | ~KeyIterator(); |
1038 | 213 | 218 | ||
1039 | 214 | void open(); | 219 | void open(); |
1040 | 215 | 220 | ||
1041 | === added file 'test/rbkt/ExpQueryResults/zorba/index/keys1.xml.res' | |||
1042 | --- test/rbkt/ExpQueryResults/zorba/index/keys1.xml.res 1970-01-01 00:00:00 +0000 | |||
1043 | +++ test/rbkt/ExpQueryResults/zorba/index/keys1.xml.res 2012-07-20 23:53:19 +0000 | |||
1044 | @@ -0,0 +1,1 @@ | |||
1045 | 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> | ||
1046 | 0 | 2 | ||
1047 | === added file 'test/rbkt/ExpQueryResults/zorba/index/keys1g.xml.res' | |||
1048 | --- test/rbkt/ExpQueryResults/zorba/index/keys1g.xml.res 1970-01-01 00:00:00 +0000 | |||
1049 | +++ test/rbkt/ExpQueryResults/zorba/index/keys1g.xml.res 2012-07-20 23:53:19 +0000 | |||
1050 | @@ -0,0 +1,32 @@ | |||
1051 | 1 | <keys> | ||
1052 | 2 | <key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"> | ||
1053 | 3 | <attribute type="xs:string" value="2"></attribute> | ||
1054 | 4 | </key> | ||
1055 | 5 | <key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"> | ||
1056 | 6 | <attribute type="xs:string" value="6"></attribute> | ||
1057 | 7 | </key> | ||
1058 | 8 | <key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"> | ||
1059 | 9 | <attribute type="xs:string" value="4"></attribute> | ||
1060 | 10 | </key> | ||
1061 | 11 | <key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"> | ||
1062 | 12 | <attribute type="xs:string" value="10"></attribute> | ||
1063 | 13 | </key> | ||
1064 | 14 | <key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"> | ||
1065 | 15 | <attribute type="xs:string" value="8"></attribute> | ||
1066 | 16 | </key> | ||
1067 | 17 | <key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"> | ||
1068 | 18 | <attribute type="xs:long" value="0"></attribute> | ||
1069 | 19 | </key> | ||
1070 | 20 | <key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"> | ||
1071 | 21 | <attribute type="xs:long" value="6"></attribute> | ||
1072 | 22 | </key> | ||
1073 | 23 | <key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"> | ||
1074 | 24 | <attribute type="xs:long" value="2"></attribute> | ||
1075 | 25 | </key> | ||
1076 | 26 | <key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"> | ||
1077 | 27 | <attribute type="xs:long" value="8"></attribute> | ||
1078 | 28 | </key> | ||
1079 | 29 | <key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"> | ||
1080 | 30 | <attribute type="xs:long" value="4"></attribute> | ||
1081 | 31 | </key> | ||
1082 | 32 | </keys> | ||
1083 | 0 | 33 | ||
1084 | === added file 'test/rbkt/ExpQueryResults/zorba/index/keys2.xml.res' | |||
1085 | --- test/rbkt/ExpQueryResults/zorba/index/keys2.xml.res 1970-01-01 00:00:00 +0000 | |||
1086 | +++ test/rbkt/ExpQueryResults/zorba/index/keys2.xml.res 2012-07-20 23:53:19 +0000 | |||
1087 | @@ -0,0 +1,1 @@ | |||
1088 | 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> | ||
1089 | 0 | 2 | ||
1090 | === added file 'test/rbkt/ExpQueryResults/zorba/index/keys3.xml.res' | |||
1091 | --- test/rbkt/ExpQueryResults/zorba/index/keys3.xml.res 1970-01-01 00:00:00 +0000 | |||
1092 | +++ test/rbkt/ExpQueryResults/zorba/index/keys3.xml.res 2012-07-20 23:53:19 +0000 | |||
1093 | @@ -0,0 +1,1 @@ | |||
1094 | 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> | ||
1095 | 0 | 2 | ||
1096 | === added file 'test/rbkt/Queries/zorba/index/keys1.xq' | |||
1097 | --- test/rbkt/Queries/zorba/index/keys1.xq 1970-01-01 00:00:00 +0000 | |||
1098 | +++ test/rbkt/Queries/zorba/index/keys1.xq 2012-07-20 23:53:19 +0000 | |||
1099 | @@ -0,0 +1,22 @@ | |||
1100 | 1 | import module namespace ddl = "http://www.zorba-xquery.com/modules/store/static/collections/ddl"; | ||
1101 | 2 | import module namespace dml = "http://www.zorba-xquery.com/modules/store/static/collections/dml"; | ||
1102 | 3 | import module namespace index_ddl = "http://www.zorba-xquery.com/modules/store/static/indexes/ddl"; | ||
1103 | 4 | import module namespace index_dml = "http://www.zorba-xquery.com/modules/store/static/indexes/dml"; | ||
1104 | 5 | |||
1105 | 6 | import module namespace keys-lib = "http://www.example.com/" at "keys_mod.xqlib"; | ||
1106 | 7 | |||
1107 | 8 | ddl:create(xs:QName("keys-lib:foo")); | ||
1108 | 9 | index_ddl:create(xs:QName("keys-lib:FooIdx")); | ||
1109 | 10 | |||
1110 | 11 | for $i in 1 to 10 | ||
1111 | 12 | return | ||
1112 | 13 | dml:insert-nodes(xs:QName("keys-lib:foo"), | ||
1113 | 14 | <foo id="{$i}"/> | ||
1114 | 15 | ); | ||
1115 | 16 | |||
1116 | 17 | let $keys := index_dml:keys(xs:QName("keys-lib:FooIdx")) | ||
1117 | 18 | let $attr := $keys[1]/self::*:key/*:attribute/@*:value | ||
1118 | 19 | return | ||
1119 | 20 | <keys typeIsInteger="{data($attr) instance of xs:integer}">{ | ||
1120 | 21 | $keys | ||
1121 | 22 | }</keys> | ||
1122 | 0 | 23 | ||
1123 | === added file 'test/rbkt/Queries/zorba/index/keys1g.xq' | |||
1124 | --- test/rbkt/Queries/zorba/index/keys1g.xq 1970-01-01 00:00:00 +0000 | |||
1125 | +++ test/rbkt/Queries/zorba/index/keys1g.xq 2012-07-20 23:53:19 +0000 | |||
1126 | @@ -0,0 +1,26 @@ | |||
1127 | 1 | import module namespace ddl = "http://www.zorba-xquery.com/modules/store/static/collections/ddl"; | ||
1128 | 2 | import module namespace dml = "http://www.zorba-xquery.com/modules/store/static/collections/dml"; | ||
1129 | 3 | import module namespace index_ddl = "http://www.zorba-xquery.com/modules/store/static/indexes/ddl"; | ||
1130 | 4 | import module namespace index_dml = "http://www.zorba-xquery.com/modules/store/static/indexes/dml"; | ||
1131 | 5 | |||
1132 | 6 | import module namespace keys-lib = "http://www.example.com/" at "keys_mod.xqlib"; | ||
1133 | 7 | |||
1134 | 8 | ddl:create(xs:QName("keys-lib:foo")); | ||
1135 | 9 | index_ddl:create(xs:QName("keys-lib:FooIdx-general")); | ||
1136 | 10 | |||
1137 | 11 | for $i in 1 to 10 | ||
1138 | 12 | return | ||
1139 | 13 | dml:insert-nodes(xs:QName("keys-lib:foo"), | ||
1140 | 14 | if ($i mod 2 = 0) then | ||
1141 | 15 | <foo id="{$i}"/> | ||
1142 | 16 | else | ||
1143 | 17 | <foo id="{$i - 1}" string="true"/> | ||
1144 | 18 | ); | ||
1145 | 19 | |||
1146 | 20 | let $keys := index_dml:keys(xs:QName("keys-lib:FooIdx-general")) | ||
1147 | 21 | let $attr := $keys[1]/self::*:key/*:attribute/@*:value | ||
1148 | 22 | return | ||
1149 | 23 | <keys>{ | ||
1150 | 24 | $keys | ||
1151 | 25 | }</keys> | ||
1152 | 26 | |||
1153 | 0 | 27 | ||
1154 | === added file 'test/rbkt/Queries/zorba/index/keys2.xq' | |||
1155 | --- test/rbkt/Queries/zorba/index/keys2.xq 1970-01-01 00:00:00 +0000 | |||
1156 | +++ test/rbkt/Queries/zorba/index/keys2.xq 2012-07-20 23:53:19 +0000 | |||
1157 | @@ -0,0 +1,22 @@ | |||
1158 | 1 | import module namespace ddl = "http://www.zorba-xquery.com/modules/store/static/collections/ddl"; | ||
1159 | 2 | import module namespace dml = "http://www.zorba-xquery.com/modules/store/static/collections/dml"; | ||
1160 | 3 | import module namespace index_ddl = "http://www.zorba-xquery.com/modules/store/static/indexes/ddl"; | ||
1161 | 4 | import module namespace index_dml = "http://www.zorba-xquery.com/modules/store/static/indexes/dml"; | ||
1162 | 5 | |||
1163 | 6 | import module namespace keys-lib = "http://www.example.com/" at "keys_mod.xqlib"; | ||
1164 | 7 | |||
1165 | 8 | ddl:create(xs:QName("keys-lib:foo")); | ||
1166 | 9 | index_ddl:create(xs:QName("keys-lib:FooIdx2")); | ||
1167 | 10 | |||
1168 | 11 | for $i in 1 to 10 | ||
1169 | 12 | return | ||
1170 | 13 | dml:insert-nodes(xs:QName("keys-lib:foo"), | ||
1171 | 14 | <foo id="{$i}"/> | ||
1172 | 15 | ); | ||
1173 | 16 | |||
1174 | 17 | let $keys := index_dml:keys(xs:QName("keys-lib:FooIdx2")) | ||
1175 | 18 | return | ||
1176 | 19 | <keys>{ | ||
1177 | 20 | $keys | ||
1178 | 21 | }</keys> | ||
1179 | 22 | |||
1180 | 0 | 23 | ||
1181 | === added file 'test/rbkt/Queries/zorba/index/keys3.xq' | |||
1182 | --- test/rbkt/Queries/zorba/index/keys3.xq 1970-01-01 00:00:00 +0000 | |||
1183 | +++ test/rbkt/Queries/zorba/index/keys3.xq 2012-07-20 23:53:19 +0000 | |||
1184 | @@ -0,0 +1,21 @@ | |||
1185 | 1 | import module namespace ddl = "http://www.zorba-xquery.com/modules/store/static/collections/ddl"; | ||
1186 | 2 | import module namespace dml = "http://www.zorba-xquery.com/modules/store/static/collections/dml"; | ||
1187 | 3 | import module namespace index_ddl = "http://www.zorba-xquery.com/modules/store/static/indexes/ddl"; | ||
1188 | 4 | import module namespace index_dml = "http://www.zorba-xquery.com/modules/store/static/indexes/dml"; | ||
1189 | 5 | |||
1190 | 6 | import module namespace keys-lib = "http://www.example.com/" at "keys_mod.xqlib"; | ||
1191 | 7 | |||
1192 | 8 | ddl:create(xs:QName("keys-lib:foo")); | ||
1193 | 9 | index_ddl:create(xs:QName("keys-lib:FooIdx3")); | ||
1194 | 10 | |||
1195 | 11 | for $i in 1 to 10 | ||
1196 | 12 | return | ||
1197 | 13 | dml:insert-nodes(xs:QName("keys-lib:foo"), | ||
1198 | 14 | if ($i mod 5 eq 0) then <foo id="{$i}" name="me"/> else <foo id="{$i}"/> | ||
1199 | 15 | ); | ||
1200 | 16 | |||
1201 | 17 | let $keys := index_dml:keys(xs:QName("keys-lib:FooIdx3")) | ||
1202 | 18 | return | ||
1203 | 19 | <keys>{ | ||
1204 | 20 | $keys | ||
1205 | 21 | }</keys> | ||
1206 | 0 | 22 | ||
1207 | === added file 'test/rbkt/Queries/zorba/index/keys_mod.xqlib' | |||
1208 | --- test/rbkt/Queries/zorba/index/keys_mod.xqlib 1970-01-01 00:00:00 +0000 | |||
1209 | +++ test/rbkt/Queries/zorba/index/keys_mod.xqlib 2012-07-20 23:53:19 +0000 | |||
1210 | @@ -0,0 +1,40 @@ | |||
1211 | 1 | module namespace keys-lib = "http://www.example.com/"; | ||
1212 | 2 | |||
1213 | 3 | import module namespace dml = "http://www.zorba-xquery.com/modules/store/static/collections/dml"; | ||
1214 | 4 | |||
1215 | 5 | declare namespace ann = "http://www.zorba-xquery.com/annotations"; | ||
1216 | 6 | |||
1217 | 7 | declare %ann:unordered collection keys-lib:foo as node()*; | ||
1218 | 8 | |||
1219 | 9 | declare %ann:automatic %ann:value-equality index keys-lib:FooIdx | ||
1220 | 10 | on nodes dml:collection(xs:QName("keys-lib:foo")) | ||
1221 | 11 | by xs:integer(./@id) as xs:integer; | ||
1222 | 12 | |||
1223 | 13 | declare %ann:automatic %ann:value-range index keys-lib:FooIdx2 | ||
1224 | 14 | on nodes dml:collection(xs:QName("keys-lib:foo")) | ||
1225 | 15 | by xs:integer(./@id) as xs:integer; | ||
1226 | 16 | |||
1227 | 17 | declare %ann:automatic %ann:value-range index keys-lib:FooIdx3 | ||
1228 | 18 | on nodes dml:collection(xs:QName("keys-lib:foo")) | ||
1229 | 19 | by xs:string(./@id) as xs:string, (if (./@name) then xs:string(./@name) else ()) as xs:string?; | ||
1230 | 20 | |||
1231 | 21 | declare %ann:automatic %ann:general-equality index keys-lib:FooIdx-general | ||
1232 | 22 | on nodes dml:collection(xs:QName("keys-lib:foo")) | ||
1233 | 23 | by | ||
1234 | 24 | ( | ||
1235 | 25 | let $val := fn:data(./@id) | ||
1236 | 26 | return | ||
1237 | 27 | if (./@string) then | ||
1238 | 28 | xs:long($val) | ||
1239 | 29 | else | ||
1240 | 30 | xs:string($val) | ||
1241 | 31 | ) | ||
1242 | 32 | as xs:anyAtomicType; | ||
1243 | 33 | |||
1244 | 34 | declare %ann:automatic %ann:general-range index keys-lib:FooIdx2-general | ||
1245 | 35 | on nodes dml:collection(xs:QName("keys-lib:foo")) | ||
1246 | 36 | by xs:integer(./@id) as xs:integer; | ||
1247 | 37 | |||
1248 | 38 | declare %ann:automatic %ann:general-range index keys-lib:FooIdx3-general | ||
1249 | 39 | on nodes dml:collection(xs:QName("keys-lib:foo")) | ||
1250 | 40 | by (if (./@name) then xs:string(./@name) else ()) as xs:string?; |
Validation queue starting for merge proposal. zorbatest. lambda. nu:8080/ remotequeue/ bug900677- 2012-01- 18T01-02- 56.733Z/ log.html
Log at: http://