incubator-vxquery-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prest...@apache.org
Subject svn commit: r1384153 - in /incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions: cast/CastScalarEvaluatorFactory.java castable/CastableScalarEvaluatorFactory.java util/FunctionHelper.java
Date Wed, 12 Sep 2012 22:29:46 GMT
Author: prestonc
Date: Wed Sep 12 22:29:46 2012
New Revision: 1384153

URL: http://svn.apache.org/viewvc?rev=1384153&view=rev
Log:
Adding a few more functions to the util and other clean up items.

Modified:
    incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastScalarEvaluatorFactory.java
    incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/castable/CastableScalarEvaluatorFactory.java
    incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/FunctionHelper.java

Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastScalarEvaluatorFactory.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastScalarEvaluatorFactory.java?rev=1384153&r1=1384152&r2=1384153&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastScalarEvaluatorFactory.java
(original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastScalarEvaluatorFactory.java
Wed Sep 12 22:29:46 2012
@@ -19,17 +19,11 @@ package org.apache.vxquery.runtime.funct
 import java.io.DataOutput;
 
 import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
-import org.apache.vxquery.datamodel.accessors.atomic.XSBinaryPointable;
-import org.apache.vxquery.datamodel.accessors.atomic.XSDatePointable;
-import org.apache.vxquery.datamodel.accessors.atomic.XSDateTimePointable;
-import org.apache.vxquery.datamodel.accessors.atomic.XSDecimalPointable;
-import org.apache.vxquery.datamodel.accessors.atomic.XSDurationPointable;
-import org.apache.vxquery.datamodel.accessors.atomic.XSQNamePointable;
-import org.apache.vxquery.datamodel.accessors.atomic.XSTimePointable;
 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.type.AbstractTypeScalarEvaluatorFactory;
+import org.apache.vxquery.runtime.functions.util.FunctionHelper;
 import org.apache.vxquery.types.BuiltinTypeRegistry;
 import org.apache.vxquery.types.SequenceType;
 
@@ -38,14 +32,6 @@ 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.BooleanPointable;
-import edu.uci.ics.hyracks.data.std.primitive.BytePointable;
-import edu.uci.ics.hyracks.data.std.primitive.DoublePointable;
-import edu.uci.ics.hyracks.data.std.primitive.FloatPointable;
-import edu.uci.ics.hyracks.data.std.primitive.IntegerPointable;
-import edu.uci.ics.hyracks.data.std.primitive.LongPointable;
-import edu.uci.ics.hyracks.data.std.primitive.ShortPointable;
-import edu.uci.ics.hyracks.data.std.primitive.UTF8StringPointable;
 import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
 
 public class CastScalarEvaluatorFactory extends AbstractTypeScalarEvaluatorFactory {
@@ -61,7 +47,7 @@ public class CastScalarEvaluatorFactory 
         return new AbstractTypeScalarEvaluator(args, ctx) {
             final ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
             final DataOutput dOut = abvs.getDataOutput();
-            final TypedPointables tp = new TypedPointables();
+            final FunctionHelper.TypedPointables tp = new FunctionHelper.TypedPointables();
             AbstractCastToOperation aOp = new CastToStringOperation();
 
             @Override
@@ -303,6 +289,8 @@ public class CastScalarEvaluatorFactory 
                     aOp = new CastToBase64BinaryOperation();
                 } else if (sType.getItemType() == BuiltinTypeRegistry.XS_BOOLEAN) {
                     aOp = new CastToBooleanOperation();
+                } else if (sType.getItemType() == BuiltinTypeRegistry.XS_BYTE) {
+                    aOp = new CastToByteOperation();
                 } else if (sType.getItemType() == BuiltinTypeRegistry.XS_DATE) {
                     aOp = new CastToDateOperation();
                 } else if (sType.getItemType() == BuiltinTypeRegistry.XS_DATETIME) {
@@ -327,27 +315,12 @@ public class CastScalarEvaluatorFactory 
                     aOp = new CastToGYearOperation();
                 } else if (sType.getItemType() == BuiltinTypeRegistry.XS_G_YEAR_MONTH) {
                     aOp = new CastToGYearMonthOperation();
-                } else if (sType.getItemType() == BuiltinTypeRegistry.XS_INTEGER) {
-                    aOp = new CastToIntegerOperation();
                 } else if (sType.getItemType() == BuiltinTypeRegistry.XS_HEX_BINARY) {
                     aOp = new CastToHexBinaryOperation();
-                } else if (sType.getItemType() == BuiltinTypeRegistry.XS_NOTATION) {
-                    aOp = new CastToNotationOperation();
-                } else if (sType.getItemType() == BuiltinTypeRegistry.XS_QNAME) {
-                    aOp = new CastToQNameOperation();
-                } else if (sType.getItemType() == BuiltinTypeRegistry.XS_STRING) {
-                    aOp = new CastToStringOperation();
-                } else if (sType.getItemType() == BuiltinTypeRegistry.XS_TIME) {
-                    aOp = new CastToTimeOperation();
-                } else if (sType.getItemType() == BuiltinTypeRegistry.XS_UNTYPED_ATOMIC)
{
-                    aOp = new CastToUntypedAtomicOperation();
-                } else if (sType.getItemType() == BuiltinTypeRegistry.XS_YEAR_MONTH_DURATION)
{
-                    aOp = new CastToYMDurationOperation();
-
-                } else if (sType.getItemType() == BuiltinTypeRegistry.XS_BYTE) {
-                    aOp = new CastToByteOperation();
                 } else if (sType.getItemType() == BuiltinTypeRegistry.XS_INT) {
                     aOp = new CastToIntOperation();
+                } else if (sType.getItemType() == BuiltinTypeRegistry.XS_INTEGER) {
+                    aOp = new CastToIntegerOperation();
                 } else if (sType.getItemType() == BuiltinTypeRegistry.XS_LONG) {
                     aOp = new CastToLongOperation();
                 } else if (sType.getItemType() == BuiltinTypeRegistry.XS_NEGATIVE_INTEGER)
{
@@ -356,10 +329,20 @@ public class CastScalarEvaluatorFactory 
                     aOp = new CastToNonNegativeIntegerOperation();
                 } else if (sType.getItemType() == BuiltinTypeRegistry.XS_NON_POSITIVE_INTEGER)
{
                     aOp = new CastToNonPositiveIntegerOperation();
+                } else if (sType.getItemType() == BuiltinTypeRegistry.XS_NOTATION) {
+                    aOp = new CastToNotationOperation();
                 } else if (sType.getItemType() == BuiltinTypeRegistry.XS_POSITIVE_INTEGER)
{
                     aOp = new CastToPositiveIntegerOperation();
+                } else if (sType.getItemType() == BuiltinTypeRegistry.XS_QNAME) {
+                    aOp = new CastToQNameOperation();
                 } else if (sType.getItemType() == BuiltinTypeRegistry.XS_SHORT) {
                     aOp = new CastToShortOperation();
+                } else if (sType.getItemType() == BuiltinTypeRegistry.XS_STRING) {
+                    aOp = new CastToStringOperation();
+                } else if (sType.getItemType() == BuiltinTypeRegistry.XS_TIME) {
+                    aOp = new CastToTimeOperation();
+                } else if (sType.getItemType() == BuiltinTypeRegistry.XS_UNTYPED_ATOMIC)
{
+                    aOp = new CastToUntypedAtomicOperation();
                 } else if (sType.getItemType() == BuiltinTypeRegistry.XS_UNSIGNED_BYTE) {
                     aOp = new CastToUnsignedByteOperation();
                 } else if (sType.getItemType() == BuiltinTypeRegistry.XS_UNSIGNED_INT) {
@@ -368,7 +351,8 @@ public class CastScalarEvaluatorFactory 
                     aOp = new CastToUnsignedLongOperation();
                 } else if (sType.getItemType() == BuiltinTypeRegistry.XS_UNSIGNED_SHORT)
{
                     aOp = new CastToUnsignedShortOperation();
-
+                } else if (sType.getItemType() == BuiltinTypeRegistry.XS_YEAR_MONTH_DURATION)
{
+                    aOp = new CastToYMDurationOperation();
                 } else {
                     aOp = new CastToUntypedAtomicOperation();
                 }
@@ -377,22 +361,4 @@ public class CastScalarEvaluatorFactory 
         };
     }
 
