rewrite rule and test implemented to fix fn:doc

Project: http://git-wip-us.apache.org/repos/asf/vxquery/repo
Commit: http://git-wip-us.apache.org/repos/asf/vxquery/commit/911bc5b1
Tree: http://git-wip-us.apache.org/repos/asf/vxquery/tree/911bc5b1
Diff: http://git-wip-us.apache.org/repos/asf/vxquery/diff/911bc5b1

Branch: refs/heads/master
Commit: 911bc5b113f372292e66becd513b5fcadabd8291
Parents: 3e62dbe
Author: Shivani Mall <[email protected]>
Authored: Mon Jun 22 15:17:21 2015 -0700
Committer: Shivani Mall <[email protected]>
Committed: Mon Jun 22 15:17:21 2015 -0700

----------------------------------------------------------------------
 .../rules/ConvertDocExpressionToFile.java       | 13 ++-------
 .../metadata/VXQueryMetadataProvider.java       |  6 ++++-
 .../ExpectedTestResults/Simple/fn_doc.xml       |  1 +
 .../resources/Queries/XQuery/Simple/fn_doc.xq   | 19 +++++++++++++
 .../src/test/resources/VXQueryCatalog.xml       | 18 ++++++-------
 .../FunctionsAndOperatorsOnNumericsQueries.xml  |  2 +-
 ...nctionsAndOperatorsThatGenerateSequences.xml | 28 ++++++++++++++++++++
 .../resources/cat/GhcndPartition2Queries.xml    |  2 +-
 .../test/resources/cat/SingleAlternateQuery.xml |  2 +-
 .../src/test/resources/cat/SingleQuery.xml      |  2 +-
 .../test/resources/cat/XMarkOriginalQueries.xml |  2 +-
 11 files changed, 68 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/vxquery/blob/911bc5b1/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/ConvertDocExpressionToFile.java
----------------------------------------------------------------------
diff --git 
a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/ConvertDocExpressionToFile.java
 
