incubator-vxquery-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prest...@apache.org
Subject svn commit: r1390186 - /incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/qname/
Date Tue, 25 Sep 2012 22:06:05 GMT
Author: prestonc
Date: Tue Sep 25 22:06:05 2012
New Revision: 1390186

URL: http://svn.apache.org/viewvc?rev=1390186&view=rev
Log:
Added support for QName functions to have empty sequence as a parameter.

Modified:
    incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/qname/FnLocalNameFromQNameScalarEvaluatorFactory.java
    incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/qname/FnNamespaceUriFromQNameScalarEvaluatorFactory.java
    incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/qname/FnPrefixFromQNameScalarEvaluatorFactory.java
    incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/qname/FnQNameScalarEvaluatorFactory.java

Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/qname/FnLocalNameFromQNameScalarEvaluatorFactory.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/qname/FnLocalNameFromQNameScalarEvaluatorFactory.java?rev=1390186&r1=1390185&r2=1390186&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/qname/FnLocalNameFromQNameScalarEvaluatorFactory.java
(original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/qname/FnLocalNameFromQNameScalarEvaluatorFactory.java
Tue Sep 25 22:06:05 2012
@@ -18,9 +18,11 @@ package org.apache.vxquery.runtime.funct
 
 import java.io.DataOutput;
 
+import org.apache.vxquery.datamodel.accessors.SequencePointable;
 import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
 import org.apache.vxquery.datamodel.accessors.atomic.XSQNamePointable;
 import org.apache.vxquery.datamodel.values.ValueTag;
+import org.apache.vxquery.datamodel.values.XDMConstants;
 import org.apache.vxquery.exceptions.ErrorCode;
 import org.apache.vxquery.exceptions.SystemException;
 import org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentScalarEvaluator;
@@ -31,6 +33,7 @@ import edu.uci.ics.hyracks.algebricks.ru
 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;
+import edu.uci.ics.hyracks.data.std.primitive.UTF8StringPointable;
 import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
 
 public class FnLocalNameFromQNameScalarEvaluatorFactory extends AbstractTaggedValueArgumentScalarEvaluatorFactory
{
@@ -44,6 +47,8 @@ public class FnLocalNameFromQNameScalarE
     protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[]
args)
             throws AlgebricksException {
         final XSQNamePointable qnamep = (XSQNamePointable) XSQNamePointable.FACTORY.createPointable();
+        final SequencePointable seqp = (SequencePointable) SequencePointable.FACTORY.createPointable();
+        final UTF8StringPointable stringp = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();
         final ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
         final DataOutput dOut = abvs.getDataOutput();
 
@@ -52,18 +57,25 @@ public class FnLocalNameFromQNameScalarE
             protected void evaluate(TaggedValuePointable[] args, IPointable result) throws
SystemException {
                 TaggedValuePointable tvp1 = args[0];
 
-                // Only accept a strings.
+                // Only accept a QNames or empty sequence.
+                if (tvp1.getTag() == ValueTag.SEQUENCE_TAG) {
+                    tvp1.getValue(seqp);
+                    if (seqp.getEntryCount() == 0) {
+                        XDMConstants.setEmptySequence(result);
+                        return;
+                    }
+                    // Pass through.
+                }
                 if (tvp1.getTag() != ValueTag.XS_QNAME_TAG) {
                     throw new SystemException(ErrorCode.FORG0006);
                 }
                 tvp1.getValue(qnamep);
+                qnamep.getLocalName(stringp);
 
                 try {
                     abvs.reset();
                     dOut.write(ValueTag.XS_NCNAME_TAG);
-                    dOut.write(qnamep.getByteArray(),
-                            qnamep.getStartOffset() + qnamep.getUriLength() + qnamep.getPrefixLength(),
-                            qnamep.getLocalNameLength());
+                    dOut.write(stringp.getByteArray(), stringp.getStartOffset(), stringp.getLength());
                     result.set(abvs);
                 } catch (Exception e) {
                     throw new SystemException(ErrorCode.SYSE0001, e);

Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/qname/FnNamespaceUriFromQNameScalarEvaluatorFactory.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/qname/FnNamespaceUriFromQNameScalarEvaluatorFactory.java?rev=1390186&r1=1390185&r2=1390186&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/qname/FnNamespaceUriFromQNameScalarEvaluatorFactory.java
(original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/qname/FnNamespaceUriFromQNameScalarEvaluatorFactory.java
Tue Sep 25 22:06:05 2012
@@ -18,9 +18,11 @@ package org.apache.vxquery.runtime.funct
 
 import java.io.DataOutput;
 
+import org.apache.vxquery.datamodel.accessors.SequencePointable;
 import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
 import org.apache.vxquery.datamodel.accessors.atomic.XSQNamePointable;
 import org.apache.vxquery.datamodel.values.ValueTag;
+import org.apache.vxquery.datamodel.values.XDMConstants;
 import org.apache.vxquery.exceptions.ErrorCode;
 import org.apache.vxquery.exceptions.SystemException;
 import org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentScalarEvaluator;
@@ -31,6 +33,7 @@ import edu.uci.ics.hyracks.algebricks.ru
 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;
+import edu.uci.ics.hyracks.data.std.primitive.UTF8StringPointable;
 import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
 
 public class FnNamespaceUriFromQNameScalarEvaluatorFactory extends AbstractTaggedValueArgumentScalarEvaluatorFactory
{
@@ -44,6 +47,8 @@ public class FnNamespaceUriFromQNameScal
     protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[]
args)
             throws AlgebricksException {
         final XSQNamePointable qnamep = (XSQNamePointable) XSQNamePointable.FACTORY.createPointable();
+        final SequencePointable seqp = (SequencePointable) SequencePointable.FACTORY.createPointable();
+        final UTF8StringPointable stringp = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();
         final ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
         final DataOutput dOut = abvs.getDataOutput();
 
@@ -52,17 +57,30 @@ public class FnNamespaceUriFromQNameScal
             protected void evaluate(TaggedValuePointable[] args, IPointable result) throws
SystemException {
                 TaggedValuePointable tvp1 = args[0];
 
-                // Only accept a strings.
+                // Only accept a QNames or empty sequence.
+                if (tvp1.getTag() == ValueTag.SEQUENCE_TAG) {
+                    tvp1.getValue(seqp);
+                    if (seqp.getEntryCount() == 0) {
+                        XDMConstants.setEmptySequence(result);
+                        return;
+                    }
+                    // Pass through.
+                }
                 if (tvp1.getTag() != ValueTag.XS_QNAME_TAG) {
                     throw new SystemException(ErrorCode.FORG0006);
                 }
                 tvp1.getValue(qnamep);
+                qnamep.getUri(stringp);
 
                 try {
-                    abvs.reset();
-                    dOut.write(ValueTag.XS_NCNAME_TAG);
-                    dOut.write(qnamep.getByteArray(), qnamep.getStartOffset(), qnamep.getUriLength());
-                    result.set(abvs);
+                    if (qnamep.getUriLength() == 0) {
+                        XDMConstants.setEmptyString(result);
+                    } else {
+                        abvs.reset();
+                        dOut.write(ValueTag.XS_NCNAME_TAG);
+                        dOut.write(stringp.getByteArray(), stringp.getStartOffset(), stringp.getLength());
+                        result.set(abvs);
+                    }
                 } catch (Exception e) {
                     throw new SystemException(ErrorCode.SYSE0001, e);
                 }

Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/qname/FnPrefixFromQNameScalarEvaluatorFactory.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/qname/FnPrefixFromQNameScalarEvaluatorFactory.java?rev=1390186&r1=1390185&r2=1390186&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/qname/FnPrefixFromQNameScalarEvaluatorFactory.java
(original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/qname/FnPrefixFromQNameScalarEvaluatorFactory.java
Tue Sep 25 22:06:05 2012
@@ -33,6 +33,7 @@ import edu.uci.ics.hyracks.algebricks.ru
 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;
+import edu.uci.ics.hyracks.data.std.primitive.UTF8StringPointable;
 import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
 
 public class FnPrefixFromQNameScalarEvaluatorFactory extends AbstractTaggedValueArgumentScalarEvaluatorFactory
{
@@ -47,6 +48,7 @@ public class FnPrefixFromQNameScalarEval
             throws AlgebricksException {
         final XSQNamePointable qnamep = (XSQNamePointable) XSQNamePointable.FACTORY.createPointable();
         final SequencePointable seqp = (SequencePointable) SequencePointable.FACTORY.createPointable();
+        final UTF8StringPointable stringp = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();
         final ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
         final DataOutput dOut = abvs.getDataOutput();
 
@@ -68,6 +70,7 @@ public class FnPrefixFromQNameScalarEval
                     throw new SystemException(ErrorCode.FORG0006);
                 }
                 tvp1.getValue(qnamep);
+                qnamep.getPrefix(stringp);
 
                 try {
                     // Return empty sequence if no prefix.
@@ -76,8 +79,7 @@ public class FnPrefixFromQNameScalarEval
                     } else {
                         abvs.reset();
                         dOut.write(ValueTag.XS_NCNAME_TAG);
-                        dOut.write(qnamep.getByteArray(), qnamep.getStartOffset() + qnamep.getUriLength(),
-                                qnamep.getPrefixLength());
+                        dOut.write(stringp.getByteArray(), stringp.getStartOffset(), stringp.getLength());
                         result.set(abvs);
                     }
                 } catch (Exception e) {

Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/qname/FnQNameScalarEvaluatorFactory.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/qname/FnQNameScalarEvaluatorFactory.java?rev=1390186&r1=1390185&r2=1390186&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/qname/FnQNameScalarEvaluatorFactory.java
(original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/qname/FnQNameScalarEvaluatorFactory.java
Tue Sep 25 22:06:05 2012
@@ -18,14 +18,17 @@ package org.apache.vxquery.runtime.funct
 
 import java.io.DataOutput;
 
+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.datamodel.values.XDMConstants;
 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 org.apache.vxquery.runtime.functions.strings.ICharacterIterator;
 import org.apache.vxquery.runtime.functions.strings.UTF8StringCharacterIterator;
+import org.apache.vxquery.runtime.functions.util.FunctionHelper;
 
 import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
 import edu.uci.ics.hyracks.algebricks.runtime.base.IScalarEvaluator;
@@ -51,6 +54,8 @@ public class FnQNameScalarEvaluatorFacto
         final DataOutput dOut = abvs.getDataOutput();
         final ArrayBackedValueStorage abvsParamQName = new ArrayBackedValueStorage();
         final DataOutput dOutParamQName = abvsParamQName.getDataOutput();
+        final SequencePointable seqp = (SequencePointable) SequencePointable.FACTORY.createPointable();
+        final TaggedValuePointable tvp = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
 
         return new AbstractTaggedValueArgumentScalarEvaluator(args) {
             @Override
@@ -59,14 +64,35 @@ public class FnQNameScalarEvaluatorFacto
                 TaggedValuePointable tvp2 = args[1];
 
                 // Only accept a strings.
-                if (tvp1.getTag() != ValueTag.XS_STRING_TAG) {
-                    throw new SystemException(ErrorCode.FORG0006);
-                }
-                if (tvp2.getTag() != ValueTag.XS_STRING_TAG) {
+                if (args.length == 2) {
+                    if (tvp1.getTag() == ValueTag.SEQUENCE_TAG) {
+                        tvp1.getValue(seqp);
+                        if (seqp.getEntryCount() == 0) {
+                            XDMConstants.setEmptyString(tvp);
+                            tvp.getValue(paramURI);
+                        } else {
+                            throw new SystemException(ErrorCode.FORG0006);
+                        }
+                    } else {
+                        if (!FunctionHelper.isDerivedFromString(tvp1.getTag())) {
+                            throw new SystemException(ErrorCode.FORG0006);
+                        }
+                        tvp1.getValue(paramURI);
+                    }
+                    if (tvp2.getTag() != ValueTag.XS_STRING_TAG) {
+                        throw new SystemException(ErrorCode.FORG0006);
+                    }
+                    tvp2.getValue(paramQName);
+                } else if (args.length == 1) {
+                    if (tvp1.getTag() != ValueTag.XS_STRING_TAG) {
+                        throw new SystemException(ErrorCode.FORG0006);
+                    }
+                    XDMConstants.setEmptyString(tvp);
+                    tvp.getValue(paramURI);
+                    tvp2.getValue(paramQName);
+                } else {
                     throw new SystemException(ErrorCode.FORG0006);
                 }
-                tvp1.getValue(paramURI);
-                tvp2.getValue(paramQName);
 
                 try {
                     abvs.reset();



Mime
View raw message