-    private static class TypedPointables {
-        BooleanPointable boolp = (BooleanPointable) BooleanPointable.FACTORY.createPointable();
-        BytePointable bytep = (BytePointable) BytePointable.FACTORY.createPointable();
-        ShortPointable shortp = (ShortPointable) ShortPointable.FACTORY.createPointable();
-        IntegerPointable intp = (IntegerPointable) IntegerPointable.FACTORY.createPointable();
-        LongPointable longp = (LongPointable) LongPointable.FACTORY.createPointable();
-        FloatPointable floatp = (FloatPointable) FloatPointable.FACTORY.createPointable();
-        DoublePointable doublep = (DoublePointable) DoublePointable.FACTORY.createPointable();
-        UTF8StringPointable utf8sp = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();
-        XSBinaryPointable binaryp = (XSBinaryPointable) XSBinaryPointable.FACTORY.createPointable();
-        XSDecimalPointable decp = (XSDecimalPointable) XSDecimalPointable.FACTORY.createPointable();
-        XSDateTimePointable datetimep = (XSDateTimePointable) XSDateTimePointable.FACTORY.createPointable();
-        XSDatePointable datep = (XSDatePointable) XSDatePointable.FACTORY.createPointable();
-        XSDurationPointable durationp = (XSDurationPointable) XSDurationPointable.FACTORY.createPointable();
-        XSTimePointable timep = (XSTimePointable) XSTimePointable.FACTORY.createPointable();
-        XSQNamePointable qnamep = (XSQNamePointable) XSQNamePointable.FACTORY.createPointable();
-    }
-
 }
