incubator-vxquery-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prest...@apache.org
Subject svn commit: r1380919 - in /incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery: functions/ runtime/functions/sequence/
Date Tue, 04 Sep 2012 22:09:14 GMT
Author: prestonc
Date: Tue Sep  4 22:09:14 2012
New Revision: 1380919

URL: http://svn.apache.org/viewvc?rev=1380919&view=rev
Log:
VXQUERY-75 Added FnZeroOrOne, FnExactlyOne and FnOneOrMore.

Added:
    incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/sequence/FnExactlyOneScalarEvaluatorFactory.java
  (with props)
    incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/sequence/FnOneOrMoreScalarEvaluatorFactory.java
  (with props)
    incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/sequence/FnZeroOrOneScalarEvaluatorFactory.java
  (with props)
Modified:
    incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-functions.xml

Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-functions.xml
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-functions.xml?rev=1380919&r1=1380918&r2=1380919&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-functions.xml
(original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-functions.xml
Tue Sep  4 22:09:14 2012
@@ -343,6 +343,7 @@
     <function name="fn:exactly-one">
         <param name="arg" type="item()*"/>
         <return type="item()"/>
+        <runtime type="scalar" class="org.apache.vxquery.runtime.functions.sequence.FnExactlyOneScalarEvaluatorFactory"/>
     </function>
 
     <!-- fn:exists($arg as  item()*) as xs:boolean -->
@@ -673,6 +674,7 @@
     <function name="fn:one-or-more">
         <param name="arg" type="item()*"/>
         <return type="item()+"/>
+        <runtime type="scalar" class="org.apache.vxquery.runtime.functions.sequence.FnOneOrMoreScalarEvaluatorFactory"/>
     </function>
 
     <!-- fn:position() as  xs:integer -->
@@ -1032,5 +1034,6 @@
     <function name="fn:zero-or-one">
         <param name="arg" type="item()*"/>
         <return type="item()?"/>
+        <runtime type="scalar" class="org.apache.vxquery.runtime.functions.sequence.FnZeroOrOneScalarEvaluatorFactory"/>
     </function>
 </functions>

Added: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/sequence/FnExactlyOneScalarEvaluatorFactory.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/sequence/FnExactlyOneScalarEvaluatorFactory.java?rev=1380919&view=auto
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/sequence/FnExactlyOneScalarEvaluatorFactory.java
(added)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/sequence/FnExactlyOneScalarEvaluatorFactory.java
Tue Sep  4 22:09:14 2012
@@ -0,0 +1,45 @@
+package org.apache.vxquery.runtime.functions.sequence;
+
+import org.apache.vxquery.datamodel.accessors.SequencePointable;
+import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
+import org.apache.vxquery.datamodel.values.ValueTag;
+import org.apache.vxquery.exceptions.ErrorCode;
+import org.apache.vxquery.exceptions.SystemException;
+import org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentScalarEvaluator;
+import org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentScalarEvaluatorFactory;
+
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import edu.uci.ics.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
+import edu.uci.ics.hyracks.data.std.api.IPointable;
+
+public class FnExactlyOneScalarEvaluatorFactory extends AbstractTaggedValueArgumentScalarEvaluatorFactory
{
+    private static final long serialVersionUID = 1L;
+
+    public FnExactlyOneScalarEvaluatorFactory(IScalarEvaluatorFactory[] args) {
+        super(args);
+    }
+
+    @Override
+    protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[]
args)
+            throws AlgebricksException {
+        final SequencePointable seqp = new SequencePointable();
+        return new AbstractTaggedValueArgumentScalarEvaluator(args) {
+            @Override
+            protected void evaluate(TaggedValuePointable[] args, IPointable result) throws
SystemException {
+                TaggedValuePointable tvp = args[0];
+                if (tvp.getTag() == ValueTag.SEQUENCE_TAG) {
+                    tvp.getValue(seqp);
+                    if (seqp.getEntryCount() == 1) {
+                        result.set(tvp);
+                    } else {
+                        throw new SystemException(ErrorCode.FORG0005);
+                    }
+                } else {
+                    result.set(tvp);
+                }
+            }
+        };
+    }
+}
\ No newline at end of file

