Merge lp:~zorba-coders/zorba/expr-matching into lp:zorba

Proposed by Markos Zaharioudakis
Status: Merged
Approved by: Markos Zaharioudakis
Approved revision: 11154
Merged at revision: 11246
Proposed branch: lp:~zorba-coders/zorba/expr-matching
Merge into: lp:zorba
Diff against target: 214 lines (+181/-1)
5 files modified
src/compiler/rewriter/rules/index_matching_rule.cpp (+1/-1)
test/rbkt/ExpCompilerResults/IterPlan/zorba/index/match_veq_08b.iter (+113/-0)
test/rbkt/Queries/zorba/index/match_veq_08.xq (+21/-0)
test/rbkt/Queries/zorba/index/match_veq_08.xqlib (+15/-0)
test/rbkt/Queries/zorba/index/match_veq_08b.xq (+31/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/expr-matching
Reviewer Review Type Date Requested Status
Markos Zaharioudakis Approve
Review via email: mp+149751@code.launchpad.net

Commit message

fixed typing-related bug in index matching

Description of the change

fixed typing-related bug in index matching

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

Validation queue job expr-matching-2013-02-21T06-35-46.349Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/compiler/rewriter/rules/index_matching_rule.cpp'
2--- src/compiler/rewriter/rules/index_matching_rule.cpp 2013-01-29 06:01:31 +0000
3+++ src/compiler/rewriter/rules/index_matching_rule.cpp 2013-02-21 06:31:22 +0000
4@@ -978,7 +978,7 @@
5 TypeManager* tm = qe->get_type_manager();
6 RootTypeManager& rtm = GENV_TYPESYSTEM;
7
8- if (TypeOps::is_subtype(tm, *qtype, *vtype) ||
9+ if (TypeOps::is_subtype(tm, *vtype, *qtype) ||
10 (TypeOps::is_subtype(tm, *qtype, *rtm.UNTYPED_ATOMIC_TYPE_STAR) &&
11 TypeOps::is_subtype(tm, *vtype, *rtm.STRING_TYPE_STAR)))
12 {
13
14=== added file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/index/match_veq_08b.iter'
15--- test/rbkt/ExpCompilerResults/IterPlan/zorba/index/match_veq_08b.iter 1970-01-01 00:00:00 +0000
16+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/index/match_veq_08b.iter 2013-02-21 06:31:22 +0000
17@@ -0,0 +1,113 @@
18+Iterator tree for index:
19+<flwor::FLWORIterator>
20+ <ForVariable name="$$context-item">
21+ <ZorbaCollectionIterator>
22+ <SingletonIterator value="xs:QName(http://28.io/collections,db28,faqs)"/>
23+ </ZorbaCollectionIterator>
24+ </ForVariable>
25+ <ReturnClause>
26+ <ValueIndexEntryBuilderIterator>
27+ <ForVarIterator varname="$$context-item"/>
28+ <PromoteIterator type="xs:string">
29+ <FnDataIterator>
30+ <JSONObjectValueIterator>
31+ <ForVarIterator varname="$$context-item"/>
32+ <SingletonIterator value="xs:string(question_id)"/>
33+ </JSONObjectValueIterator>
34+ </FnDataIterator>
35+ </PromoteIterator>
36+ </ValueIndexEntryBuilderIterator>
37+ </ReturnClause>
38+</flwor::FLWORIterator>
39+
40+Iterator tree for const-folded expr:
41+<OrIterator>
42+ <SingletonIterator value="xs:boolean(false)"/>
43+ <SingletonIterator value="xs:boolean(false)"/>
44+ <SingletonIterator value="xs:boolean(false)"/>
45+</OrIterator>
46+
47+Iterator tree for main query:
48+<SequentialIterator>
49+ <ApplyIterator>
50+ <ZorbaCreateCollectionIterator>
51+ <SingletonIterator value="xs:QName(http://28.io/collections,db28,faqs)"/>
52+ </ZorbaCreateCollectionIterator>
53+ </ApplyIterator>
54+ <ApplyIterator>
55+ <ZorbaCreateCollectionIterator>
56+ <SingletonIterator value="xs:QName(http://28.io/collections,db28,answers)"/>
57+ </ZorbaCreateCollectionIterator>
58+ </ApplyIterator>
59+ <ApplyIterator>
60+ <CreateIndexIterator>
61+ <SingletonIterator value="xs:QName(http://28.io/collections,db28,question-id-idx)"/>
62+ </CreateIndexIterator>
63+ </ApplyIterator>
64+ <flwor::TupleStreamIterator>
65+ <flwor::OrderByIterator>
66+ <OrderByForVariable inputVar="id : "/>
67+ <OrderByForVariable inputVar="count : "/>
68+ <OrderBySpec>
69+ <ForVarIterator varname="count"/>
70+ </OrderBySpec>
71+ <flwor::ForIterator>
72+ <ForVariable name="count"/>
73+ <flwor::GroupByIterator>
74+ <flwor::ForIterator>
75+ <ForVariable name="answers"/>
76+ <flwor::TupleSourceIterator/>
77+ <ZorbaCollectionIterator>
78+ <SingletonIterator value="xs:QName(http://28.io/collections,db28,answers)"/>
79+ </ZorbaCollectionIterator>
80+ </flwor::ForIterator>
81+ <Spec>
82+ <TreatIterator quant="?">
83+ <FnDataIterator>
84+ <JSONObjectValueIterator>
85+ <ForVarIterator varname="answers"/>
86+ <SingletonIterator value="xs:string(question_id)"/>
87+ </JSONObjectValueIterator>
88+ </FnDataIterator>
89+ </TreatIterator>
90+ <GroupVariable/>
91+ </Spec>
92+ <Spec>
93+ <ForVarIterator varname="answers"/>
94+ <NonGroupVariable/>
95+ </Spec>
96+ </flwor::GroupByIterator>
97+ <FnCountIterator>
98+ <LetVarIterator varname="answers"/>
99+ </FnCountIterator>
100+ </flwor::ForIterator>
101+ </flwor::OrderByIterator>
102+ <JSONDirectObjectIterator>
103+ <SingletonIterator value="xs:string(title)"/>
104+ <SingletonIterator value="xs:string(answer_count)"/>
105+ <JSONBoxIterator>
106+ <flwor::FLWORIterator>
107+ <ForVariable name="$$context-item">
108+ <ProbeIndexRangeValueIterator>
109+ <SingletonIterator value="xs:QName(http://28.io/collections,db28,question-id-idx)"/>
110+ <ForVarIterator varname="id"/>
111+ <ForVarIterator varname="id"/>
112+ <SingletonIterator value="xs:boolean(true)"/>
113+ <SingletonIterator value="xs:boolean(true)"/>
114+ <SingletonIterator value="xs:boolean(true)"/>
115+ <SingletonIterator value="xs:boolean(true)"/>
116+ </ProbeIndexRangeValueIterator>
117+ </ForVariable>
118+ <ReturnClause>
119+ <JSONObjectValueIterator>
120+ <ForVarIterator varname="$$context-item"/>
121+ <SingletonIterator value="xs:string(title)"/>
122+ </JSONObjectValueIterator>
123+ </ReturnClause>
124+ </flwor::FLWORIterator>
125+ </JSONBoxIterator>
126+ <ForVarIterator varname="count"/>
127+ </JSONDirectObjectIterator>
128+ </flwor::TupleStreamIterator>
129+</SequentialIterator>
130+
131
132=== added file 'test/rbkt/ExpQueryResults/zorba/index/match_veq_08.xml.res'
133=== added file 'test/rbkt/ExpQueryResults/zorba/index/match_veq_08b.xml.res'
134=== added file 'test/rbkt/Queries/zorba/index/match_veq_08.xq'
135--- test/rbkt/Queries/zorba/index/match_veq_08.xq 1970-01-01 00:00:00 +0000
136+++ test/rbkt/Queries/zorba/index/match_veq_08.xq 2013-02-21 06:31:22 +0000
137@@ -0,0 +1,21 @@
138+import module namespace db28 =
139+"http://28.io/collections" at "match_veq_08.xqlib";
140+
141+import module namespace dml =
142+"http://www.zorba-xquery.com/modules/store/static/collections/dml";
143+
144+import module namespace ddl =
145+"http://www.zorba-xquery.com/modules/store/static/collections/ddl";
146+
147+import module namespace iddl =
148+"http://www.zorba-xquery.com/modules/store/static/indexes/ddl";
149+
150+
151+ddl:create(xs:QName("db28:faqs"));
152+
153+iddl:create(xs:QName("db28:question-id-idx"));
154+
155+
156+for $obj in dml:collection(xs:QName("db28:faqs"))
157+where $obj("question_id") eq "4419499"
158+return $obj
159
160=== added file 'test/rbkt/Queries/zorba/index/match_veq_08.xqlib'
161--- test/rbkt/Queries/zorba/index/match_veq_08.xqlib 1970-01-01 00:00:00 +0000
162+++ test/rbkt/Queries/zorba/index/match_veq_08.xqlib 2013-02-21 06:31:22 +0000
163@@ -0,0 +1,15 @@
164+
165+module namespace db28 = "http://28.io/collections";
166+
167+import module namespace db = "http://www.zorba-xquery.com/modules/store/static/collections/dml";
168+
169+declare namespace an = "http://www.zorba-xquery.com/annotations";
170+
171+declare collection db28:answers as object()*;
172+
173+declare collection db28:faqs as object()*;
174+
175+declare %an:value-range index db28:question-id-idx
176+on nodes db:collection(xs:QName("db28:faqs"))
177+by .("question_id") as xs:string?;
178+
179
180=== added file 'test/rbkt/Queries/zorba/index/match_veq_08b.xq'
181--- test/rbkt/Queries/zorba/index/match_veq_08b.xq 1970-01-01 00:00:00 +0000
182+++ test/rbkt/Queries/zorba/index/match_veq_08b.xq 2013-02-21 06:31:22 +0000
183@@ -0,0 +1,31 @@
184+
185+
186+import module namespace db28 =
187+"http://28.io/collections" at "match_veq_08.xqlib";
188+
189+import module namespace dml =
190+"http://www.zorba-xquery.com/modules/store/static/collections/dml";
191+
192+import module namespace ddl =
193+"http://www.zorba-xquery.com/modules/store/static/collections/ddl";
194+
195+import module namespace iddl =
196+"http://www.zorba-xquery.com/modules/store/static/indexes/ddl";
197+
198+
199+ddl:create(xs:QName("db28:faqs"));
200+
201+ddl:create(xs:QName("db28:answers"));
202+
203+iddl:create(xs:QName("db28:question-id-idx"));
204+
205+
206+for $answers in dml:collection(xs:QName("db28:answers"))
207+let $id := $answers("question_id")
208+group by $id
209+let $count := count($answers)
210+order by $count descending
211+return {
212+ "title": dml:collection(xs:QName("db28:faqs"))[$id eq .("question_id")]("title"),
213+ "answer_count": $count
214+}

Subscribers

People subscribed via source and target branches