zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #18258
[Merge] lp:~zorba-coders/zorba/expr-matching into lp:zorba
Markos Zaharioudakis has proposed merging lp:~zorba-coders/zorba/expr-matching into lp:zorba.
Commit message:
fixed typing-related bug in index matching
Requested reviews:
Markos Zaharioudakis (markos-za)
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/expr-matching/+merge/149751
fixed typing-related bug in index matching
--
https://code.launchpad.net/~zorba-coders/zorba/expr-matching/+merge/149751
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/compiler/rewriter/rules/index_matching_rule.cpp'
--- src/compiler/rewriter/rules/index_matching_rule.cpp 2013-01-29 06:01:31 +0000
+++ src/compiler/rewriter/rules/index_matching_rule.cpp 2013-02-21 06:31:22 +0000
@@ -978,7 +978,7 @@
TypeManager* tm = qe->get_type_manager();
RootTypeManager& rtm = GENV_TYPESYSTEM;
- if (TypeOps::is_subtype(tm, *qtype, *vtype) ||
+ if (TypeOps::is_subtype(tm, *vtype, *qtype) ||
(TypeOps::is_subtype(tm, *qtype, *rtm.UNTYPED_ATOMIC_TYPE_STAR) &&
TypeOps::is_subtype(tm, *vtype, *rtm.STRING_TYPE_STAR)))
{
=== added file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/index/match_veq_08b.iter'
--- test/rbkt/ExpCompilerResults/IterPlan/zorba/index/match_veq_08b.iter 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/index/match_veq_08b.iter 2013-02-21 06:31:22 +0000
@@ -0,0 +1,113 @@
+Iterator tree for index:
+<flwor::FLWORIterator>
+ <ForVariable name="$$context-item">
+ <ZorbaCollectionIterator>
+ <SingletonIterator value="xs:QName(http://28.io/collections,db28,faqs)"/>
+ </ZorbaCollectionIterator>
+ </ForVariable>
+ <ReturnClause>
+ <ValueIndexEntryBuilderIterator>
+ <ForVarIterator varname="$$context-item"/>
+ <PromoteIterator type="xs:string">
+ <FnDataIterator>
+ <JSONObjectValueIterator>
+ <ForVarIterator varname="$$context-item"/>
+ <SingletonIterator value="xs:string(question_id)"/>
+ </JSONObjectValueIterator>
+ </FnDataIterator>
+ </PromoteIterator>
+ </ValueIndexEntryBuilderIterator>
+ </ReturnClause>
+</flwor::FLWORIterator>
+
+Iterator tree for const-folded expr:
+<OrIterator>
+ <SingletonIterator value="xs:boolean(false)"/>
+ <SingletonIterator value="xs:boolean(false)"/>
+ <SingletonIterator value="xs:boolean(false)"/>
+</OrIterator>
+
+Iterator tree for main query:
+<SequentialIterator>
+ <ApplyIterator>
+ <ZorbaCreateCollectionIterator>
+ <SingletonIterator value="xs:QName(http://28.io/collections,db28,faqs)"/>
+ </ZorbaCreateCollectionIterator>
+ </ApplyIterator>
+ <ApplyIterator>
+ <ZorbaCreateCollectionIterator>
+ <SingletonIterator value="xs:QName(http://28.io/collections,db28,answers)"/>
+ </ZorbaCreateCollectionIterator>
+ </ApplyIterator>
+ <ApplyIterator>
+ <CreateIndexIterator>
+ <SingletonIterator value="xs:QName(http://28.io/collections,db28,question-id-idx)"/>
+ </CreateIndexIterator>
+ </ApplyIterator>
+ <flwor::TupleStreamIterator>
+ <flwor::OrderByIterator>
+ <OrderByForVariable inputVar="id : "/>
+ <OrderByForVariable inputVar="count : "/>
+ <OrderBySpec>
+ <ForVarIterator varname="count"/>
+ </OrderBySpec>
+ <flwor::ForIterator>
+ <ForVariable name="count"/>
+ <flwor::GroupByIterator>
+ <flwor::ForIterator>
+ <ForVariable name="answers"/>
+ <flwor::TupleSourceIterator/>
+ <ZorbaCollectionIterator>
+ <SingletonIterator value="xs:QName(http://28.io/collections,db28,answers)"/>
+ </ZorbaCollectionIterator>
+ </flwor::ForIterator>
+ <Spec>
+ <TreatIterator quant="?">
+ <FnDataIterator>
+ <JSONObjectValueIterator>
+ <ForVarIterator varname="answers"/>
+ <SingletonIterator value="xs:string(question_id)"/>
+ </JSONObjectValueIterator>
+ </FnDataIterator>
+ </TreatIterator>
+ <GroupVariable/>
+ </Spec>
+ <Spec>
+ <ForVarIterator varname="answers"/>
+ <NonGroupVariable/>
+ </Spec>
+ </flwor::GroupByIterator>
+ <FnCountIterator>
+ <LetVarIterator varname="answers"/>
+ </FnCountIterator>
+ </flwor::ForIterator>
+ </flwor::OrderByIterator>
+ <JSONDirectObjectIterator>
+ <SingletonIterator value="xs:string(title)"/>
+ <SingletonIterator value="xs:string(answer_count)"/>
+ <JSONBoxIterator>
+ <flwor::FLWORIterator>
+ <ForVariable name="$$context-item">
+ <ProbeIndexRangeValueIterator>
+ <SingletonIterator value="xs:QName(http://28.io/collections,db28,question-id-idx)"/>
+ <ForVarIterator varname="id"/>
+ <ForVarIterator varname="id"/>
+ <SingletonIterator value="xs:boolean(true)"/>
+ <SingletonIterator value="xs:boolean(true)"/>
+ <SingletonIterator value="xs:boolean(true)"/>
+ <SingletonIterator value="xs:boolean(true)"/>
+ </ProbeIndexRangeValueIterator>
+ </ForVariable>
+ <ReturnClause>
+ <JSONObjectValueIterator>
+ <ForVarIterator varname="$$context-item"/>
+ <SingletonIterator value="xs:string(title)"/>
+ </JSONObjectValueIterator>
+ </ReturnClause>
+ </flwor::FLWORIterator>
+ </JSONBoxIterator>
+ <ForVarIterator varname="count"/>
+ </JSONDirectObjectIterator>
+ </flwor::TupleStreamIterator>
+</SequentialIterator>
+
=== added file 'test/rbkt/ExpQueryResults/zorba/index/match_veq_08.xml.res'
=== added file 'test/rbkt/ExpQueryResults/zorba/index/match_veq_08b.xml.res'
=== added file 'test/rbkt/Queries/zorba/index/match_veq_08.xq'
--- test/rbkt/Queries/zorba/index/match_veq_08.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/index/match_veq_08.xq 2013-02-21 06:31:22 +0000
@@ -0,0 +1,21 @@
+import module namespace db28 =
+"http://28.io/collections"; at "match_veq_08.xqlib";
+
+import module namespace dml =
+"http://www.zorba-xquery.com/modules/store/static/collections/dml";;
+
+import module namespace ddl =
+"http://www.zorba-xquery.com/modules/store/static/collections/ddl";;
+
+import module namespace iddl =
+"http://www.zorba-xquery.com/modules/store/static/indexes/ddl";;
+
+
+ddl:create(xs:QName("db28:faqs"));
+
+iddl:create(xs:QName("db28:question-id-idx"));
+
+
+for $obj in dml:collection(xs:QName("db28:faqs"))
+where $obj("question_id") eq "4419499"
+return $obj
=== added file 'test/rbkt/Queries/zorba/index/match_veq_08.xqlib'
--- test/rbkt/Queries/zorba/index/match_veq_08.xqlib 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/index/match_veq_08.xqlib 2013-02-21 06:31:22 +0000
@@ -0,0 +1,15 @@
+
+module namespace db28 = "http://28.io/collections";;
+
+import module namespace db = "http://www.zorba-xquery.com/modules/store/static/collections/dml";;
+
+declare namespace an = "http://www.zorba-xquery.com/annotations";;
+
+declare collection db28:answers as object()*;
+
+declare collection db28:faqs as object()*;
+
+declare %an:value-range index db28:question-id-idx
+on nodes db:collection(xs:QName("db28:faqs"))
+by .("question_id") as xs:string?;
+
=== added file 'test/rbkt/Queries/zorba/index/match_veq_08b.xq'
--- test/rbkt/Queries/zorba/index/match_veq_08b.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/index/match_veq_08b.xq 2013-02-21 06:31:22 +0000
@@ -0,0 +1,31 @@
+
+
+import module namespace db28 =
+"http://28.io/collections"; at "match_veq_08.xqlib";
+
+import module namespace dml =
+"http://www.zorba-xquery.com/modules/store/static/collections/dml";;
+
+import module namespace ddl =
+"http://www.zorba-xquery.com/modules/store/static/collections/ddl";;
+
+import module namespace iddl =
+"http://www.zorba-xquery.com/modules/store/static/indexes/ddl";;
+
+
+ddl:create(xs:QName("db28:faqs"));
+
+ddl:create(xs:QName("db28:answers"));
+
+iddl:create(xs:QName("db28:question-id-idx"));
+
+
+for $answers in dml:collection(xs:QName("db28:answers"))
+let $id := $answers("question_id")
+group by $id
+let $count := count($answers)
+order by $count descending
+return {
+ "title": dml:collection(xs:QName("db28:faqs"))[$id eq .("question_id")]("title"),
+ "answer_count": $count
+}
Follow ups