\ No newline at end of file

Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/castable/CastableScalarEvaluatorFactory.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/castable/CastableScalarEvaluatorFactory.java?rev=1384153&r1=1384152&r2=1384153&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/castable/CastableScalarEvaluatorFactory.java
(original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/castable/CastableScalarEvaluatorFactory.java
Wed Sep 12 22:29:46 2012
@@ -19,17 +19,12 @@ package org.apache.vxquery.runtime.funct
 import java.io.DataOutput;
 
 import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
-import org.apache.vxquery.datamodel.accessors.atomic.XSBinaryPointable;
-import org.apache.vxquery.datamodel.accessors.atomic.XSDatePointable;
-import org.apache.vxquery.datamodel.accessors.atomic.XSDateTimePointable;
-import org.apache.vxquery.datamodel.accessors.atomic.XSDecimalPointable;
-import org.apache.vxquery.datamodel.accessors.atomic.XSDurationPointable;
-import org.apache.vxquery.datamodel.accessors.atomic.XSQNamePointable;
-import org.apache.vxquery.datamodel.accessors.atomic.XSTimePointable;
 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.type.AbstractTypeScalarEvaluatorFactory;
+import org.apache.vxquery.runtime.functions.util.FunctionHelper;
 import org.apache.vxquery.types.BuiltinTypeRegistry;
 import org.apache.vxquery.types.SequenceType;
 
@@ -38,12 +33,6 @@ 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.BooleanPointable;
-import edu.uci.ics.hyracks.data.std.primitive.DoublePointable;
-import edu.uci.ics.hyracks.data.std.primitive.FloatPointable;
-import edu.uci.ics.hyracks.data.std.primitive.IntegerPointable;
-import edu.uci.ics.hyracks.data.std.primitive.LongPointable;
-import edu.uci.ics.hyracks.data.std.primitive.UTF8StringPointable;
 import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
 
 public class CastableScalarEvaluatorFactory extends AbstractTypeScalarEvaluatorFactory {
@@ -59,19 +48,13 @@ public class CastableScalarEvaluatorFact
         return new AbstractTypeScalarEvaluator(args, ctx) {
             final ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
             final DataOutput dOut = abvs.getDataOutput();
-            final TypedPointables tp = new TypedPointables();
+            final FunctionHelper.TypedPointables tp = new FunctionHelper.TypedPointables();
             AbstractCastableAsOperation aOp = new CastableAsStringOperation();
 
             @Override
             protected void evaluate(TaggedValuePointable tvp, IPointable result) throws SystemException
{
-                int tid = getBaseTypeForCasts(tvp.getTag());
-                if (tid == ValueTag.XS_UNTYPED_ATOMIC_TAG) {
-                    // TODO Convert to double
-                    tid = ValueTag.XS_DOUBLE_TAG;
-                    throw new UnsupportedOperationException();
-                }
-
                 abvs.reset();
+                int tid = tvp.getTag();
                 try {
                     switch (tid) {
                         case ValueTag.XS_ANY_URI_TAG:
@@ -92,6 +75,12 @@ public class CastableScalarEvaluatorFact
                             result.set(abvs);
                             return;
 
+                        case ValueTag.XS_BYTE_TAG:
+                            tvp.getValue(tp.bytep);
+                            aOp.convertByte(tp.bytep, dOut);
+                            result.set(abvs);
+                            return;
+
                         case ValueTag.XS_DATE_TAG:
                             tvp.getValue(tp.datep);
                             aOp.convertDate(tp.datep, dOut);
@@ -170,24 +159,70 @@ public class CastableScalarEvaluatorFact
                             result.set(abvs);
                             return;
 
+                        case ValueTag.XS_INT_TAG:
+                            tvp.getValue(tp.intp);
+                            aOp.convertInt(tp.intp, dOut);
+                            result.set(abvs);
+                            return;
+
                         case ValueTag.XS_INTEGER_TAG:
                             tvp.getValue(tp.longp);
                             aOp.convertInteger(tp.longp, dOut);
                             result.set(abvs);
                             return;
 
+                        case ValueTag.XS_LONG_TAG:
+                            tvp.getValue(tp.longp);
+                            aOp.convertLong(tp.longp, dOut);
+                            result.set(abvs);
+                            return;
+
+                        case ValueTag.XS_NEGATIVE_INTEGER_TAG:
+                            tvp.getValue(tp.longp);
+                            aOp.convertNegativeInteger(tp.longp, dOut);
+                            result.set(abvs);
+                            return;
+
+                        case ValueTag.XS_NON_NEGATIVE_INTEGER_TAG:
+                            tvp.getValue(tp.longp);
+                            aOp.convertNonNegativeInteger(tp.longp, dOut);
+                            result.set(abvs);
+                            return;
+
+                        case ValueTag.XS_NON_POSITIVE_INTEGER_TAG:
+                            tvp.getValue(tp.longp);
+                            aOp.convertNonPositiveInteger(tp.longp, dOut);
+                            result.set(abvs);
+                            return;
+
                         case ValueTag.XS_NOTATION_TAG:
                             tvp.getValue(tp.utf8sp);
                             aOp.convertNotation(tp.utf8sp, dOut);
                             result.set(abvs);
                             return;
 
+                        case ValueTag.XS_POSITIVE_INTEGER_TAG:
+                            tvp.getValue(tp.longp);
+                            aOp.convertPositiveInteger(tp.longp, dOut);
+                            result.set(abvs);
+                            return;
+
                         case ValueTag.XS_QNAME_TAG:
                             tvp.getValue(tp.qnamep);
                             aOp.convertQName(tp.qnamep, dOut);
                             result.set(abvs);
                             return;
 
+                        case ValueTag.SEQUENCE_TAG:
+                            XDMConstants.setFalse(result);
+                            return;
+
+                        case ValueTag.XS_SHORT_TAG:
+                            tvp.getValue(tp.shortp);
+                            aOp.convertShort(tp.shortp, dOut);
+                            result.set(abvs);
+                            return;
+
                         case ValueTag.XS_STRING_TAG:
                             tvp.getValue(tp.utf8sp);
                             aOp.convertString(tp.utf8sp, dOut);
@@ -200,6 +235,30 @@ public class CastableScalarEvaluatorFact
                             result.set(abvs);
                             return;
 
+                        case ValueTag.XS_UNSIGNED_BYTE_TAG:
+                            tvp.getValue(tp.shortp);
+                            aOp.convertShort(tp.shortp, dOut);
+                            result.set(abvs);
+                            return;
+
+                        case ValueTag.XS_UNSIGNED_INT_TAG:
+                            tvp.getValue(tp.longp);
+                            aOp.convertUnsignedInt(tp.longp, dOut);
+                            result.set(abvs);
+                            return;
+
+                        case ValueTag.XS_UNSIGNED_LONG_TAG:
+                            tvp.getValue(tp.longp);
+                            aOp.convertUnsignedLong(tp.longp, dOut);
+                            result.set(abvs);
+                            return;
+
+                        case ValueTag.XS_UNSIGNED_SHORT_TAG:
+                            tvp.getValue(tp.intp);
+                            aOp.convertUnsignedShort(tp.intp, dOut);
+                            result.set(abvs);
+                            return;
+
                         case ValueTag.XS_UNTYPED_ATOMIC_TAG:
                             tvp.getValue(tp.utf8sp);
                             aOp.convertUntypedAtomic(tp.utf8sp, dOut);
@@ -229,6 +288,8 @@ public class CastableScalarEvaluatorFact
                     aOp = new CastableAsBase64BinaryOperation();
                 } else if (sType.getItemType() == BuiltinTypeRegistry.XS_BOOLEAN) {
                     aOp = new CastableAsBooleanOperation();
+                } else if (sType.getItemType() == BuiltinTypeRegistry.XS_BYTE) {
+                    aOp = new CastableAsByteOperation();
                 } else if (sType.getItemType() == BuiltinTypeRegistry.XS_DATE) {
                     aOp = new CastableAsDateOperation();
                 } else if (sType.getItemType() == BuiltinTypeRegistry.XS_DATETIME) {
@@ -253,18 +314,38 @@ public class CastableScalarEvaluatorFact
                     aOp = new CastableAsGYearOperation();
                 } else if (sType.getItemType() == BuiltinTypeRegistry.XS_G_YEAR_MONTH) {
                     aOp = new CastableAsGYearMonthOperation();
-                } else if (sType.getItemType() == BuiltinTypeRegistry.XS_INTEGER) {
-                    aOp = new CastableAsIntegerOperation();
                 } else if (sType.getItemType() == BuiltinTypeRegistry.XS_HEX_BINARY) {
                     aOp = new CastableAsHexBinaryOperation();
+                } else if (sType.getItemType() == BuiltinTypeRegistry.XS_INT) {
+                    aOp = new CastableAsIntOperation();
+                } else if (sType.getItemType() == BuiltinTypeRegistry.XS_INTEGER) {
+                    aOp = new CastableAsIntegerOperation();
+                } else if (sType.getItemType() == BuiltinTypeRegistry.XS_LONG) {
+                    aOp = new CastableAsLongOperation();
+                } else if (sType.getItemType() == BuiltinTypeRegistry.XS_NEGATIVE_INTEGER)
{
+                    aOp = new CastableAsNegativeIntegerOperation();
+                } else if (sType.getItemType() == BuiltinTypeRegistry.XS_NON_NEGATIVE_INTEGER)
{
+                    aOp = new CastableAsNonNegativeIntegerOperation();
+                } else if (sType.getItemType() == BuiltinTypeRegistry.XS_NON_POSITIVE_INTEGER)
{
+                    aOp = new CastableAsNonPositiveIntegerOperation();
                 } else if (sType.getItemType() == BuiltinTypeRegistry.XS_NOTATION) {
                     aOp = new CastableAsNotationOperation();
                 } else if (sType.getItemType() == BuiltinTypeRegistry.XS_QNAME) {
                     aOp = new CastableAsQNameOperation();
+                } else if (sType.getItemType() == BuiltinTypeRegistry.XS_SHORT) {
+                    aOp = new CastableAsShortOperation();
                 } else if (sType.getItemType() == BuiltinTypeRegistry.XS_STRING) {
                     aOp = new CastableAsStringOperation();
                 } else if (sType.getItemType() == BuiltinTypeRegistry.XS_TIME) {
                     aOp = new CastableAsTimeOperation();
+                } else if (sType.getItemType() == BuiltinTypeRegistry.XS_UNSIGNED_BYTE) {
+                    aOp = new CastableAsUnsignedByteOperation();
+                } else if (sType.getItemType() == BuiltinTypeRegistry.XS_UNSIGNED_INT) {
+                    aOp = new CastableAsUnsignedIntOperation();
+                } else if (sType.getItemType() == BuiltinTypeRegistry.XS_UNSIGNED_LONG) {
+                    aOp = new CastableAsUnsignedLongOperation();
+                } else if (sType.getItemType() == BuiltinTypeRegistry.XS_UNSIGNED_SHORT)
{
+                    aOp = new CastableAsUnsignedShortOperation();
                 } else if (sType.getItemType() == BuiltinTypeRegistry.XS_UNTYPED_ATOMIC)
{
                     aOp = new CastableAsUntypedAtomicOperation();
                 } else if (sType.getItemType() == BuiltinTypeRegistry.XS_YEAR_MONTH_DURATION)
{
@@ -274,59 +355,7 @@ public class CastableScalarEvaluatorFact
                 }
             }
 
-            private int getBaseTypeForCasts(int tid) throws SystemException {
-                while (true) {
-                    switch (tid) {
-                        case ValueTag.XS_ANY_URI_TAG:
-                        case ValueTag.XS_BASE64_BINARY_TAG:
-                        case ValueTag.XS_BOOLEAN_TAG:
-                        case ValueTag.XS_DATE_TAG:
-                        case ValueTag.XS_DATETIME_TAG:
-                        case ValueTag.XS_DAY_TIME_DURATION_TAG:
-                        case ValueTag.XS_DECIMAL_TAG:
-                        case ValueTag.XS_DOUBLE_TAG:
-                        case ValueTag.XS_DURATION_TAG:
-                        case ValueTag.XS_FLOAT_TAG:
-                        case ValueTag.XS_G_DAY_TAG:
-                        case ValueTag.XS_G_MONTH_DAY_TAG:
-                        case ValueTag.XS_G_MONTH_TAG:
-                        case ValueTag.XS_G_YEAR_MONTH_TAG:
-                        case ValueTag.XS_G_YEAR_TAG:
-                        case ValueTag.XS_HEX_BINARY_TAG:
-                        case ValueTag.XS_INTEGER_TAG:
-                        case ValueTag.XS_QNAME_TAG:
-                        case ValueTag.XS_STRING_TAG:
-                        case ValueTag.XS_TIME_TAG:
-                        case ValueTag.XS_UNTYPED_ATOMIC_TAG:
-                        case ValueTag.XS_YEAR_MONTH_DURATION_TAG:
-                            return tid;
-
-                        case ValueTag.XS_ANY_ATOMIC_TAG:
-                            throw new SystemException(ErrorCode.XPTY0004);
-
-                        default:
-                            tid = BuiltinTypeRegistry.INSTANCE.getSchemaTypeById(tid).getBaseType().getTypeId();
-                    }
-                }
-            }
-
         };
     }
 
-    private static class TypedPointables {
-        BooleanPointable boolp = (BooleanPointable) BooleanPointable.FACTORY.createPointable();
-        IntegerPointable intp = (IntegerPointable) IntegerPointable.FACTORY.createPointable();
-        LongPointable longp = (LongPointable) LongPointable.FACTORY.createPointable();
-        FloatPointable floatp = (FloatPointable) FloatPointable.FACTORY.createPointable();
-        DoublePointable doublep = (DoublePointable) DoublePointable.FACTORY.createPointable();
-        UTF8StringPointable utf8sp = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();
-        XSBinaryPointable binaryp = (XSBinaryPointable) XSBinaryPointable.FACTORY.createPointable();
-        XSDecimalPointable decp = (XSDecimalPointable) XSDecimalPointable.FACTORY.createPointable();
-        XSDateTimePointable datetimep = (XSDateTimePointable) XSDateTimePointable.FACTORY.createPointable();
-        XSDatePointable datep = (XSDatePointable) XSDatePointable.FACTORY.createPointable();
-        XSDurationPointable durationp = (XSDurationPointable) XSDurationPointable.FACTORY.createPointable();
-        XSTimePointable timep = (XSTimePointable) XSTimePointable.FACTORY.createPointable();
-        XSQNamePointable qnamep = (XSQNamePointable) XSQNamePointable.FACTORY.createPointable();
-    }
-
 }
\ No newline at end of file

Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/FunctionHelper.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/FunctionHelper.java?rev=1384153&r1=1384152&r2=1384153&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/FunctionHelper.java
(original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/FunctionHelper.java
Wed Sep 12 22:29:46 2012
@@ -32,6 +32,7 @@ import org.apache.vxquery.datamodel.util
 import org.apache.vxquery.datamodel.values.ValueTag;
 import org.apache.vxquery.exceptions.ErrorCode;
 import org.apache.vxquery.exceptions.SystemException;
+import org.apache.vxquery.types.BuiltinTypeConstants;
 import org.apache.vxquery.types.BuiltinTypeRegistry;
 
 import edu.uci.ics.hyracks.data.std.primitive.BooleanPointable;
@@ -135,11 +136,78 @@ public class FunctionHelper {
                 case ValueTag.XS_YEAR_MONTH_DURATION_TAG:
                     return tid;
 
+                case ValueTag.XS_LONG_TAG:
+                case ValueTag.XS_NEGATIVE_INTEGER_TAG:
+                case ValueTag.XS_NON_POSITIVE_INTEGER_TAG:
+                case ValueTag.XS_NON_NEGATIVE_INTEGER_TAG:
+                case ValueTag.XS_POSITIVE_INTEGER_TAG:
+                case ValueTag.XS_UNSIGNED_INT_TAG:
+                case ValueTag.XS_UNSIGNED_LONG_TAG:
+                case ValueTag.XS_INT_TAG:
+                case ValueTag.XS_UNSIGNED_SHORT_TAG:
+                case ValueTag.XS_SHORT_TAG:
+                case ValueTag.XS_UNSIGNED_BYTE_TAG:
+                case ValueTag.XS_BYTE_TAG:
+                    return ValueTag.XS_INTEGER_TAG;
+
+                case ValueTag.XS_ANY_ATOMIC_TAG:
+                    throw new SystemException(ErrorCode.XPTY0004);
+
+                default:
+                    tid = BuiltinTypeRegistry.INSTANCE.getSchemaTypeById(tid).getBaseType().getTypeId();
+            }
+        }
+    }
+
+    public static int getBaseTypeForArithmetics(int tid) throws SystemException {
+        if (tid >= BuiltinTypeConstants.BUILTIN_TYPE_COUNT) {
+            throw new SystemException(ErrorCode.XPTY0004);
+        }
+        while (true) {
+            switch (tid) {
+                case ValueTag.XS_STRING_TAG:
+                case ValueTag.XS_DECIMAL_TAG:
+                case ValueTag.XS_INTEGER_TAG:
+                case ValueTag.XS_FLOAT_TAG:
+                case ValueTag.XS_DOUBLE_TAG:
+                case ValueTag.XS_ANY_URI_TAG:
+                case ValueTag.XS_BOOLEAN_TAG:
+                case ValueTag.XS_DATE_TAG:
+                case ValueTag.XS_DATETIME_TAG:
+                case ValueTag.XS_TIME_TAG:
+                case ValueTag.XS_DAY_TIME_DURATION_TAG:
+                case ValueTag.XS_YEAR_MONTH_DURATION_TAG:
+                case ValueTag.XS_BASE64_BINARY_TAG:
+                case ValueTag.XS_HEX_BINARY_TAG:
+                case ValueTag.XS_QNAME_TAG:
+                case ValueTag.XS_G_DAY_TAG:
+                case ValueTag.XS_G_MONTH_DAY_TAG:
+                case ValueTag.XS_G_MONTH_TAG:
+                case ValueTag.XS_G_YEAR_MONTH_TAG:
+                case ValueTag.XS_G_YEAR_TAG:
+                case ValueTag.XS_UNTYPED_ATOMIC_TAG:
+                    return tid;
+
+                case ValueTag.XS_LONG_TAG:
+                case ValueTag.XS_NEGATIVE_INTEGER_TAG:
+                case ValueTag.XS_NON_POSITIVE_INTEGER_TAG:
+                case ValueTag.XS_NON_NEGATIVE_INTEGER_TAG:
+                case ValueTag.XS_POSITIVE_INTEGER_TAG:
+                case ValueTag.XS_UNSIGNED_INT_TAG:
+                case ValueTag.XS_UNSIGNED_LONG_TAG:
+                case ValueTag.XS_INT_TAG:
+                case ValueTag.XS_UNSIGNED_SHORT_TAG:
+                case ValueTag.XS_SHORT_TAG:
+                case ValueTag.XS_UNSIGNED_BYTE_TAG:
+                case ValueTag.XS_BYTE_TAG:
+                    return ValueTag.XS_INTEGER_TAG;
+
                 case ValueTag.XS_ANY_ATOMIC_TAG:
                     throw new SystemException(ErrorCode.XPTY0004);
 
                 default:
                     tid = BuiltinTypeRegistry.INSTANCE.getSchemaTypeById(tid).getBaseType().getTypeId();
+                    return tid;
             }
         }
     }



Mime
View raw message