← Back to team overview

zorba-coders team mailing list archive

[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 bug in IndexMatchingRule::checkFreeVars

Requested reviews:
  Markos Zaharioudakis (markos-za)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/expr-matching/+merge/149957

fixed bug in IndexMatchingRule::checkFreeVars
-- 
https://code.launchpad.net/~zorba-coders/zorba/expr-matching/+merge/149957
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-02-21 22:41:14 +0000
+++ src/compiler/rewriter/rules/index_matching_rule.cpp	2013-02-22 00:10:33 +0000
@@ -1046,7 +1046,8 @@
     if (freeVar == domVar)
       continue;
 
-    if (freeVar->get_flwor_clause()->get_flwor_expr() == theQueryExpr)
+    if (freeVar->get_flwor_clause() != NULL &&
+        freeVar->get_flwor_clause()->get_flwor_expr() == theQueryExpr)
     {
       freeVar->setVisitId(1);
     }

=== added file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/index/match_veq_11.iter'
--- test/rbkt/ExpCompilerResults/IterPlan/zorba/index/match_veq_11.iter	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/index/match_veq_11.iter	2013-02-22 00:10:33 +0000
@@ -0,0 +1,180 @@
+Iterator tree for doc indexer:
+<flwor::FLWORIterator>
+  <ForVariable name="$$context-item">
+    <CtxVarIterator varid="1" varname="$$idx_doc_var" varkind="global"/>
+  </ForVariable>
+  <ReturnClause>
+    <ValueIndexEntryBuilderIterator>
+      <ForVarIterator varname="$$context-item"/>
+      <TreatIterator quant="">
+        <CastIterator type="xs:int">
+          <FnDataIterator>
+            <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,id)" typename="*" nill allowed="0">
+              <ForVarIterator varname="$$context-item"/>
+            </AttributeAxisIterator>
+          </FnDataIterator>
+        </CastIterator>
+      </TreatIterator>
+    </ValueIndexEntryBuilderIterator>
+  </ReturnClause>
+</flwor::FLWORIterator>
+
+Iterator tree for index:
+<flwor::FLWORIterator>
+  <ForVariable name="$$context-item">
+    <ZorbaCollectionIterator>
+      <SingletonIterator value="xs:QName(http://www.28msec.com/benchmark/lib/custacc,ca,custaccs)"/>
+    </ZorbaCollectionIterator>
+  </ForVariable>
+  <ReturnClause>
+    <ValueIndexEntryBuilderIterator>
+      <ForVarIterator varname="$$context-item"/>
+      <TreatIterator quant="">
+        <CastIterator type="xs:int">
+          <FnDataIterator>
+            <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,id)" typename="*" nill allowed="0">
+              <ForVarIterator varname="$$context-item"/>
+            </AttributeAxisIterator>
+          </FnDataIterator>
+        </CastIterator>
+      </TreatIterator>
+    </ValueIndexEntryBuilderIterator>
+  </ReturnClause>
+</flwor::FLWORIterator>
+
+Iterator tree for doc indexer:
+<flwor::FLWORIterator>
+  <ForVariable name="$$context-item">
+    <CtxVarIterator varid="1" varname="$$idx_doc_var" varkind="global"/>
+  </ForVariable>
+  <ReturnClause>
+    <ValueIndexEntryBuilderIterator>
+      <ForVarIterator varname="$$context-item"/>
+      <PromoteIterator type="xs:string">
+        <FnDataIterator>
+          <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,id)" typename="*" nill allowed="0">
+            <ForVarIterator varname="$$context-item"/>
+          </AttributeAxisIterator>
+        </FnDataIterator>
+      </PromoteIterator>
+    </ValueIndexEntryBuilderIterator>
+  </ReturnClause>
+</flwor::FLWORIterator>
+
+Iterator tree for index:
+<flwor::FLWORIterator>
+  <ForVariable name="$$context-item">
+    <ZorbaCollectionIterator>
+      <SingletonIterator value="xs:QName(http://www.28msec.com/benchmark/lib/custacc,ca,custaccs)"/>
+    </ZorbaCollectionIterator>
+  </ForVariable>
+  <ReturnClause>
+    <ValueIndexEntryBuilderIterator>
+      <ForVarIterator varname="$$context-item"/>
+      <PromoteIterator type="xs:string">
+        <FnDataIterator>
+          <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,id)" typename="*" nill allowed="0">
+            <ForVarIterator varname="$$context-item"/>
+          </AttributeAxisIterator>
+        </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>
+  <CtxVarDeclareIterator varid="4" varname="ca:custaccs">
+    <SingletonIterator value="xs:QName(http://www.28msec.com/benchmark/lib/custacc,ca,custaccs)"/>
+  </CtxVarDeclareIterator>
+  <CtxVarDeclareIterator varid="5" varname="ca:orders">
+    <SingletonIterator value="xs:QName(http://www.28msec.com/benchmark/lib/custacc,ca,orders)"/>
+  </CtxVarDeclareIterator>
+  <CtxVarDeclareIterator varid="6" varname="ca:index-custaccs-str">
+    <SingletonIterator value="xs:QName(http://www.28msec.com/benchmark/lib/custacc,ca,index-custaccs-str)"/>
+  </CtxVarDeclareIterator>
+  <CtxVarDeclareIterator varid="7" varname="ca:index-custaccs-int">
+    <SingletonIterator value="xs:QName(http://www.28msec.com/benchmark/lib/custacc,ca,index-custaccs-int)"/>
+  </CtxVarDeclareIterator>
+  <SequentialIterator>
+    <ApplyIterator>
+      <ZorbaCreateCollectionIterator>
+        <SingletonIterator value="xs:QName(http://www.28msec.com/benchmark/lib/custacc,ca,custaccs)"/>
+      </ZorbaCreateCollectionIterator>
+    </ApplyIterator>
+    <ApplyIterator>
+      <ZorbaCreateCollectionIterator>
+        <SingletonIterator value="xs:QName(http://www.28msec.com/benchmark/lib/custacc,ca,orders)"/>
+      </ZorbaCreateCollectionIterator>
+    </ApplyIterator>
+    <ApplyIterator>
+      <CreateIndexIterator>
+        <CtxVarIterator varid="6" varname="ca:index-custaccs-str" varkind="global"/>
+      </CreateIndexIterator>
+    </ApplyIterator>
+    <ApplyIterator>
+      <CreateIndexIterator>
+        <CtxVarIterator varid="7" varname="ca:index-custaccs-int" varkind="global"/>
+      </CreateIndexIterator>
+    </ApplyIterator>
+    <FnMinMaxIterator type="max">
+      <FnDataIterator>
+        <flwor::TupleStreamIterator>
+          <flwor::WhereIterator>
+            <flwor::ForIterator>
+              <ForVariable name="ord"/>
+              <flwor::ForIterator>
+                <ForVariable name="acct-id"/>
+                <flwor::ForIterator>
+                  <ForVariable name="$$context-item"/>
+                  <flwor::ForIterator>
+                    <ForVariable name="$$context-item"/>
+                    <flwor::TupleSourceIterator/>
+                    <ProbeIndexPointValueIterator>
+                      <SingletonIterator value="xs:QName(http://www.28msec.com/benchmark/lib/custacc,ca,index-custaccs-str)"/>
+                      <SingletonIterator value="xs:integer(4)"/>
+                    </ProbeIndexPointValueIterator>
+                  </flwor::ForIterator>
+                  <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,id)" typename="*" nill allowed="0">
+                    <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,Account)" typename="*" nill allowed="0">
+                      <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,Accounts)" typename="*" nill allowed="0">
+                        <ForVarIterator varname="$$context-item"/>
+                      </ChildAxisIterator>
+                    </ChildAxisIterator>
+                  </AttributeAxisIterator>
+                </flwor::ForIterator>
+                <FnStringIterator>
+                  <ForVarIterator varname="$$context-item"/>
+                </FnStringIterator>
+              </flwor::ForIterator>
+              <ZorbaCollectionIterator>
+                <CtxVarIterator varid="5" varname="ca:orders" varkind="global"/>
+              </ZorbaCollectionIterator>
+            </flwor::ForIterator>
+            <CompareIterator>
+              <FnDataIterator>
+                <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,Acct)" typename="*" nill allowed="0">
+                  <ForVarIterator varname="ord"/>
+                </AttributeAxisIterator>
+              </FnDataIterator>
+              <ForVarIterator varname="acct-id"/>
+            </CompareIterator>
+          </flwor::WhereIterator>
+          <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,Cash)" typename="*" nill allowed="0">
+            <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,OrdQty)" typename="*" nill allowed="0">
+              <ForVarIterator varname="ord"/>
+            </ChildAxisIterator>
+          </AttributeAxisIterator>
+        </flwor::TupleStreamIterator>
+      </FnDataIterator>
+    </FnMinMaxIterator>
+  </SequentialIterator>
+</SequentialIterator>
+

