incubator-vxquery-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prest...@apache.org
Subject svn commit: r1381442 - in /incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery: functions/builtin-functions.xml runtime/functions/datetime/FnImplicitTimezoneScalarEvaluatorFactory.java
Date Wed, 05 Sep 2012 23:33:30 GMT
Author: prestonc
Date: Wed Sep  5 23:33:30 2012
New Revision: 1381442

URL: http://svn.apache.org/viewvc?rev=1381442&view=rev
Log:
Added Implicit Timezone.

Added:
    incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/datetime/FnImplicitTimezoneScalarEvaluatorFactory.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=1381442&r1=1381441&r2=1381442&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
Wed Sep  5 23:33:30 2012
@@ -416,6 +416,7 @@
     <!-- fn:implicit-timezone()  as xs:dayTimeDuration -->
     <function name="fn:implicit-timezone">
         <return type="xs:dayTimeDuration"/>
+        <runtime type="scalar" class="org.apache.vxquery.runtime.functions.datetime.FnImplicitTimezoneScalarEvaluatorFactory"/>
     </function>
 
     <!-- fn:in-scope-prefixes( $element as element())  as xs:string* -->

Added: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/datetime/FnImplicitTimezoneScalarEvaluatorFactory.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/datetime/FnImplicitTimezoneScalarEvaluatorFactory.java?rev=1381442&view=auto
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/datetime/FnImplicitTimezoneScalarEvaluatorFactory.java
(added)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/datetime/FnImplicitTimezoneScalarEvaluatorFactory.java
Wed Sep  5 23:33:30 2012
@@ -0,0 +1,56 @@
+package org.apache.vxquery.runtime.functions.datetime;
+
+import java.io.DataOutput;
+import java.io.IOException;
+
+import org.apache.vxquery.context.DynamicContext;
+import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
+import org.apache.vxquery.datamodel.accessors.atomic.XSDateTimePointable;
+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 FnImplicitTimezoneScalarEvaluatorFactory extends AbstractTaggedValueArgumentScalarEvaluatorFactory
{
+    private static final long serialVersionUID = 1L;
+
+    public FnImplicitTimezoneScalarEvaluatorFactory(IScalarEvaluatorFactory[] args) {
+        super(args);
+    }
+
+    @Override
+    protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[]
args)
+            throws AlgebricksException {
+        final DynamicContext dCtx = (DynamicContext) ctx.getJobletContext().getGlobalJobData();
+        final XSDateTimePointable datetimep = (XSDateTimePointable) XSDateTimePointable.FACTORY.createPointable();
+        final ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
+        final DataOutput dOut = abvs.getDataOutput();
+
+        return new AbstractTaggedValueArgumentScalarEvaluator(args) {
+            @Override
+            protected void evaluate(TaggedValuePointable[] args, IPointable result) throws
SystemException {
+                try {
+                    dCtx.getCurrentDateTime(datetimep);
+                    long value = datetimep.getTimezoneHour() * DateTime.CHRONON_OF_HOUR +
datetimep.getTimezoneMinute()
+                            * DateTime.CHRONON_OF_MINUTE;
+
+                    abvs.reset();
+                    dOut.write(ValueTag.XS_DAY_TIME_DURATION_TAG);
+                    dOut.writeLong(value);
+                    result.set(abvs);
+                } catch (IOException e) {
+                    throw new SystemException(ErrorCode.SYSE0001, e);
+                }
+            }
+        };
+    }
+}

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



Mime
View raw message