Propchange: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/sequence/FnExactlyOneScalarEvaluatorFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/sequence/FnOneOrMoreScalarEvaluatorFactory.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/sequence/FnOneOrMoreScalarEvaluatorFactory.java?rev=1380919&view=auto
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/sequence/FnOneOrMoreScalarEvaluatorFactory.java
(added)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/sequence/FnOneOrMoreScalarEvaluatorFactory.java
Tue Sep  4 22:09:14 2012
@@ -0,0 +1,45 @@
+package org.apache.vxquery.runtime.functions.sequence;
+
+import org.apache.vxquery.datamodel.accessors.SequencePointable;
+import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
+import org.apache.vxquery.datamodel.values.ValueTag;
+import org.apache.vxquery.exceptions.ErrorCode;
+import org.apache.vxquery.exceptions.SystemException;
+import org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentScalarEvaluator;
+import org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentScalarEvaluatorFactory;
+
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import edu.uci.ics.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
+import edu.uci.ics.hyracks.data.std.api.IPointable;
+
+public class FnOneOrMoreScalarEvaluatorFactory extends AbstractTaggedValueArgumentScalarEvaluatorFactory
{
+    private static final long serialVersionUID = 1L;
+
+    public FnOneOrMoreScalarEvaluatorFactory(IScalarEvaluatorFactory[] args) {
+        super(args);
+    }
+
+    @Override
+    protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[]
args)
+            throws AlgebricksException {
+        final SequencePointable seqp = new SequencePointable();
+        return new AbstractTaggedValueArgumentScalarEvaluator(args) {
+            @Override
+            protected void evaluate(TaggedValuePointable[] args, IPointable result) throws
SystemException {
+                TaggedValuePointable tvp = args[0];
+                if (tvp.getTag() == ValueTag.SEQUENCE_TAG) {
+                    tvp.getValue(seqp);
+                    if (seqp.getEntryCount() > 0) {
+                        result.set(tvp);
+                    } else {
+                        throw new SystemException(ErrorCode.FORG0004);
+                    }
+                } else {
+                    result.set(tvp);
+                }
+            }
+        };
+    }
+}
\ No newline at end of file

Propchange: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/sequence/FnOneOrMoreScalarEvaluatorFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/sequence/FnZeroOrOneScalarEvaluatorFactory.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/sequence/FnZeroOrOneScalarEvaluatorFactory.java?rev=1380919&view=auto
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/sequence/FnZeroOrOneScalarEvaluatorFactory.java
(added)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/sequence/FnZeroOrOneScalarEvaluatorFactory.java
Tue Sep  4 22:09:14 2012
@@ -0,0 +1,45 @@
+package org.apache.vxquery.runtime.functions.sequence;
+
+import org.apache.vxquery.datamodel.accessors.SequencePointable;
+import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
+import org.apache.vxquery.datamodel.values.ValueTag;
+import org.apache.vxquery.exceptions.ErrorCode;
+import org.apache.vxquery.exceptions.SystemException;
+import org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentScalarEvaluator;
+import org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentScalarEvaluatorFactory;
+
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import edu.uci.ics.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
+import edu.uci.ics.hyracks.data.std.api.IPointable;
+
+public class FnZeroOrOneScalarEvaluatorFactory extends AbstractTaggedValueArgumentScalarEvaluatorFactory
{
+    private static final long serialVersionUID = 1L;
+
+    public FnZeroOrOneScalarEvaluatorFactory(IScalarEvaluatorFactory[] args) {
+        super(args);
+    }
+
+    @Override
+    protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[]
args)
+            throws AlgebricksException {
+        final SequencePointable seqp = new SequencePointable();
+        return new AbstractTaggedValueArgumentScalarEvaluator(args) {
+            @Override
+            protected void evaluate(TaggedValuePointable[] args, IPointable result) throws
SystemException {
+                TaggedValuePointable tvp = args[0];
+                if (tvp.getTag() == ValueTag.SEQUENCE_TAG) {
+                    tvp.getValue(seqp);
+                    if (seqp.getEntryCount() == 0 || seqp.getEntryCount() == 1) {
+                        result.set(tvp);
+                    } else {
+                        throw new SystemException(ErrorCode.FORG0003);
+                    }
+                } else {
+                    result.set(tvp);
+                }
+            }
+        };
+    }
+}
\ No newline at end of file

Propchange: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/sequence/FnZeroOrOneScalarEvaluatorFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message