=== added file 'test/rbkt/Queries/zorba/index/match_veq_11.spec'
--- test/rbkt/Queries/zorba/index/match_veq_11.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/index/match_veq_11.spec	2013-02-22 00:10:33 +0000
@@ -0,0 +1,1 @@
+Error:  http://www.w3.org/2005/xqt-errors:FORG0006

=== added file 'test/rbkt/Queries/zorba/index/match_veq_11.xq'
--- test/rbkt/Queries/zorba/index/match_veq_11.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/index/match_veq_11.xq	2013-02-22 00:10:33 +0000
@@ -0,0 +1,32 @@
+
+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";;
+
+import module namespace ca = 
+'http://www.28msec.com/benchmark/lib/custacc' at 'match_veq_11.xqlib';
+
+
+ddl:create(xs:QName("ca:custaccs"));
+
+ddl:create(xs:QName("ca:orders"));
+
+
+iddl:create($ca:index-custaccs-str);
+
+iddl:create($ca:index-custaccs-int);
+
+
+let $orderprice :=
+  for $cust in dml:collection($ca:custaccs)[@id eq 4]
+  for $acct-id in $cust/Accounts/Account/@id/fn:string(.)
+  for $ord in dml:collection($ca:orders)
+  where $ord/@Acct = $acct-id
+  return $ord/OrdQty/@Cash
+return max($orderprice)
+

=== added file 'test/rbkt/Queries/zorba/index/match_veq_11.xqlib'
--- test/rbkt/Queries/zorba/index/match_veq_11.xqlib	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/index/match_veq_11.xqlib	2013-02-22 00:10:33 +0000
@@ -0,0 +1,26 @@
+module namespace ca = 'http://www.28msec.com/benchmark/lib/custacc';
+
+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 ca:custaccs as node()*;
+
+declare collection ca:orders as node()*;
+
+
+declare %an:automatic %an:value-equality index ca:index-custaccs-int
+  on nodes db:collection(xs:QName("ca:custaccs"))
+  by xs:int(./@id) as xs:int;
+
+declare %an:automatic %an:value-equality index ca:index-custaccs-str
+  on nodes db:collection(xs:QName("ca:custaccs"))
+  by ./@id as xs:string;
+
+
+declare variable $ca:custaccs := xs:QName("ca:custaccs");
+declare variable $ca:orders := xs:QName("ca:orders");
+declare variable $ca:index-custaccs-str := xs:QName("ca:index-custaccs-str");
+declare variable $ca:index-custaccs-int := xs:QName("ca:index-custaccs-int");
+


Follow ups