b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/ConvertDocExpressionToFile.java
index c64157f..7cf9616 100644
--- 
a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/ConvertDocExpressionToFile.java
+++ 
b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/ConvertDocExpressionToFile.java
@@ -92,14 +92,8 @@ public class ConvertDocExpressionToFile implements 
IAlgebraicRewriteRule {
     public boolean rewritePost(Mutable<ILogicalOperator> opRef, 
IOptimizationContext context)
             throws AlgebricksException {
         boolean modified = false;
-        //returns the list of expressions inside the operator.
         List<Mutable<ILogicalExpression>> expressions = 
OperatorToolbox.getExpressions(opRef);
-        //for each expression we go in
         for (Mutable<ILogicalExpression> expression : expressions) {
-            //checks if the expression is a function call
-            //checks if the function call is fn_doc1
-            //returns the first expression contained in it only!
-            //what is a function has multiple arguments that is multiple 
expressions
             Mutable<ILogicalExpression> docExpression = 
ExpressionToolbox.findFirstFunctionExpression(expression,
                     BuiltinFunctions.FN_DOC_1.getFunctionIdentifier());
             if (docExpression != null) {
@@ -112,9 +106,6 @@ public class ConvertDocExpressionToFile implements 
IAlgebraicRewriteRule {
         return modified;
     }
 
-    //side note: I only see nested arguments, not multiple expressions in most 
cases.//
-    //Expressions == arguments ??
-
     protected boolean ifDocExpressionFound(Mutable<ILogicalOperator> opRef, 
Mutable<ILogicalExpression> funcExpression,
             IOptimizationContext context) {
         VXQueryConstantValue constantValue = null;
@@ -159,10 +150,10 @@ public class ConvertDocExpressionToFile implements 
IAlgebraicRewriteRule {
             e.printStackTrace();
         }
         VXQueryMetadataProvider mdp = (VXQueryMetadataProvider) 
context.getMetadataProvider();
-        if (!mdp.sourceFileMap.containsKey(collectionName)) {
+        if (!mdp.getSourceFileMap().containsKey(collectionName)) {
             return false;
         }
-        File file = mdp.sourceFileMap.get(collectionName);
+        File file = mdp.getSourceFileMap().get(collectionName);
         StringValueBuilder svb = new StringValueBuilder();
         try {
             abvs.reset();

http://git-wip-us.apache.org/repos/asf/vxquery/blob/911bc5b1/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryMetadataProvider.java
----------------------------------------------------------------------
diff --git 
a/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryMetadataProvider.java
 
b/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryMetadataProvider.java
index b0e4594..b2ab17c 100644
--- 
a/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryMetadataProvider.java
+++ 
b/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryMetadataProvider.java
@@ -53,7 +53,7 @@ import 
edu.uci.ics.hyracks.dataflow.std.result.ResultWriterOperatorDescriptor;
 
 public class VXQueryMetadataProvider implements IMetadataProvider<String, 
String> {
     String[] nodeList;
-    public Map<String, File> sourceFileMap;
+    Map<String, File> sourceFileMap;
 
     public VXQueryMetadataProvider(String[] nodeList, Map<String, File> 
sourceFileMap) {
         this.nodeList = nodeList;
@@ -65,6 +65,10 @@ public class VXQueryMetadataProvider implements 
IMetadataProvider<String, String
         return null;
     }
 
+    public Map<String, File> getSourceFileMap() {
+        return sourceFileMap;
+    }
+
     @Override
     public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> 
getScannerRuntime(IDataSource<String> dataSource,
             List<LogicalVariable> scanVariables, List<LogicalVariable> 
projectVariables, boolean projectPushed,

http://git-wip-us.apache.org/repos/asf/vxquery/blob/911bc5b1/vxquery-xtest/src/test/resources/ExpectedTestResults/Simple/fn_doc.xml
----------------------------------------------------------------------
diff --git 
a/vxquery-xtest/src/test/resources/ExpectedTestResults/Simple/fn_doc.xml 
b/vxquery-xtest/src/test/resources/ExpectedTestResults/Simple/fn_doc.xml
new file mode 100644
index 0000000..169a175
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Simple/fn_doc.xml
@@ -0,0 +1 @@
+<stationCollection 
pageSize="100"pageCount="1"totalCount="1"><station><id>GHCND:US000000001</id><displayName>Station
 
1</displayName><latitude>10.000</latitude><longitude>-10.000</longitude><elevation>1000.0</elevation><locationLabels><type>ST</type><id>FIPS:1</id><displayName>State
 
1</displayName></locationLabels><locationLabels><type>CNTY</type><id>FIPS:-9999</id><displayName>County
 
1</displayName></locationLabels><locationLabels><type>CNTRY</type><id>FIPS:US</id><displayName>UNITED
 STATES</displayName></locationLabels></station></stationCollection>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/vxquery/blob/911bc5b1/vxquery-xtest/src/test/resources/Queries/XQuery/Simple/fn_doc.xq
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Simple/fn_doc.xq 
b/vxquery-xtest/src/test/resources/Queries/XQuery/Simple/fn_doc.xq
new file mode 100644
index 0000000..bce856c
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Simple/fn_doc.xq
@@ -0,0 +1,19 @@
+(: Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+   
+     http://www.apache.org/licenses/LICENSE-2.0
+   
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License. :)
+   
+   doc("station_xml_file")/stationCollection
+   
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/vxquery/blob/911bc5b1/vxquery-xtest/src/test/resources/VXQueryCatalog.xml
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/VXQueryCatalog.xml 
b/vxquery-xtest/src/test/resources/VXQueryCatalog.xml
index 5b9b234..aa4953d 100644
--- a/vxquery-xtest/src/test/resources/VXQueryCatalog.xml
+++ b/vxquery-xtest/src/test/resources/VXQueryCatalog.xml
@@ -23,6 +23,7 @@
 <!ENTITY AggregatePartition4Queries SYSTEM 
"cat/AggregatePartition4Queries.xml">
 
 <!ENTITY FunctionsAndOperatorsOnNumericsQueries SYSTEM 
"cat/FunctionsAndOperatorsOnNumericsQueries.xml">
+<!ENTITY FunctionsAndOperatorsThatGenerateSequences SYSTEM 
"cat/FunctionsAndOperatorsThatGenerateSequences.xml">
 
 <!ENTITY GhcndPartition1Queries SYSTEM "cat/GhcndPartition1Queries.xml">
 <!ENTITY GhcndPartition2Queries SYSTEM "cat/GhcndPartition2Queries.xml">
@@ -39,10 +40,6 @@
 <!ENTITY SingleQuery SYSTEM "cat/SingleQuery.xml">
 <!ENTITY SingleAlternateQuery SYSTEM "cat/SingleAlternateQuery.xml">
 
-<!ENTITY TestRewriteRules SYSTEM "cat/TestRewriteRules.xml">
-
-
-
 ]>
 <test-suite xmlns="http://www.w3.org/2005/02/query-test-XQTSCatalog";
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
@@ -108,12 +105,6 @@
           </GroupInfo>
          &SingleAlternateQuery;
       </test-group>
-      <test-group name="DocRewriteRuleTest" featureOwner="Shiavni Mall">
-         <GroupInfo>
-            <title>Doc Rewrite Rule Test</title>
-         </GroupInfo>
-         &TestRewriteRules;
-      </test-group>
    </test-group>
    <test-group name="AggregatePartitionQueries" featureOwner="Preston Carman">
       <GroupInfo>
@@ -143,6 +134,13 @@
          &FunctionsAndOperatorsOnNumericsQueries;
       </test-group>
    </test-group>
+   <test-group name="FunctionsAndOperatorsThatGenerateSequences" 
featureOwner="Shiavni Mall">
+        <GroupInfo>
+           <title>Functions and Operators that Generate Sequences</title>
+           <description/>
+        </GroupInfo>
+        &FunctionsAndOperatorsThatGenerateSequences;
+   </test-group>
    <test-group name="GhcndPartitionQueries" featureOwner="Preston Carman">
       <GroupInfo>
          <title>GHCND Partition Queries</title>

http://git-wip-us.apache.org/repos/asf/vxquery/blob/911bc5b1/vxquery-xtest/src/test/resources/cat/FunctionsAndOperatorsOnNumericsQueries.xml
----------------------------------------------------------------------
diff --git 
a/vxquery-xtest/src/test/resources/cat/FunctionsAndOperatorsOnNumericsQueries.xml
 
b/vxquery-xtest/src/test/resources/cat/FunctionsAndOperatorsOnNumericsQueries.xml
index aacc9ea..52a1e69 100644
--- 
a/vxquery-xtest/src/test/resources/cat/FunctionsAndOperatorsOnNumericsQueries.xml
+++ 
b/vxquery-xtest/src/test/resources/cat/FunctionsAndOperatorsOnNumericsQueries.xml
@@ -15,7 +15,7 @@
   limitations under the License.
 -->
 
-<test-group xmlns="http://www.w3.org/2005/02/query-test-XQTSCatalog"; 
name="GhcndRecordsPartition1Queries" featureOwner="VXQuery">
+<test-group xmlns="http://www.w3.org/2005/02/query-test-XQTSCatalog"; 
name="FunctionsAndOperatorsOnNumericQueries" featureOwner="VXQuery">
    <GroupInfo>
       <title>Function and Operators on Numerics</title>
       <description/>

http://git-wip-us.apache.org/repos/asf/vxquery/blob/911bc5b1/vxquery-xtest/src/test/resources/cat/FunctionsAndOperatorsThatGenerateSequences.xml
----------------------------------------------------------------------
diff --git 
a/vxquery-xtest/src/test/resources/cat/FunctionsAndOperatorsThatGenerateSequences.xml
 
b/vxquery-xtest/src/test/resources/cat/FunctionsAndOperatorsThatGenerateSequences.xml
new file mode 100644
index 0000000..2b52f15
--- /dev/null
+++ 
b/vxquery-xtest/src/test/resources/cat/FunctionsAndOperatorsThatGenerateSequences.xml
@@ -0,0 +1,28 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<test-group xmlns="http://www.w3.org/2005/02/query-test-XQTSCatalog"; 
name="FunctionsAndOperatorsThatGenerateSequences" featureOwner="VXQuery">
+   <GroupInfo>
+      <title>Functions and Operators that Generate Sequences</title>
+   </GroupInfo>
+   <test-case name="functions-and-operators-that-generate-sequences-fn_doc" 
FilePath="Simple/" Creator="Shivani Mall">
+      <description>Query for fn:doc with uri.</description>
+      <query name="fn_doc" date="2015-06-19"/>
+      <output-file compare="Text">fn_doc.xml</output-file>
+   </test-case>
+</test-group>
+ 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/vxquery/blob/911bc5b1/vxquery-xtest/src/test/resources/cat/GhcndPartition2Queries.xml
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/cat/GhcndPartition2Queries.xml 
b/vxquery-xtest/src/test/resources/cat/GhcndPartition2Queries.xml
index 73c01e1..1075183 100644
--- a/vxquery-xtest/src/test/resources/cat/GhcndPartition2Queries.xml
+++ b/vxquery-xtest/src/test/resources/cat/GhcndPartition2Queries.xml
@@ -15,7 +15,7 @@
   limitations under the License.
 -->
 
-<test-group xmlns="http://www.w3.org/2005/02/query-test-XQTSCatalog"; 
name="GhcndPartition1Queries" featureOwner="VXQuery">
+<test-group xmlns="http://www.w3.org/2005/02/query-test-XQTSCatalog"; 
name="GhcndPartition2Queries" featureOwner="VXQuery">
    <GroupInfo>
       <title>GHCND Partition 1</title>
       <description/>

http://git-wip-us.apache.org/repos/asf/vxquery/blob/911bc5b1/vxquery-xtest/src/test/resources/cat/SingleAlternateQuery.xml
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/cat/SingleAlternateQuery.xml 
b/vxquery-xtest/src/test/resources/cat/SingleAlternateQuery.xml
index ea444d8..bba230c 100644
--- a/vxquery-xtest/src/test/resources/cat/SingleAlternateQuery.xml
+++ b/vxquery-xtest/src/test/resources/cat/SingleAlternateQuery.xml
@@ -15,7 +15,7 @@
   limitations under the License.
 -->
 
-<test-group xmlns="http://www.w3.org/2005/02/query-test-XQTSCatalog"; 
name="AggregatePartition1Queries" featureOwner="VXQuery">
+<test-group xmlns="http://www.w3.org/2005/02/query-test-XQTSCatalog"; 
name="SingleAlternateQuery" featureOwner="VXQuery">
    <GroupInfo>
       <title>Single Test</title>
       <description/>

http://git-wip-us.apache.org/repos/asf/vxquery/blob/911bc5b1/vxquery-xtest/src/test/resources/cat/SingleQuery.xml
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/cat/SingleQuery.xml 
b/vxquery-xtest/src/test/resources/cat/SingleQuery.xml
index add4fab..42ab548 100644
--- a/vxquery-xtest/src/test/resources/cat/SingleQuery.xml
+++ b/vxquery-xtest/src/test/resources/cat/SingleQuery.xml
@@ -13,7 +13,7 @@
   limitations under the License.
 -->
 
-<test-group xmlns="http://www.w3.org/2005/02/query-test-XQTSCatalog"; 
name="AggregatePartition1Queries" featureOwner="VXQuery">
+<test-group xmlns="http://www.w3.org/2005/02/query-test-XQTSCatalog"; 
name="SingleQuery" featureOwner="VXQuery">
    <GroupInfo>
       <title>Single Test</title>
       <description/>

http://git-wip-us.apache.org/repos/asf/vxquery/blob/911bc5b1/vxquery-xtest/src/test/resources/cat/XMarkOriginalQueries.xml
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/cat/XMarkOriginalQueries.xml 
b/vxquery-xtest/src/test/resources/cat/XMarkOriginalQueries.xml
index 3ebe301..87a57d1 100644
--- a/vxquery-xtest/src/test/resources/cat/XMarkOriginalQueries.xml
+++ b/vxquery-xtest/src/test/resources/cat/XMarkOriginalQueries.xml
@@ -15,7 +15,7 @@
   limitations under the License.
 -->
 
-<test-group xmlns="http://www.w3.org/2005/02/query-test-XQTSCatalog"; 
name="XMarkQueries" featureOwner="VXQuery">
+<test-group xmlns="http://www.w3.org/2005/02/query-test-XQTSCatalog"; 
name="XMarkOriginalQueries" featureOwner="VXQuery">
    <GroupInfo>
       <title>XMark Queries</title>
       <description/>

Reply via email to