incubator-vxquery-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prest...@apache.org
Subject svn commit: r1381431 [2/2] - /incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/datetime/
Date Wed, 05 Sep 2012 22:46:17 GMT
Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/datetime/FnTimezoneFromTimeScalarEvaluatorFactory.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/datetime/FnTimezoneFromTimeScalarEvaluatorFactory.java?rev=1381431&r1=1381430&r2=1381431&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/datetime/FnTimezoneFromTimeScalarEvaluatorFactory.java
(original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/datetime/FnTimezoneFromTimeScalarEvaluatorFactory.java
Wed Sep  5 22:46:16 2012
@@ -1,58 +1,32 @@
 package org.apache.vxquery.runtime.functions.datetime;
 
-import java.io.DataOutput;
-import java.io.IOException;
-
 import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
 import org.apache.vxquery.datamodel.accessors.atomic.XSTimePointable;
-import org.apache.vxquery.datamodel.util.DateTime;
 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;
-import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
 
-public class FnTimezoneFromTimeScalarEvaluatorFactory extends AbstractTaggedValueArgumentScalarEvaluatorFactory
{
+public class FnTimezoneFromTimeScalarEvaluatorFactory extends AbstractValueFromDateTimeScalarEvaluatorFactory
{
     private static final long serialVersionUID = 1L;
+    final XSTimePointable timep = (XSTimePointable) XSTimePointable.FACTORY.createPointable();
 
     public FnTimezoneFromTimeScalarEvaluatorFactory(IScalarEvaluatorFactory[] args) {
         super(args);
     }
 
     @Override
-    protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[]
args)
-            throws AlgebricksException {
-        final XSTimePointable timep = (XSTimePointable) XSTimePointable.FACTORY.createPointable();
-        final ArrayBackedValueStorage abvsInner = new ArrayBackedValueStorage();
-        final DataOutput dOutInner = abvsInner.getDataOutput();
-
-        return new AbstractTaggedValueArgumentScalarEvaluator(args) {
-            @Override
-            protected void evaluate(TaggedValuePointable[] args, IPointable result) throws
SystemException {
-                TaggedValuePointable tvp1 = args[0];
-                if (tvp1.getTag() != ValueTag.XS_TIME_TAG) {
-                    throw new SystemException(ErrorCode.FORG0006);
-                }
-                tvp1.getValue(timep);
-
-                long value = timep.getTimezoneHour() * DateTime.CHRONON_OF_HOUR + timep.getTimezoneMinute()
-                        * DateTime.CHRONON_OF_MINUTE;
-                try {
-                    abvsInner.reset();
-                    dOutInner.write(ValueTag.XS_DAY_TIME_DURATION_TAG);
-                    dOutInner.writeLong(value);
-                    result.set(abvsInner);
-                } catch (IOException e) {
-                    throw new SystemException(ErrorCode.SYSE0001, e);
-                }
-            }
-        };
+    protected int getInputTag() {
+        return ValueTag.XS_TIME_TAG;
+    }
+
+    @Override
+    protected int getReturnTag() {
+        return ValueTag.XS_DAY_TIME_DURATION_TAG;
+    }
+
+    @Override
+    protected long getInteger(TaggedValuePointable tvp) {
+        tvp.getValue(timep);
+        return getTimezone(timep);
     }
 }

Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/datetime/FnYearFromDateScalarEvaluatorFactory.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/datetime/FnYearFromDateScalarEvaluatorFactory.java?rev=1381431&r1=1381430&r2=1381431&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/datetime/FnYearFromDateScalarEvaluatorFactory.java
(original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/datetime/FnYearFromDateScalarEvaluatorFactory.java
Wed Sep  5 22:46:16 2012
@@ -1,55 +1,27 @@
 package org.apache.vxquery.runtime.functions.datetime;
 
-import java.io.DataOutput;
-import java.io.IOException;
-
 import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
 import org.apache.vxquery.datamodel.accessors.atomic.XSDatePointable;
 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;
-import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
 
-public class FnYearFromDateScalarEvaluatorFactory extends AbstractTaggedValueArgumentScalarEvaluatorFactory
{
+public class FnYearFromDateScalarEvaluatorFactory extends AbstractValueFromDateTimeScalarEvaluatorFactory
{
     private static final long serialVersionUID = 1L;
+    final XSDatePointable datep = (XSDatePointable) XSDatePointable.FACTORY.createPointable();
 
     public FnYearFromDateScalarEvaluatorFactory(IScalarEvaluatorFactory[] args) {
         super(args);
     }
 
     @Override
-    protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[]
args)
-            throws AlgebricksException {
-        final XSDatePointable datep = (XSDatePointable) XSDatePointable.FACTORY.createPointable();
-        final ArrayBackedValueStorage abvsInner = new ArrayBackedValueStorage();
-        final DataOutput dOutInner = abvsInner.getDataOutput();
-
-        return new AbstractTaggedValueArgumentScalarEvaluator(args) {
-            @Override
-            protected void evaluate(TaggedValuePointable[] args, IPointable result) throws
SystemException {
-                TaggedValuePointable tvp1 = args[0];
-                if (tvp1.getTag() != ValueTag.XS_DATE_TAG) {
-                    throw new SystemException(ErrorCode.FORG0006);
-                }
-                tvp1.getValue(datep);
-
-                try {
-                    abvsInner.reset();
-                    dOutInner.write(ValueTag.XS_INTEGER_TAG);
-                    dOutInner.writeLong(datep.getYear());
-                    result.set(abvsInner);
-                } catch (IOException e) {
-                    throw new SystemException(ErrorCode.SYSE0001, e);
-                }
-            }
-        };
+    protected int getInputTag() {
+        return ValueTag.XS_DATE_TAG;
+    }
+
+    @Override
+    protected long getInteger(TaggedValuePointable tvp) {
+        tvp.getValue(datep);
+        return datep.getYear();
     }
 }

Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/datetime/FnYearFromDateTimeScalarEvaluatorFactory.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/datetime/FnYearFromDateTimeScalarEvaluatorFactory.java?rev=1381431&r1=1381430&r2=1381431&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/datetime/FnYearFromDateTimeScalarEvaluatorFactory.java
(original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/datetime/FnYearFromDateTimeScalarEvaluatorFactory.java
Wed Sep  5 22:46:16 2012
@@ -1,55 +1,27 @@
 package org.apache.vxquery.runtime.functions.datetime;
 
-import java.io.DataOutput;
-import java.io.IOException;
-
 import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
 import org.apache.vxquery.datamodel.accessors.atomic.XSDateTimePointable;
 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;
-import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
 
-public class FnYearFromDateTimeScalarEvaluatorFactory extends AbstractTaggedValueArgumentScalarEvaluatorFactory
{
+public class FnYearFromDateTimeScalarEvaluatorFactory extends AbstractValueFromDateTimeScalarEvaluatorFactory
{
     private static final long serialVersionUID = 1L;
+    final XSDateTimePointable datetimep = (XSDateTimePointable) XSDateTimePointable.FACTORY.createPointable();
 
     public FnYearFromDateTimeScalarEvaluatorFactory(IScalarEvaluatorFactory[] args) {
         super(args);
     }
 
     @Override
-    protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[]
args)
-            throws AlgebricksException {
-        final XSDateTimePointable datetimep = (XSDateTimePointable) XSDateTimePointable.FACTORY.createPointable();
-        final ArrayBackedValueStorage abvsInner = new ArrayBackedValueStorage();
-        final DataOutput dOutInner = abvsInner.getDataOutput();
-
-        return new AbstractTaggedValueArgumentScalarEvaluator(args) {
-            @Override
-            protected void evaluate(TaggedValuePointable[] args, IPointable result) throws
SystemException {
-                TaggedValuePointable tvp1 = args[0];
-                if (tvp1.getTag() != ValueTag.XS_DATETIME_TAG) {
-                    throw new SystemException(ErrorCode.FORG0006);
-                }
-                tvp1.getValue(datetimep);
-
-                try {
-                    abvsInner.reset();
-                    dOutInner.write(ValueTag.XS_INTEGER_TAG);
-                    dOutInner.writeLong(datetimep.getYear());
-                    result.set(abvsInner);
-                } catch (IOException e) {
-                    throw new SystemException(ErrorCode.SYSE0001, e);
-                }
-            }
-        };
+    protected int getInputTag() {
+        return ValueTag.XS_DATETIME_TAG;
+    }
+
+    @Override
+    protected long getInteger(TaggedValuePointable tvp) {
+        tvp.getValue(datetimep);
+        return datetimep.getYear();
     }
 }

Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/datetime/FnYearsFromDurationScalarEvaluatorFactory.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/datetime/FnYearsFromDurationScalarEvaluatorFactory.java?rev=1381431&r1=1381430&r2=1381431&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/datetime/FnYearsFromDurationScalarEvaluatorFactory.java
(original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/datetime/FnYearsFromDurationScalarEvaluatorFactory.java
Wed Sep  5 22:46:16 2012
@@ -1,25 +1,8 @@
 package org.apache.vxquery.runtime.functions.datetime;
 
-import java.io.DataOutput;
-import java.io.IOException;
-
-import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
-import org.apache.vxquery.datamodel.accessors.atomic.XSDurationPointable;
-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;
-import edu.uci.ics.hyracks.data.std.primitive.IntegerPointable;
-import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
 
-public class FnYearsFromDurationScalarEvaluatorFactory extends AbstractTaggedValueArgumentScalarEvaluatorFactory
{
+public class FnYearsFromDurationScalarEvaluatorFactory extends AbstractValueFromDurationScalarEvaluatorFactory
{
     private static final long serialVersionUID = 1L;
 
     public FnYearsFromDurationScalarEvaluatorFactory(IScalarEvaluatorFactory[] args) {
@@ -27,39 +10,8 @@ public class FnYearsFromDurationScalarEv
     }
 
     @Override
-    protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[]
args)
-            throws AlgebricksException {
-        final XSDurationPointable durationp = (XSDurationPointable) XSDurationPointable.FACTORY.createPointable();
-        final IntegerPointable intp = (IntegerPointable) IntegerPointable.FACTORY.createPointable();
-        final ArrayBackedValueStorage abvsInner = new ArrayBackedValueStorage();
-        final DataOutput dOutInner = abvsInner.getDataOutput();
-
-        return new AbstractTaggedValueArgumentScalarEvaluator(args) {
-            @Override
-            protected void evaluate(TaggedValuePointable[] args, IPointable result) throws
SystemException {
-                TaggedValuePointable tvp1 = args[0];
-                long value;
-                if (tvp1.getTag() == ValueTag.XS_DURATION_TAG) {
-                    tvp1.getValue(durationp);
-                    value = durationp.getYearMonth() / 12;
-                } else if (tvp1.getTag() == ValueTag.XS_DAY_TIME_DURATION_TAG) {
-                    value = 0;
-                } else if (tvp1.getTag() == ValueTag.XS_YEAR_MONTH_DURATION_TAG) {
-                    tvp1.getValue(intp);
-                    value = intp.getInteger() /12;
-                } else {
-                    throw new SystemException(ErrorCode.FORG0006);
-                }
-
-                try {
-                    abvsInner.reset();
-                    dOutInner.write(ValueTag.XS_INTEGER_TAG);
-                    dOutInner.writeLong(value);
-                    result.set(abvsInner);
-                } catch (IOException e) {
-                    throw new SystemException(ErrorCode.SYSE0001, e);
-                }
-            }
-        };
+    protected long convertDuration(long YMDuration, long DTDuration) {
+        return (YMDuration / 12);
     }
+
 }



Mime
View raw message